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