text
stringlengths
0
152
PRIMARY KEY (`QueueDialplanParametersID`)
);
Using func_odbc, you can write a function that will return the dialplan parameters
relevant to that queue:
11 Note that we’re creating this table in our pbx schema, rather than the asterisk schema, and that is because
this is not a table that comes with Asterisk, but instead one we’re creating ourselves. We recommend letting
Asterisk and Alembic have exclusive control over the asterisk schema, and using a custom schema (such as
pbx) for anything custom we might create.
286
|
Chapter 15: Relational Database Integration
[QUEUE_DETAILS]
prefix=GET
dsn=asterisk
readsql=SELECT * FROM pbx.QueueDialplanParameters
readsql+= WHERE QueueDialplanParametersID='${ARG1}'
Then pass those parameters to the Queue() application as calls arrive:
exten => s,1,Verbose(1,Call entering queue named ${SomeValidID)
same => n,Set(QueueParameters=${GET_QUEUE_DETAILS(SomeValidID)})
same => n,Queue(${QueueParameters})
While somewhat more complicated to develop than just writing an appropriate
dialplan, the advantage is that you will be able to manage a larger number of queues,
with a wider variety of parameters, using dialplan that is flexible enough to handle
any sort of parameters the queueing application in Asterisk accepts. For anything
more than a very simple queue, we think you will find the use of a database for all this
is well worth the effort.
Writing queue_log to Database
Finally, we can store our queue_log to a database, which can make it easier for exter‐
nal applications to extract queue performance details from the system:
CREATE TABLE queue_log (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
time char(26) default NULL,
callid varchar(32) NOT NULL default '',
queuename varchar(32) NOT NULL default '',
agent varchar(32) NOT NULL default '',
event varchar(32) NOT NULL default '',
data1 varchar(100) NOT NULL default '',
data2 varchar(100) NOT NULL default '',
data3 varchar(100) NOT NULL default '',
data4 varchar(100) NOT NULL default '',
data5 varchar(100) NOT NULL default '',
PRIMARY KEY (`id`)
);
Edit your extconfig.conf file to refer to the queue_log table:
[settings]
queue_log => odbc,asterisk,queue_log
A restart of Asterisk, and your queue will now log information to the database. As an
example, logging an agent into the sales queue should produce something like this:
mysql> select * from queue_log;
+----+----------------------------+----------------------+-----------+
| id | time | callid | queuename |
+----+----------------------------+----------------------+-----------+
| 1 | 2013-01-22 15:07:49.772263 | NONE | NONE |
| 2 | 2013-01-22 15:07:49.809028 | toronto-1358885269.1 | support |
+----+----------------------------+----------------------+-----------+
Database Integration of ACD Queues
|
287
+------------------+------------+-------+-------+-------+-------+-------+
| agent | event | data1 | data2 | data3 | data4 | data5 |
+------------------+------------+-------+-------+-------+-------+-------+
| NONE | QUEUESTART | | | | | |
| SIP/0000FFFF0001 | ADDMEMBER | | | | | |
+------------------+------------+-------+-------+-------+-------+-------+
If you’re developing any sort of external application that needs access to queue statis‐
tics, having the data stored in this manner will prove far superior to using
the /var/log/asterisk/queue_log file.
Conclusion
In this chapter, you learned about several areas where Asterisk can integrate with a
relational database. This is useful for systems where you need to start scaling by clus‐
tering multiple Asterisk boxes working with the same centralized information, or
when you want to start building external applications to modify information without
requiring a reload of the system (i.e., not requiring the modification of flat files).
288
|
Chapter 15: Relational Database Integration