Contact

Blogs

Take a look at the things that interest us.

Asterisk 18 realtime cdr call records

Wesley Wesley 3 years
Asterisk 18 realtime cdr call records

In this tutorial, we are going to setup a connection between our Asterisk 18 and MySQL database to store real-time call records into our cdr table.

Requirements

  • Asterisk 18
  • ODBC connection between Asterisk and Mysql

Setting up realtime cdr call records

To get started with cdr, you'll first need to add the cdr table to your database.

CREATE TABLE cdr (
    accountcode VARCHAR(80), 
    src VARCHAR(80), 
    dst VARCHAR(80), 
    dcontext VARCHAR(80), 
    clid VARCHAR(80), 
    channel VARCHAR(80), 
    dstchannel VARCHAR(80), 
    lastapp VARCHAR(80), 
    lastdata VARCHAR(80), 
    start DATETIME, 
    answer DATETIME, 
    end DATETIME, 
    duration INTEGER, 
    billsec INTEGER, 
    disposition VARCHAR(45), 
    amaflags VARCHAR(45), 
    userfield VARCHAR(256), 
    uniqueid VARCHAR(150), 
    linkedid VARCHAR(150), 
    peeraccount VARCHAR(80), 
    sequence INTEGER
);

After the cdr table has been added, we need to update two config files within the Asterisk directorty.

Let's go to the Asterisk directory.

$ cd /etc/asterisk

Now let's open the first file.

$ vim cdr_odbc.conf

Add the following data to the config file.

[global]
dsn=asterisk
loguniqueid=yes
dispositionstring=yes
usegmtime=no
newcdrcolumns=yes 

// The dsn tag is the tag name of your odbc connector.

Now let's open the second file.

$ vim cdr_adaptive_odbc.conf

Add the following data to the config file.

[first]
connection=asterisk 
table=cdr

// The connection tag is the tag name of your odbc connector.

After setting up the cdr table and config files we will restart our current Asterisk.

$ systemctl restart asterisk

Now let's make a call between two extensions. If you have done everything correct the call records will be added to the cdr table.

Asterisk 18 realtime cdr call records 2021-08-18 12:49:18

There are no comments.

4123

Have questions about our services?

Contact our Sales team to get answers.

Contact Us
gomibako@aska-ltd.jp