root/doc/INSTALL.txt

Revision 1075, 13.7 kB (checked in by Adrian Georgescu <ag@…>, 4 weeks ago)

Remove obsolete info

Line 
1
2CDRTool installation
3--------------------
4
5Obtain the software from http://cdrtool.ag-projects.com. The software is
6available as a tar archive or as a debian package.
7
8Installing from the tar archive:
9
10Change directory to your web root (/var/www on Debian systems)
11
12tar zxvf cdrtool*.tgz
13
14You must create /etc/cdrtool config directory unless you have installed the
15debian package.
16
17For people running Debian testing or unstable on an i386 architecture there
18is an official public repository provided by AG Projects. To use it, add
19these lines in /etc/apt/sources.list
20
21# AG Projects software
22deb     http://ag-projects.com/debian unstable main
23deb-src http://ag-projects.com/debian unstable main
24
25Install the AG Projects debian software signing key:
26
27wget http://download.ag-projects.com/agp-debian-gpg.key
28apt-key add agp-debian-gpg.key
29
30After that, run:
31
32apt-get update
33apt-get install cdrtool
34
35
36Create CDRTool database
37-----------------------
38
39You need MySQL root access with GRANT priviledges from the machine where
40CDRTool runs, otherwise copy the files required by setup/setup_mysql.sh to
41the MySQL machine and run the script locally.
42
43Change the MySQL password of the cdrtool user from file
44setup/create_users.mysql
45
46Then run the database setup script:
47
48cd /var/www/CDRtool/setup/mysql/
49./setup_mysql.sh <password> <dbserver>
50
51The script performs the following:
52
531. It adds to the MySQL server a user for cdrtool software
542. It creates a new MySQL database "cdrtool"
553. It creates a default web user admin/admin, you may use
56   this initial account to login in the web interface
574. It populates the cdrtool database with initial values
58
59
60PHP setup and Apache setup
61--------------------------
62
63Install PHP and dependencies. If you have chosen to install the debian
64package, the dependencies will be resolved during installation.
65
66Example for Debian systems and php5:
67
68Enable php-mysql module in /etc/php5/*/php.ini:
69
70extension=mysql.so
71
72Enable php in apache web server. Configuration example for apache on
73Debian systems:
74
75/etc/apache/httpd.conf
76
77DirectoryIndex index.phtml index.php index.html index.htm index.shtml index.cgi
78AddType application/x-httpd-php .php
79AddType application/x-httpd-php .phtml
80
81Make sure php module is enbaled in apache configuration. For apache this is
82done in /etc/apache/modules.conf:
83
84LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
85
86Change AllowOverride None  to
87    AllowOverride All
88
89For apache2 us a2enmode php command.
90
91Create a virtual host for cdrtool. Example for apache2:
92
93cp setup/apache2/sites-available/cdrtool.example.com /etc/apache2/sites-enabled
94cp setup/apache2/conf.d/cdrtool /etc/apache2/conf.d/
95
96<VirtualHost cdrtool.example.com:80>
97
98   ServerName          cdrtool.example.com
99   DocumentRoot        /var/www/
100   CustomLog           /var/log/apache2/cdrtool-access.log combined
101   ErrorLog            /var/log/apache2/cdrtool-errors.log
102   SetEnvIf User-Agent ".*MSIE.*"      nokeepalive ssl-unclean-shutdown
103
104   # To enable SSL:
105   # a2enmode ssl
106   # add Listen 443 to ports.conf file
107   # generate site certificates
108
109   # SSLEngine           On
110   # SSLCertificateFile    /etc/apache2/ssl/snakeoil-rsa.crt
111   # SSLCertificateKeyFile /etc/apache2/ssl/snakeoil-rsa.key
112
113</VirtualHost>
114
115Enable the virtual site using:
116
117a2ensite cdrtool.example.com
118
119You may enable ssl using "a2enmod ssl" command. If you use ssl you must also
120generate a site certificate using the instructions provided by apache2
121software.
122
123
124Create a configuration file
125---------------------------
126
127cp /var/www/CDRTool/setup/global.inc.simple.sample /etc/cdrtool/global.inc
128
129Edit global.inc and setup your variables to match your system.
130
131For each different datasource you must instantiate a new class
132extending one of the existing classes (ser, asterisk or cisco).
133
134global.inc.in contains a more elaborate example for setting up
135datasources
136
137
138Enable rating engine
139--------------------
140
141The rating engine is used for prepaid applications and as price calculator
142for postpaid traffic. It provides access to the rating tables and stays in
143memory (running as a daemon).
144
145See the information in the head of the scripts/ratingEngine.php daemon for
146how to enable prepaid or other rating functionality. For prepaid, an
147external B2BUA is required, CDRTool provides only the rating and update
148balance functions.
149
150Set the IP and port where the rating engine listens to and the OpenSIPs
151datasource in global.inc:
152
153$RatingEngine=array("socketIP"   =>  "IP.address.of.the.private.interface.of.cdrtool.example.com",
154                     "socketPort" => "9024",
155                     "CDRS_class" => "ser_radius",
156                     "allow"      => array('10.0.0')
157                   );
158
159The MSQL schema for prepaid accounts: setup/mysql/create_prepaid.mysql
160
161For non Debian systems you must create /etc/default/cdrtool as follows:
162
163RUN_ratingEngine=yes
164
165For non Debian systems copy the init script from setup/init.d/cdrtool to
166/etc/init.d/cdrtool
167
168Then start the rating engine:
169
170/etc/init.d/cdrtool restart
171
172
173High availability
174----------------- 
175
176Setup heartbeat and MySQL replication.
177
178
179CRON setup
180----------
181
182Some operations must be scheduled to run periodically by cron. Such
183operations are the scripts that block fraudulous accounts in OpenSIPs,
184normalize the call detail records, purge the old SIP traces.
185
186The sample cron file is in /var/www/CDRTool/setup/crontabs/
187
188This is done automatically if you install the debian package.
189
190
191RADIUS setup
192------------
193
194CDRTool works with FreeRadius server from http://www.freeradius.org
195
196apt-get install freeradius freeradius-mysql
197Create the database for radius tables on MySQL server
198
199mysqladmin -u root create radius
200
201Create RADIUS tables
202
203The paths might differ depending on freeradius installation
204
205cp /usr/share/doc/freeradius/examples/db_mysql.sql.gz .
206gunzip db_mysql.sql.gz
207mysql -u root radius < /usr/share/doc/freeradius/examples/db_mysql.sql
208
209Patch radacct table for storage of CISCO VSA and rating. Apply a patch to
210the default radacct table. This will add fields necessary to store Vendor
211Specific Atributes from Cisco or OpenSIPs.
212
213It is not possible to mix call details records from CISCO and OpenSIPs
214in the same radius table. You need to create multiple radius server
215profiles and save the CDRs into dedicated tables for each datasource.
216
217Modify the default radacct table for OpenSIPs by running:
218
219/var/www/CDRTool/setup/radius/OpenSIPs/radacct-patch.sh
220
221and for CISCO by running:
222
223/var/www/CDRTool/setup/radius/CISCO/radacct-patch.sh
224
225Configure Freeradius to write data into the radacct table:
226
227cp /var/www/CDRTool/setup/radius/OpenSIPs/sql.conf /etc/freeradius/sql.conf 
228
229For large volume of CDRs it is usefull automatically rotate the tables in
230which the data is written.
231
232/var/www/CDRTool/setup/radius/OpenSIPs/radius_accounting.*, contain mysql
233procedures that automatically create monthly tables in the format
234radacctYYYYMM. To use mysql procedures, your must use MySQL server version 5
235or greater and Freeradius server mysql module must be compiled to support
236CLIENT_MULTI_RESULTS mysql connection flag. This must be done in
237src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c:
238
239if (!(mysql_sock->sock = mysql_real_connect(&(mysql_sock->conn),
240                                            config->sql_server,
241                                            config->sql_login,
242                                            config->sql_password,
243                                            config->sql_db,
244                                            atoi(config->sql_port),
245                                            NULL,
246                                            CLIENT_FOUND_ROWS|CLIENT_MULTI_RESULTS ))) {
247
248Also, if you use MediaProxy for accounting in combination with OpenSIPs you
249must use the MediaProxy version that supports the same mysql procedures.
250 
251Edit the database connection details in sql.conf and restart Freeradius
252server.
253
254Add RADIUS clients in clients.conf. Each device sending RADIUS accounting
255requests must be added to /etc/radddb/clients.conf. Examples:
256
257client 10.0.0.0/8 {
258        secret=DssUET01
259        nastype=other
260        shortname=localnet
261}
262
263Enable MySQL accounting in FreeRadius server. Edit radius.conf "sql" must be uncommented
264or added if missing.   
265
266# accounting {
267        detail
268        sql
269        }
270
271Copy /var/www/CDRTool/setup/radius/OpenSIPs/dictionary.ser to /etc/freeradius
272
273
274OpenSIPs setup
275-------------
276
277Enable MySQL storage for subscribers and Radius accounting. For SIP tracing
278you need to configure the OpenSIPs siptrace module. To enable quota you must
279add an extra column in the subscriber table:
280
281alter table openser.subscriber add column quota int not null;
282
283Entries required in openser.cfg:
284
285loadmodule "acc.so"
286
287modparam("acc", "failed_transaction_flag", 1)
288modparam("acc", "report_cancels",     0)
289modparam("acc", "report_ack",         0)
290modparam("acc", "early_media",        0)
291
292modparam("acc", "log_level",          1)
293modparam("acc", "log_flag",           1)
294modparam("acc", "log_missed_flag",    1)
295
296modparam("acc", "radius_config",      "/etc/openser/radius/client.conf")
297modparam("acc", "radius_flag",        1)
298modparam("acc", "radius_missed_flag", 1)
299modparam("acc", "radius_extra",       "User-Name=$Au; \
300                                       Calling-Station-Id=$from; \
301                                       Called-Station-Id=$to; \
302                                       Sip-Translated-Request-URI=$ruri; \
303                                       Sip-RPid=$avp(s:rpid); \
304                                       Source-IP=$si; \
305                                       Source-Port=$sp; \
306                                       Canonical-URI=$avp(s:can_uri); \
307                                       Billing-Party=$avp(billing_party); \
308                                       Divert-Reason=$avp(s:divert_reason); \
309                                       X-RTP-Stat=$hdr(X-RTP-Stat); \
310                                       User-Agent=$hdr(user-agent); \
311                                       Contact=$hdr(contact); \
312                                       Event=$hdr(event); \
313                                       SIP-Proxy-IP=$avp(s:sip_proxy_ip); \
314                                       ENUM-TLD=$avp(s:enum_tld)")
315
316Further, you must enable accounting in various parts of the routing script
317by setting the accounting flag and saving the AVP containing the proxy IP
318address. It is important to save $avp(s:can_uri) after the Proxy has performed
319all possible lookups except DNS. The Canonical-URI will be used for rating
320the session. Example:
321
322route {
323       ...
324       setflag(ACCOUNTING_FLAG);
325       $avp(s:can_uri) = $ru;
326       ...
327}
328
329Copy /var/www/CDRTool/setup/radius/OpenSIPs/dictionary.ser to /etc/openser/radius/
330and uncomment the line:
331
332$INCLUDE               /etc/radiusclient-ng/dictionary
333
334Note
335----
336
337Many of the standard Radius attributes previously logged by default in the
338accounting packets must be added manually to "radius_extra" parameter of the
339acc module when using OpenSIPs >= 1.2.
340
341
342MediaProxy setup
343----------------
344
345MediaProy can log into CDRTool the IP bandwidth utilization, the codecs and
346the User Agents. MediaProxy logs this information into the database used by
347the Radiusserver, the radacct table.
348
349MediaProxy can also correct the session duration of CDRs for which no BYE
350messages have been received.
351
352The following information is logged:
353
354- InputOctets and OutputOctets
355- CodecType (like GSM or G711)
356- ApplicationType (text/audio/video)
357- User Agent(s)
358- Media IP source and IP destination
359
360See MediaProxy documentation for how to enable Radius or database accounting.
361
362
363Asterisk setup
364--------------
365
366Download from cvs the asterisk-addons and patch asterisk to store CDRs in
367MySQL.
368
369See /var/www/CDRTool/setup/asterisk for more information.
370
371
372Cisco setup
373-----------
374
375Use the CISCO CLI, enter enable mode and configuration from terminal:
376
377>enable
378config terminal
379aaa new-model
380aaa group server radius aaa.router
381server RADIUS_SERVER_IP auth-port 1812 acct-port 1813
382aaa accounting connection h323 start-stop group radius
383gw-accounting h323
384gw-accounting h323 vsa
385gw-accounting voip
386
387
388Manual CDR uploads
389------------------
390
391If MySQL is down you will miss CDRs written by RADIUS. These CDRs can be
392reload manually from radius accounting files using the supplied upload
393scripts in scripts directory (IPNX, OpenSIPs and CISCO import scripts available).
394
395
396Q931 Release codes for Cisco
397----------------------------
398
399In CDRTool CISCO hexadecimal release codes are automatically mapped to Q931
400release codes.
401
402
403Rating engine
404-------------
405
406See RATING file.
407
408
409Monitoring
410----------
411
412Monit can check if the rating engine stopped working and restart it. A
413sample configuration file for monit is available in setup/monit/monitrc.
414Edit the IP address and hostname where the rating engine runs and copy
415/var/www/CDRTool/setup/monit/monitrc /etc/monit/monit.d/cdrtool
416
417Usage statistics
418----------------
419
420CDRTool can build  usage statistics of the number of online SIP devices from
421OpenSIPs, simultaneous number of media streams and relayed IP traffic by
422MediaProxy.
423
424Define DB_siponline as a new database class in global.inc. Example:
425
426class DB_siponline extends DB_Sql {
427  var $Host     = "db";
428  var $Database = "openser";
429  var $User     = "openser";
430  var $Password = "password";
431  var $Halt_On_Error ="no";
432}
433
434Define all media proxy servers as follows:
435
436For MediaProxy 1.x: mediaServers variable of each data source
437For MediaProxy 2.x: mediaDispatcher variable of each data source
438
439The script that gathers the usage information and builds the graphical
440statistics is /var/www/CDRTool/scripts/buildStatistics.php
441
442This script runs as a cron job every 5 minutes.
443
444The usage information is cumulated in /tmp/CDRTool-sip-statistics.txt file,
445which is a plain text file with one line per domain and values separated by
446tabs. This file can be easily parsed by external scripts to build statistics
447using other tools like SNMP.
448
449To see the graphical statistics, follow the Usage link.
Note: See TracBrowser for help on using the browser.