# Queue log is not getting dummped in to mysql database

**URL:** <https://community.asterisk.org/t/queue-log-is-not-getting-dummped-in-to-mysql-database/38399>\
**Category:** Asterisk Support\
**Created:** [February 29, 2012, 6:09am UTC](https://community.asterisk.org/t/queue-log-is-not-getting-dummped-in-to-mysql-database/38399 "2012-02-29T06:09:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![urmi.l](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@urmi.l](https://community.asterisk.org/u/urmi.l)\
**Post date:** [February 29, 2012, 6:09am UTC](https://community.asterisk.org/t/queue-log-is-not-getting-dummped-in-to-mysql-database/38399/1 "2012-02-29T06:09:43Z")

</div>

Hello,

I have asterisk 1.6.2.22 installed on my centOS. I want to log the queue\_log data in to mysql DB. But its not going to DB though the entries are there in the ‘/var/log/asterisk/queue\_log’.

I m getting warning on my CLI :

> [@](#):
>
> \*CLI\> == Using SIP RTP CoS mark 5  
> – Executing [\*\*1@default:1] AgentLogin(“SIP/1000-00000003”, “1000”) in new stack  
> – \<SIP/1000-00000003\> Playing ‘agent-loginok.gsm’ (language ‘en’)  
> – Started music on hold, class ‘default’, on SIP/1000-00000003  
> [Feb 29 11:07:13] [color=#FF0000]WARNING[5365]: config.c:2018 find\_engine: Realtime mapping for ‘queue\_log’ found to engine ‘mysql’, but the engine is not available[/color]  
> == Agent ‘1000’ logged in (format ulaw/ulaw)  
> – Stopped music on hold on SIP/1000-00000003  
> [Feb 29 11:07:18] [color=#FF0000]WARNING[5365]: config.c:2018 find\_engine: Realtime mapping for ‘queue\_log’ found to engine ‘mysql’, but the engine is not available[/color]  
> == Agent ‘1000’ logged out  
> == Spawn extension (default, \*\*1, 1) exited non-zero on ‘SIP/1000-00000003’

extconfig.conf

[quote]queue\_log =\> mysql,general ; for asterisk-1.6.x here we have to specify the context instead of database name  
[/quote]

res\_mysql.conf

[quote][general]  
;dbhost = localhost  
dbhost = 127.0.0.1  
dbname = asterisk  
dbuser = root  
dbpass = rig@1123  
dbport = 3306  
dbsock = /tmp/mysql.sock  
[/quote]

logger.conf

> [@](#):
>
> queue\_log = yes  
> queue\_log\_name = queue\_log

/var/log/asterisk/queue\_log

> [@](#):
>
> 1330493197|NONE|NONE|NONE|QUEUESTART|  
> 1330493327|NONE|NONE|NONE|QUEUESTART|  
> 1330493373|1330493371.0|NONE|Agent/1000|AGENTLOGIN|SIP/1000-00000000  
> 1330493388|1330493371.0|NONE|Agent/1000|AGENTLOGOFF|SIP/1000-00000000|15  
> 1330493394|1330493393.1|NONE|Agent/1000|AGENTLOGIN|SIP/1000-00000001  
> 1330493406|1330493406.2|TechSupportDOA|NONE|ENTERQUEUE||1000  
> 1330493406|1330493406.2|TechSupportDOA|Agent/1000|CONNECT|0|1330493406.3|0  
> 1330493433|1330493406.2|TechSupportDOA|Agent/1000|COMPLETECALLER|0|27|1  
> 1330493434|1330493393.1|NONE|Agent/1000|AGENTLOGOFF|SIP/1000-00000001|40  
> 1330493827|NONE|NONE|NONE|CONFIGRELOAD|  
> 1330493833|1330493832.4|NONE|Agent/1000|AGENTLOGIN|SIP/1000-00000003  
> 1330493838|1330493832.4|NONE|Agent/1000|AGENTLOGOFF|SIP/1000-00000003|5

importCDR-trigger.sql

> [@](#):
>
> ## – – Triggers `queue_log`
> 
> DROP TRIGGER IF EXISTS `asterisk`.`bi_queueEvents`;  
> DELIMITER //
> 
> CREATE TRIGGER `asterisk`.`bi_queueEvents` BEFORE INSERT ON `asterisk`.`queue_log`  
> FOR EACH ROW BEGIN
> 
> IF NEW.event = ‘ADDMEMBER’ THEN  
> INSERT INTO agent\_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘READY’,FROM\_UNIXTIME(NEW.time),NULL)  
> ON DUPLICATE KEY UPDATE agentStatus = “READY”, timestamp = FROM\_UNIXTIME(NEW.time), callid = NULL;  
> ELSEIF NEW.event = ‘REMOVEMEMBER’ THEN  
> INSERT INTO `agent_status` (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘LOGGEDOUT’,FROM\_UNIXTIME(NEW.time),NULL)  
> ON DUPLICATE KEY UPDATE agentStatus = “LOGGEDOUT”, timestamp = FROM\_UNIXTIME(NEW.time), callid = NULL;  
> ELSEIF NEW.event = ‘PAUSE’ THEN  
> INSERT INTO agent\_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘PAUSE’,FROM\_UNIXTIME(NEW.time),NULL)  
> ON DUPLICATE KEY UPDATE agentStatus = “PAUSE”, timestamp = FROM\_UNIXTIME(NEW.time), callid = NULL;  
> ELSEIF NEW.event = ‘UNPAUSE’ THEN  
> INSERT INTO `agent_status` (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,‘READY’,FROM\_UNIXTIME(NEW.time),NULL)  
> ON DUPLICATE KEY UPDATE agentStatus = “READY”, timestamp = FROM\_UNIXTIME(NEW.time), callid = NULL;  
> ELSEIF NEW.event = ‘ENTERQUEUE’ THEN  
> REPLACE INTO `call_status` VALUES  
> (NEW.callid,  
> replace(replace(substring(substring\_index(NEW.data, ‘|’, 2), length(substring\_index(New.data, ‘|’, 2 - 1)) + 1), ‘|’, ‘’)  
> , ‘|’, ‘’),  
> ‘inQue’,  
> FROM\_UNIXTIME(NEW.time),  
> NEW.queuename, ‘’, ‘’, ‘’, ‘’, 0);  
> ELSEIF NEW.event = ‘CONNECT’ THEN  
> UPDATE `call_status` SET callid = NEW.callid, status = NEW.event, timestamp = FROM\_UNIXTIME(NEW.time), queue = NEW.queuename,  
> holdtime = replace(substring(substring\_index(NEW.data, ‘|’, 1), length(substring\_index(NEW.data, ‘|’, 1 - 1)) + 1), ‘|’, ‘’)  
> where callid = NEW.callid;
> 
> ```
> INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,NEW.event, FROM_UNIXTIME(NEW.time), NEW.callid) 
> ON DUPLICATE KEY UPDATE agentStatus = NEW.event, timestamp = FROM_UNIXTIME(NEW.time), callid = NEW.callid;
> 
> ```
> 
> ELSEIF NEW.event in (‘COMPLETECALLER’,‘COMPLETEAGENT’) THEN  
> UPDATE `call_status` SET callid = NEW.callid, status = NEW.event, timestamp = FROM\_UNIXTIME(NEW.time), queue = NEW.queuename,  
> originalPosition = replace(substring(substring\_index(NEW.data, ‘|’, 3), length(substring\_index(NEW.data, ‘|’, 3 - 1)) + 1), ‘|’, ‘’),  
> holdtime = replace(substring(substring\_index(NEW.data, ‘|’, 1), length(substring\_index(NEW.data, ‘|’, 1 - 1)) + 1), ‘|’, ‘’),  
> callduration = replace(substring(substring\_index(NEW.data, ‘|’, 2), length(substring\_index(NEW.data, ‘|’, 2 - 1)) + 1), ‘|’, ‘’)  
> where callid = NEW.callid;
> 
> ```
> INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES (NEW.agent,NEW.event,FROM_UNIXTIME(NEW.time),NULL) 
> ON DUPLICATE KEY UPDATE agentStatus = "READY", timestamp = FROM_UNIXTIME(NEW.time), callid = NULL;
> 
> ```
> 
> ELSEIF NEW.event in (‘TRANSFER’) THEN  
> UPDATE `call_status` SET callid = NEW.callid, status = NEW.event, timestamp = FROM\_UNIXTIME(NEW.time), queue = NEW.queuename,  
> holdtime = replace(substring(substring\_index(NEW.data, ‘|’, 1), length(substring\_index(NEW.data, ‘|’, 1 - 1)) + 1), ‘|’, ‘’),  
> callduration = replace(substring(substring\_index(NEW.data, ‘|’, 3), length(substring\_index(NEW.data, ‘|’, 3 - 1)) + 1), ‘|’, ‘’)  
> where callid = NEW.callid;
> 
> ```
> INSERT INTO agent_status (agentId,agentStatus,timestamp,callid) VALUES
> (NEW.agent,'READY',FROM_UNI	XTIME(NEW.time),NULL) ON DUPLICATE KEY UPDATE agentStatus = "READY", timestamp = FROM_UNIXTIME(NEW.time), callid = NULL;
> 
> ```
> 
> END IF;  
> END  
> //  
> DELIMITER ;

-Urmi

---

<div class="post-metadata">

**Author:** ![urmi.l](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@urmi.l](https://community.asterisk.org/u/urmi.l)\
**Post date:** [February 29, 2012, 9:28am UTC](https://community.asterisk.org/t/queue-log-is-not-getting-dummped-in-to-mysql-database/38399/2 "2012-02-29T09:28:31Z")

</div>

The above issue is resolved.

MySQL devel should be properly install. check it out if it is not there then :

> [@](#):
>
> yum install mysql\*

Run the following from the CLI :

[quote]\*CLI\> core show config mappings  
Config Engine: curl =\> mysql mapping was not there  
\*CLI\>  
\*CLI\> module show like mysql  
\*CLI\> No modules available[/quote]

I have reloaded the mysql config module.

[quote]\*CLI\> module reload res\_config\_mysql.so  
== MySQL RealTime reloaded.

\*CLI\> core show config mappings  
Config Engine: curl  
Config Engine: mysql  
===\> queue\_log (db=general, table=queue\_log)

\*CLI\> module show like mysql  
Module Description Use Count  
app\_addon\_sql\_mysql.so Simple Mysql Interface 0  
res\_config\_mysql.so MySQL RealTime Configuration Driver 0  
cdr\_addon\_mysql.so MySQL CDR Backend 0  
3 modules loaded  
[/quote]

Now, the queue log and the agent status is dumped to mysql database properly.

😄 Urmi 😄
