Convert Monitor Recordings to mp3
We run a small office with our Asterisk PBX but we record all phone traffic, in and out. Needless to say, this can exact a large toll on our disk resources. I’m submitting this script and related Cron entry for those who need to compress their monitor recordings to mp3 format and need a program that will only run when the PBX is idle. Assumptions: Continue Reading...
Installing Queuemetrics on PBX-in-a-Flash
PBX-in-a-Flash is Nerd Vittles ultra-cool version of a preconfigured Asterisk PBX based on CentOS 5. This makes installing QueueMetrics very easy, though the fact that the standard access port is already used by a different, preinstalled package makes a bit of hand-tweaking necessary. Basic installation
wget https://yum.loway.ch/loway.repo -O /etc/yum.repos.d/loway.repo
yum install queuemetrics
cd /usr/local/queuemetrics/webapps/queuemetrics-1.4.3/WEB-INF/
./installDb.sh
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />
Rebuilding Fonality queue_log
On a number of Fonality boxes, you’ll find that the queue_log file, which content is critical to the correct running of QueueMetrics, is deleted almost immediately and moved to varius files under the /var/log/asterisk/real filesystem. In order to make this work with QueueMetrics, we prepared a small script that will rebuild the queue_log out of the snippets in real. In order not to overload the system, we take only s pecified period pof time (eg 30 days) into consideration for the rebuilding. Here is the script called rebuildqlog.sh
# uso: ./rebuildqlog.sh /var/log/qm_qlog
# --------------------------------------------------
LOGF=$1
LOGT=$LOGF.temp
LOGS=$LOGT.sorted
MAXDAYS=30
rm -f $LOGT $LOGS
nice find /var/log/asterisk/real -name queue_log.\* -mtime -$MAXDAYS | xargs cat >> $LOGT
cat /var/log/asterisk/queue_log >> $LOGT
nice sort --buffer-size=10M $LOGT | uniq > $LOGS
rm -f $LOGT $LOGF
mv $LOGS $LOGF
#! /bin/bash
while [ true ]
do
nice /root/rebuildqlog.sh /var/log/qm_qlog
sleep 15
done
nohup /root/run_rebuild.sh &
# This is the default queue log file.
default.queue_log_file=/var/log/qm_qlog
Optimizing QueueMetrics data access
If you run a very large call center and your queue_log table starts to get big (>1M lines), you can apply the following techniques to improve database performance. 1. Create a complete index The default index used for access, called “partizione_b”, is not very efficient for huge datasets because its granularity is aimed only at partition and time period. To make an idex such that all queries can be “solved” completely through the index, you should drop other indices and create this one:
ALTER TABLE `queue_log` ADD INDEX (
partition(9), time_id, unique_row_count, queue(15)
)
SELECT DISTINCT partition, length( partition ) AS L FROM queue_log
SELECT DISTINCT queue, length( queue ) AS L FROM queue_log
Query_time: 6 Lock_time: 0 Rows_sent: 12999 Rows_examined: 988483
mysqldumpslow name-of-slow-query-log
ALTER TABLE queue_log
ORDER BY partition, time_id, unique_row_count
Installing QueueMetrics on Fonality PBXtra
The Fonality PBXtra boxes are based on CentOS 4.2, so the yum install is feasible with some modifications. The most important thing that is missing is that those boxes use Fonality’s RPM repository, where the mysql-server packages are missing. Luckily, it is possible to download and install the correct RPM package from the CentOS vault:
wget http://vault.centos.org/4.2/os/i386/CentOS/RPMS/mysql-server-4.1.12-3.RHEL4.1.i386.rpm
rpm -i mysql-server-4.1.12-3.RHEL4.1.i386.rpm
/etc/init.d/mysqld restart
wget https://yum.loway.ch/loway.repo -O /etc/yum.repos.d/loway.repo
yum install queuemetrics
/etc/init.d/mysqld restart
cd /usr/local/queuemetrics/webapps/queuemetrics-1.4.3/WEB-INF/README
mysql mysql
create database queuemetrics;
grant all privileges on queuemetrics.* to 'queuemetrics'@'%' identified by 'javadude';
grant all privileges on queuemetrics.* to 'queuemetrics'@'localhost' identified by 'javadude';
grant all privileges on queuemetrics.* to 'queuemetrics'@'pbxtra9999' identified by 'javadude';
mysql -u queuemetrics -p queuemetrics < queuemetrics_sample.sql
Managing agents that dynamically log-on
AddQueueMember is a command that lets you add dynamic agents to a queue. Its main advantage is that you can add channels, i.e. terminals, so you’ll have most of the advantages of agents without the performance and stability problems that the agents module may cost in very large systems. Its disadvantage is that in Asterisk 1.2 it does not log the agent login/logoff to the queue_log, and so programs that analyze the queue log data like QueueMetrics will not see agents logging on and off. This is a major organizational problem in a real-world call center, where tracking agent logons and logoffs is vital to the smooth running of the operations. In Asterisk 1.4 instead this bug has been fixed, so you can use this code: Code for Asterisk 1.4 and QueueMetrics 1.4 or newer To do the adding, you dial 422XX, where XX is your local extension; the same goes to be removed from queue.
; addqueuemember - 422 - for Asterisk 1.4
exten => _422XX,1,Answer
exten => _422XX,2,AddQueueMember(my-queue,SIP/${EXTEN:3})
exten => _422XX,3,Hangup
; removequeuemember - 423 - for Asterisk 1.4
exten => _423XX,1,Answer
exten => _423XX,2,RemoveQueueMember(my-queue,SIP/${EXTEN:3})
exten => _423XX,3,Hangup
; addqueuemember - 422
exten => _422XX,1,Answer
exten => _422XX,2,AddQueueMember(my-queue,SIP/${EXTEN:3})
exten => _422XX,3,System( echo
"${EPOCH}|${UNIQUEID}|my-queue|SIP/${EXTEN:3}|ADDMEMBER|-" >> /var/log/asterisk/queue_log )
exten => _422XX,4,DBput(dynlogin/log_Agent-${EXTEN:3}=${EPOCH})
exten => _422XX,5,Hangup
; removequeuemember - 423
exten => _423XX,1,Answer
exten => _423XX,2,RemoveQueueMember(my-queue,SIP/${EXTEN:3})
exten => _423XX,3,DBget(ORGEPOCH=dynlogin/log_Agent-${EXTEN:3})
exten => _423XX,4,Set(RV=$[${EPOCH} - ${ORGEPOCH}])
exten => _423XX,5,GotoIf($["${RV}" = "0"]?8:6)
exten => _423XX,6,System( echo "${EPOCH}|${UNIQUEID}|my-queue|SIP/${EXTEN:3}|REMOVEMEMBER|-|${RV}" >> /var/log/asterisk/queue_log )
exten => _423XX,7,DBdel(dynlogin/log_Agent-${EXTEN:3})
exten => _423XX,8,Hangup
Resetting devices from the command line
It is sometimes handy to be able to reset network and telephony apparatus right from the command line, in order to script them in case that is needed. We use: Continue Reading...
Manually updating QueueMetrics
This recipe assumes that you have a working QueueMetrics installation and you just need to update it to a newer version. It should work with any servlet container. Continue Reading...