Asterisk CDR in MySQL

Install Mysql Server and MysqlClient

apt-get install php5-mysql mysql-client-5.0 mysql-client libmysqlclient15-dev mysql-server mysql-common

Install Asterisk-Addons

cd /usr/src

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-addons-1.4.9.tar.gz

tar xvzf asterisk-addons-1.4.9.tar.gz

cd asterisk-addons*

./configure

make menuselect

select:

–> 1. Applications
[*] 1. app_addon_sql_mysql
–> 2. Call Detail Recording
[*] 1. cdr_addon_mysql

make && make install

Create Database

mysql -u root -p

CREATE DATABASE asterisk;

GRANT INSERT
ON asterisk.*
TO asterisk@localhost
IDENTIFIED BY ‘yourpassword’;

USE asterisk;

CREATE TABLE `cdr` (
`calldate` datetime NOT NULL default ‘0000-00-00 00:00:00’,
`clid` varchar(80) NOT NULL default ”,
`src` varchar(80) NOT NULL default ”,
`dst` varchar(80) NOT NULL default ”,
`dcontext` varchar(80) NOT NULL default ”,
`channel` varchar(80) NOT NULL default ”,
`dstchannel` varchar(80) NOT NULL default ”,
`lastapp` varchar(80) NOT NULL default ”,
`lastdata` varchar(80) NOT NULL default ”,
`duration` int(11) NOT NULL default ‘0’,
`billsec` int(11) NOT NULL default ‘0’,
`disposition` varchar(45) NOT NULL default ”,
`amaflags` int(11) NOT NULL default ‘0’,
`accountcode` varchar(20) NOT NULL default ”,
`userfield` varchar(255) NOT NULL default ”
);

ALTER TABLE `cdr` ADD `uniqueid` VARCHAR(32) NOT NULL default ”;
ALTER TABLE `cdr` ADD INDEX ( `calldate` );
ALTER TABLE `cdr` ADD INDEX ( `dst` );
ALTER TABLE `cdr` ADD INDEX ( `accountcode` );

Configure Asterisk CDR Mysql

vim /etc/asterisk/cdr.conf

[general]

enabled=yes

vim /etc/asterisk/cdr_mysql.conf

[global]
hostname=localhost
dbname=asterisk
table=cdr
password=”yourpassword”
user=asterisk
port=3306
;sock=/tmp/mysql.sock
;userfield=1

vim /etc/asterisk/modules.conf

load => cdr_addon_mysql.so

Restarting Asterisk

asterisk -r

CLI> restart when convenient

CLI > asterisk -r

CLI > cdr mysql status
Connected to asterisk@localhost, port 3306 using table cdr for 1 minutes, 28 seconds.
Wrote 0 records since last restart.

This it all..


14 responses to “Asterisk CDR in MySQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: