By default Asterisk generates CDR records in a CSV files located in /var/log/asterisk/cdr-csv directory. Asterisk can also store CDR records in a database such as MySQL or PostgreSQL database as an alternative to CSV files. If your CDR records are stored in a database, you can install a web-based CDR analyzer to easily manage and analyze your CDR records like Asterisk-stat by http://areski.net.
Here are some features of Asterisk-stat
To install asterisk-stat, you need to install HTTP server, PHP and MySQL database. I assume that you are running CentOS 4.4 or higher and have Asterisk 1.2 installed in you server. To install Asterisk 1.2, checkout this tutorial http://www.cahilig.org/install-asterisk-12-centos-4-and-centos-5 or download the auto install script form http://www.cahilig.org/install-asterisk-12-auto-install-script-centos-4-....
To get started, install the Apache web server, PHP and MySQL database. Run this command in the console.
Start the Apache and MySQL and make sure that it will run during boot time by typing this command.
Go to /usr/src/directory, download and install asterisk-addon source from Asterisk website.
Copy the file cdr_mysql.conf.sample from configs directory to /etc/asterisk, rename it to cdr_mysql.conf. Edit the database configuration.
[global] hostname=localhost dbname=asteriskcdrdb table=cdr password=password user=asterisk port=3306
Then edit your /etc/asterisk/modules.conf and add the cdr_addon_mysql.so under the [global] section.
[global] load => cdr_addon_mysql.so
Login to your MySQL server and create a root password to secure your server then create a database to store your CDR records.
Create Asterisk CDR databases and user to the databases.
Create a table called cdr under the database name you will be using the following schema.
Restart your Asterisk PBX, start making a call and check if the CDR is written in your database.
You can also check in Asterisk console by typing this Asterisk command:
It will display the message that look exactly like this:
Connected to asteriskcdrdb@localhost using table cdr for 0 hours, 15 minutes, 15 seconds.
Wrote 1 records since last restart.
If you see the message similar from above, you have successfully installed asterisk-addon.
Go to /var/www/html/ directory and grab asterisk-stats package from http://areski.net.
Rename asterisk-stat-v2_0_1 to asterisk-stats and edit the defines.php in /lib directory.
define ("WEBROOT", "http://hostname/asterisk-stats/"); define ("FSROOT", "/var/www/html/asterisk-stats/"); define ("LIBDIR", FSROOT."lib/"); define ("HOST", "localhost"); define ("PORT", "3306"); define ("USER", "asterisk"); define ("PASS", "password"); define ("DBNAME", "asteriskcdrdb"); define ("DB_TYPE", "mysql"); define ("DB_TABLENAME", "cdr");
Create a symlink from cdr.php to index.php
And the URL would be:
http://hostname/asterisk-stats
The asterisk-stats v2.0.1 has a bug when you are exporting CDR in pdf format.
To fix the bug, you need to change line 5 of export_pdf.php from:
include_once(dirname(FILE) . "/lib/fpdf.php');
to:
include_once(dirname(FILE) . "/lib/fpdf.php");
It should be fine now, you can export your CDR to PDF files.
Your Asterisk-stat is done, however it is not yet secured, everybody can login without any authentication. If you want to put an authentication to your Asterisk-stat, just follow this howto. It will require web site visitors to login with a user id and password.
You can delete the CDR in your MySQL database using phpMyAdmin.
评论