Mercurial > hg > freeDiameter
annotate contrib/app_acct_tools/README @ 1228:e5010975da35
Fix typo in comment.
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Thu, 18 Jul 2013 14:45:37 +0200 |
parents | 4cdf146f11d5 |
children |
rev | line source |
---|---|
533
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 This folder contains several tools to use and parse the data from the app_acct.fdx extension. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 - database.sql : |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 An example database format for use with the scripts in this folder. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 - app_acct.conf : |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 The part of app_acct.conf that is relevant to this database schema. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
8 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 - purge_to_file.php : |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 This PHP script is used to take the records from the incoming table (stored by app_acct.fdx |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 extension) and save these records in a file in SQL format. This is similar to pg_dump |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 command, except that all the records that have been saved in the file are removed from |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 the table. This can be used in cron jobs for example to maintain a reasonable size of |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 the incoming table and move the data to another host for off-line processing. It can |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 also be useful to aggregate the data from different hosts, if you are load-balancing your |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 accounting servers for example (granted that all app_acct.fdx use identical table format |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 on all the servers). See the top of the file for configuration parameters. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 - process_records.php : |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 This PHP script processes the records pertaining to users sessions, as follow: |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * when a session is complete (STOP record received), it stores a session summary |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 into the processed records table (see process_database.sql file for format). |
1228 | 23 * It optionally archives the processed records into a different table, before deleting them. |
533
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * It can also move records of unterminated sessions that are older than a configurable time |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 to an orphan_records table, so that they are not re-processed every time. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
26 This orphans table must have the same structure as the "incoming" table. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
27 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
28 - display_results.php, display_self.php, display_stats.php : |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 These scripts give a few examples of how to display the processed data. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
30 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
31 USAGE: |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
32 *) Initial: create your database using database.sql file |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 *) Configure the app_acct.fdx extension using tips from app_acct.conf |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 The following processing can be run for example as cron jobs. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 1) On each accounting server for the realm, configure the app_acct.fdx extension to |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 dump the records in a local database (all servers must use the same database format). |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 The table would typically be "incoming". |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 2) Run the purge_to_file.php script on each server regularly, then move the generated |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 files onto a single server for processing. This server only needs the other tables. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 3) Add the data from the files into the database in this server by running: |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 psql < file.sql |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 Each file that has been added should then be archived and removed so that it is not |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 re-added later. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 4) Run the process_records.php script on this processing server. Now, the database |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 contains the aggregated data that can be visualized with display_*.php scripts. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
47 |