Skip to content

Instantly share code, notes, and snippets.

@ambiorixg12
Created December 19, 2018 03:04
Show Gist options
  • Save ambiorixg12/2c208cac05b129dd50bad24564da1642 to your computer and use it in GitHub Desktop.
Save ambiorixg12/2c208cac05b129dd50bad24564da1642 to your computer and use it in GitHub Desktop.
https://community.asterisk.org/t/call-detail-records-are-not-saving-in-cdr/76743/6
Install packages
apt-get install unixodbc-dev unixodbc-bin unixodbc
/etc/odbc.ini
[asterisk-mysql]
Description = MySQL connection to ‘asterisk’ database
Driver = MySQL
Database = asterisk
Server = localhost
UserName = root
Password = ‘’
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
This lib need to be downloaded from MYSQL SITE
/etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8S.so
FileUsage = 1
/etc/asterisk/cdr_adaptive_odbc.conf
[asterisk-mysql]
connection=asterisk-mysql
table=cdr
alias start => calldate
/etc/asterisk/res_odbc.conf
[asterisk-mysql]
enabled => yes
dsn => asterisk-mysql
username => root
password => ‘’
pre-connect => yes
assuming asterisk db exist create the table
CREATE TABLE cdr (
calldate datetime NULL ,
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 ‘’
);
restart asterisk
service asterisk restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment