VICIDIAL and QueueMetrics

queue_log logging was added to VICIDIAL outbound calling as an option in the 2.0.3 release tree.

This document goes over the features and needed changes made to VICIDIAL to enable it to insert activity records into the queue_log and other tables in MySQL that QueueMetrics uses for it's statistical analysis and reports. This document should not be taken as a HOWTO for proper installation steps to get QueueMetrics working.

QueueMetrics is a closed-source, commercial product written by Loway Research in Italy. The writers of VICIDIAL do not support or warranty QueueMetrics or it's functionality with VICIDIAL in any way.

This feature was added to the package at the request of several users of VICIDIAL and was achieved with some help from the makers of QueueMetrics(although all VICIDIAL code changes were done entirely by Matt Florell).

This feature is currently only functional on outbound dialing.



Here is a short summary of the needed steps to install QueueMetrics on your system:

First, get Sun Java SDK/JRE and install on your system.
NOTE: the GCJ java JRE available on most RedHat/Feroda/CentOS systems WILL NOT WORK

download and install the Java jdk-1_5_0_11-linux-i586-rpm.bin from:
http://www.sun.com/software/communitysource/j2se/java2/index.xml


cd /usr/local
chmod 0777 jdk-1_5_0_11-linux-i586-rpm.bin
./jdk-1_5_0_11-linux-i586-rpm.bin
ls -l
rpm -i jdk-1_5_0_11-linux-i586.rpm
wget http://www.mirrorgeek.com/apache.org/tomcat/tomcat-5/v5.5.20/bin/apache-tomcat-5.5.20.tar.gz
gunzip apache-tomcat-5.5.20.tar.gz
tar xvf apache-tomcat-5.5.20.tar
ln -s apache-tomcat-5.5.20 tomcat
cd apache-tomcat-5.5.20

JAVA_HOME=/usr/java/jdk1.5.0_11/
JAVA_OPTS="-Xms256M -Xmx512M"
JRE_HOME=/usr/java/jdk1.5.0_11/jre

or

JRE_HOME=/usr/java/jre1.6.0/
JAVA_HOME=/usr/java/
JAVA_OPTS="-Xms256M -Xmx512M"

export JAVA_HOME
export JAVA_OPTS
export JRE_HOME
/usr/local/tomcat/bin/startup.sh

At this point you should go here on your web browser to see if the tomcat installation went well:
http://ip-address:8080/

If it did, then you want to add the following lines to your /etc/rc.d/rc.local file so that tomcat will start up on boot:
	JAVA_HOME=/usr/java/jdk1.5.0_11/
	JAVA_OPTS="-Xms256M -Xmx512M"
	JRE_HOME=/usr/java/jdk1.5.0_11/jre
	export JAVA_HOME
	export JAVA_OPTS
	export JRE_HOME
	/usr/local/tomcat/bin/startup.sh



cd /usr/local
*** download QueueMetrics and place it in /usr/local ***
gunzip QueueMetrics-1.1.tar.gz
tar xvf QueueMetrics-1.1.tar
mv queuemetrics-1.1 /usr/local/tomcat/webapps/qm
cd /usr/local/tomcat/webapps/qm/WEB_INF
wget http://mysql.mirrors.pair.com/Downloads/Connector-J/mysql-connector-java-3.0.10-stable.tar.gz
gunzip mysql-connector-java-3.0.10-stable.tar.gz
tar xvf mysql-connector-java-3.0.10-stable.tar
cp mysql-connector-java-3.0.10-stable/mysql-connector-java-3.0.10-stable-bin.jar ./lib/

At this point you should go here on your web browser to see if the tomcat installation went well:
http://ip-address:8080/qm

If you see a QueueMetrics page(probably with many errors), then installation went well up to this point.

You now need to add the database tables, configure the web.xml file and configuration.properties file for your system.





Now to the database side of things. 
First, give permissions to your user:

GRANT ALL PRIVILEGES ON queuemetrics.* TO qm@'localhost' IDENTIFIED BY 'qm'; 
GRANT ALL PRIVILEGES ON queuemetrics.* TO qm@'%' IDENTIFIED BY 'qm'; 

Second, the queue_log table:

mysql> describe queue_log;
+-----------+------------------+------+-----+---------+-------+
| Field     | Type             | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+-------+
| partition | char(20)         | NO   | MUL |         |       |
| time_id   | int(11) unsigned | NO   | MUL | 0       |       |
| call_id   | char(30)         | NO   | MUL |         |       |
| queue     | char(30)         | NO   |     |         |       |
| agent     | char(30)         | NO   |     |         |       |
| verb      | char(30)         | NO   |     |         |       |
| data1     | char(30)         | NO   |     |         |       |
| data2     | char(30)         | NO   |     |         |       |
| data3     | char(30)         | NO   |     |         |       |
| data4     | char(30)         | NO   |     |         |       |
| serverid  | varchar(10)      | NO   |     | 0       |       |
+-----------+------------------+------+-----+---------+-------+

partition: set to "P01" for the first partition, should match up with configuration.properties presets

time_id: epoch, unixtime (seconds since 1970-01-01 00:00:00) [1170345603]

call_id: Asterisk unique prepended with server_id field [1-1170345497.30369]
	For VICIDIAL we will use the CallerIDname of the call to 

queue: the queue that call came into (we will use the campaign_id here)

agent: we will use the user ID prepended by "agent/" [agent/6666]

verbs:

system actions - used by the AST_VDadapt.pl script when starting up
	QUEUESTART

agent actions - used by vicidial.php, vdc_db_query.php and AST_VDremote_agents.pl
	AGENTLOGIN(channel) 
	AGENTLOGOFF(channel|logintime) 
	PAUSEALL
	PAUSE
	UNPAUSEALL
	UNPAUSE
	PAUSEREASON

call actions before going to agent - used by agi-VDADtransfer scripts
	ENTERQUEUE(url|callerid)
	CONNECT(holdtime)
	EXITWITHTIMEOUT(position) 

call actions before going to agent - used by AST_VDauto_dial.pl
	ABANDON(position|origposition|waittime) 

call actions after going to agent - used by vicidial.php, vdc_db_query.php and FastAGI_log.pl
	COMPLETEAGENT(holdtime|calltime|origposition)
	COMPLETECALLER(holdtime|calltime|origposition) 
	CALLSTATUS(status)


not used in vicidial - 
	TRANSFER(extension,context) 




data1: call termination codes, TBD

data2: callerID or number called(sometimes prepended by DNIS) [3101-9015556189]
	NOTE: the queuemetrics_eq_prepend field allows you to specify what
	vicidial_list field you would like to prefend to the phone number on
	ENTERQUEUE events

data3: ??

data4: ??

serverid: number of the server the call came from [for VICIDIAL use the system_settings.queuemetrics_log_id field]




On the vicidial side of things, we will add the following columns to the system_settings table:
enable_queuemetrics_logging ENUM('0','1') default '0',
queuemetrics_server_ip VARCHAR(15),
queuemetrics_dbname VARCHAR(50),
queuemetrics_login VARCHAR(50),
queuemetrics_pass VARCHAR(50),
queuemetrics_url VARCHAR(255),
queuemetrics_log_id VARCHAR(10) default 'VIC'
queuemetrics_eq_prepend VARCHAR(255) default 'NONE'
