Skip to content

Asterisk Save queue log in MySQL database

Check for existing ODBC MySQL DSN

asterisk*CLI> odbc show 

ODBC DSN Settings
-----------------
  Name:   asterisk
  DSN:    asteriskcdr-odbc
    Last connection attempt: 2019-12-21 11:42:30
    Number of active connections: 1 (out of 1)

Add to /etc/asterisk/extconfig.conf

[settings]
; queue_log => odbc,{DSN-NAME},{TableName}
queue_log => odbc,asterisk,queue_log_test

Create table

 CREATE TABLE IF NOT EXISTS `queue_log_test` (
`time` varchar(32) DEFAULT NULL,
`callid` char(64) DEFAULT NULL,
`queuename` char(64) DEFAULT NULL,
`agent` char(64) DEFAULT NULL,
`event` char(32) DEFAULT NULL,
`data` char(64) DEFAULT NULL,
`data1` char(64) DEFAULT NULL,
`data2` char(64) DEFAULT NULL,
`data3` char(64) DEFAULT NULL,
`data4` char(64) DEFAULT NULL,
`data5` char(64) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Apply:

asterisk*CLI> reload extconfig 
Module 'extconfig' reloaded successfully.
  == Parsing '/etc/asterisk/extconfig.conf': Found
  == Binding queue_log to mysql/asterisk/queue_log_test

Awaiting for data:

MariaDB [voip]> select * from queue_log_test;
Empty set (0.00 sec)