Asterisk CDR Tables: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
New page: = Call Detail Records = The following information is based on Asterisk 1.6.x.<br> The first thing required is to create a database for the CDR to be stored, then we need to create a tables...
 
Line 35: Line 35:
cdr mysql status
cdr mysql status
</pre>
</pre>
If the command fails and does not give a response then asterisk does not see the mysql databse/table.
You should get a responce like
<pre>
Connected to databse-name@localhost, port 3306 using table table-name for 2 seconds.
<pre>
[[Category : Asterisk]]
[[Category : Asterisk]]

Revision as of 05:26, 8 October 2008

Call Detail Records

The following information is based on Asterisk 1.6.x.
The first thing required is to create a database for the CDR to be stored, then we need to create a tables.

mysql
create database asterisk-cdr;
use asterisk-cdr;

Once the databse is created and we have selected it for use, we can now create the required tables(s).

CREATE TABLE server1 (
  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 '',
  uniqueid varchar(32) NOT NULL default '',
  userfield varchar(255) NOT NULL default ''
);

Once the database is created you then need to edit the asterisk mysql.conf file to use the databse.
edit the file /etc/asterisk/cdr_mysql.conf and make the required changes.

You can then reload asterisk and make sure that it recognises mysql byt typing in:

cdr mysql status

You should get a responce like

Connected to databse-name@localhost, port 3306 using table table-name for 2 seconds.