beta code for rt blind monitoring logging

git-svn-id: svn://192.168.202.10@2749 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2017-05-09 16:48:10 +00:00
parent 3f7a63abdc
commit 3a686c5e72
7 changed files with 191 additions and 17 deletions
+81 -1
View File
@@ -47,6 +47,7 @@
# 161212-1659 - Added --cpd-log-purge-days=XX option
# 170209-1213 - Added vicidial_api_urls table rolling and purging to all vicidial_api_log sections
# 170325-1108 - Added vicidial_drop_log table rolling
# 170508-1212 - Added vicidial_rt_monitor_log table rolling
#
$CALC_TEST=0;
@@ -78,7 +79,7 @@ if (length($ARGV[0])>1)
print " that are older than XX months from least important log archive tables:\n";
print " call_log_archive, vicidial_log_extended_archive, vicidial_dial_log_archive, vicidial_drop_log\n";
print " [--only-trim-archive-level-two] = same as --only-trim-archive-level-one, except includes tables:\n";
print " vicidial_carrier_log_archive, vicidial_api_log_archive\n";
print " vicidial_carrier_log_archive, vicidial_api_log_archive, vicidial_rt_monitor_log_archive\n";
print " [--only-trim-archive-level-three] = same as --only-trim-archive-level-two, except includes tables:\n";
print " vicidial_log_archive, vicidial_agent_log_archive, vicidial_closer_log_archive\n";
print " [--recording-log-days=XX] = OPTIONAL, number of days to archive recording_log table only past\n";
@@ -554,6 +555,35 @@ if (!$T)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_api_log_archive trim processing #####
##### BEGIN vicidial_rt_monitor_log_archive trim processing #####
$stmtA = "SELECT count(*) from vicidial_rt_monitor_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_rt_monitor_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "Trimming vicidial_rt_monitor_log_archive table... ($vicidial_rt_monitor_log_archive_count)\n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_rt_monitor_log_archive WHERE monitor_start_time < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_rt_monitor_log_archive table \n";}
$stmtA = "optimize table vicidial_rt_monitor_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_rt_monitor_log_archive trim processing #####
}
if ($only_trim_archive > 2)
@@ -1555,6 +1585,56 @@ if (!$T)
}
##### vicidial_rt_monitor_log
$stmtA = "SELECT count(*) from vicidial_rt_monitor_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_rt_monitor_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_rt_monitor_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_rt_monitor_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_rt_monitor_log table... ($vicidial_rt_monitor_log_count|$vicidial_rt_monitor_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_rt_monitor_log_archive SELECT * from vicidial_rt_monitor_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_rt_monitor_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_rt_monitor_log WHERE monitor_start_time < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_rt_monitor_log table \n";}
$stmtA = "optimize table vicidial_rt_monitor_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_rt_monitor_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### vicidial_log_noanswer
$stmtA = "SELECT count(*) from vicidial_log_noanswer;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+24
View File
@@ -77,6 +77,7 @@
# 161226-1211 - Fix for previous rolled-back code
# 170325-1105 - Added optional vicidial_drop_log logging
# 170427-1125 - Fix for drop call logging of answered calls hung up by customer first
# 170508-1148 - Added blind monitor call end logging
#
# defaults for PreFork
@@ -671,6 +672,29 @@ sub process_request
}
}
### BEGIN log end of real-time blind monitor calls ###
if ( ( ($callerid =~ /^BM\d\d\d\d\d\d\d\d/) && ($channel =~ /ASTblind/) ) || ($callerid =~ /^BB\d\d\d\d\d\d\d\d/) || ($callerid =~ /^BW\d\d\d\d\d\d\d\d/) )
{
$stmtA = "SELECT monitor_start_time,UNIX_TIMESTAMP(monitor_start_time) from vicidial_rt_monitor_log where caller_code='$callerid' and monitor_end_time is NULL;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$sthA->finish();
$monitor_start_time = $aryA[0];
$EPOCHmonitor_start_time = $aryA[1];
$monitor_sec = ($now_date_epoch - $EPOCHmonitor_start_time);
$stmtA = "UPDATE vicidial_rt_monitor_log set monitor_sec='$monitor_sec',monitor_end_time='$now_date' where caller_code='$callerid';";
$affected_rowsBM = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "|$affected_rowsBM|$stmtA|$monitor_start_time|$EPOCHmonitor_start_time|"; &agi_output;}
}
}
### END log end of real-time blind monitor calls ###
### get uniqueid and start_epoch from the call_log table
$CALLunique_id = $unique_id;
$stmtA = "SELECT uniqueid,start_epoch,channel,end_epoch,channel_group FROM call_log where uniqueid='$unique_id';";
+4 -1
View File
@@ -1,4 +1,4 @@
CALLER ID NAME CODES DOC Started: 2013-07-15 Updated: 2017-03-29
CALLER ID NAME CODES DOC Started: 2013-07-15 Updated: 2017-05-08
This document is meant for reference only, and it does not contain all CID name codes possible, but more will be added over time.
@@ -23,3 +23,6 @@ AGMON - Remote Agent Monitor (AGMON715224918000001)
HLvdcW - Hangup of customer call from agent screen (HLvdcW1475524272tluc)
CH123456 - Hangup of all non-agent channels in meetme session(CH1234614755246080)
ULGC - Hangup of lone channel in left 3way session (ULGC3620170222100923)
BM - Real-time screen blind monitor (BM149425456200006666)
BB - Real-time screen blind barge (BB149425456200006666)
BW - Real-time screen blind whisper (BW149425456200006666)
+3 -3
View File
@@ -1,4 +1,4 @@
Sending email after agent dispositions a call 2017-03-30
Sending email after agent dispositions a call 2017-04-12
These instructions will show you how to set up automatic emails to be sent out when an agent dispositions a call with a specific defined "sale status".
@@ -27,7 +27,7 @@ HERE IS AN EXAMPLE SETTINGS CONTAINER TO SEND OUT AN EMAIL:
(The four keys you can use are: "email_to", "email_from", "email_subject" and "email_body_begin" will start your message while "email_body_end" will mark the finish of the message. You can use most standard SCRIPT variables in the subject and body fields, and you can use either fixed email addresses or "agent_email" and "customer_email" as variables for the email addresses as shown below. A semi-colon ";" at the beginning of a line will comment out that line and it will not be parsed. If you want to include custom fields values in the email, then you need to put "--A--CF_uses_custom_fields--B--" into the email body somewhere, it will be removed before the email is sent. Then you can put custom fields values in just like you do in a script.)
; destination email
; destination email (if you want to use more than one email address, you should separate them by a space ' ')
;email_to => vicidialemailtesting@gmail.com
email_to => --A--customer_email--B--
@@ -113,4 +113,4 @@ ACME Support Department
312-555-1212
email_body_end
email_body_end
@@ -3719,6 +3719,28 @@ uniqueid VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT '',
index(call_date)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE vicidial_rt_monitor_log (
manager_user VARCHAR(20) NOT NULL,
manager_server_ip VARCHAR(15) NOT NULL,
manager_phone VARCHAR(20) NOT NULL,
manager_ip VARCHAR(15),
agent_user VARCHAR(20),
agent_server_ip VARCHAR(15),
agent_status VARCHAR(10),
agent_session VARCHAR(10),
lead_id INT(9) UNSIGNED,
campaign_id VARCHAR(8),
caller_code VARCHAR(20),
monitor_start_time DATETIME,
monitor_end_time DATETIME,
monitor_sec INT(9) UNSIGNED default '0',
monitor_type ENUM('LISTEN','BARGE','HIJACK','WHISPER') default 'LISTEN',
index (manager_user),
index (agent_user),
unique index (caller_code),
index (monitor_start_time)
) ENGINE=MyISAM;
ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -3907,6 +3929,8 @@ CREATE TABLE vicidial_drop_log_archive LIKE vicidial_drop_log;
DROP INDEX drop_date on vicidial_drop_log_archive;
CREATE UNIQUE INDEX vicidial_drop_log_archive_key on vicidial_drop_log_archive(drop_date, uniqueid);
CREATE TABLE vicidial_rt_monitor_log_archive LIKE vicidial_rt_monitor_log;
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
@@ -3981,4 +4005,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1504',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1505',db_schema_update_date=NOW(),reload_timestamp=NOW();
+26
View File
@@ -236,3 +236,29 @@ ALTER TABLE vicidial_campaigns ADD three_way_record_stop ENUM('Y','N') default '
ALTER TABLE vicidial_campaigns ADD hangup_xfer_record_start ENUM('Y','N') default 'N';
UPDATE system_settings SET db_schema_version='1504',db_schema_update_date=NOW() where db_schema_version < 1504;
CREATE TABLE vicidial_rt_monitor_log (
manager_user VARCHAR(20) NOT NULL,
manager_server_ip VARCHAR(15) NOT NULL,
manager_phone VARCHAR(20) NOT NULL,
manager_ip VARCHAR(15),
agent_user VARCHAR(20),
agent_server_ip VARCHAR(15),
agent_status VARCHAR(10),
agent_session VARCHAR(10),
lead_id INT(9) UNSIGNED,
campaign_id VARCHAR(8),
caller_code VARCHAR(20),
monitor_start_time DATETIME,
monitor_end_time DATETIME,
monitor_sec INT(9) UNSIGNED default '0',
monitor_type ENUM('LISTEN','BARGE','HIJACK','WHISPER') default 'LISTEN',
index (manager_user),
index (agent_user),
unique index (caller_code),
index (monitor_start_time)
) ENGINE=MyISAM;
CREATE TABLE vicidial_rt_monitor_log_archive LIKE vicidial_rt_monitor_log;
UPDATE system_settings SET db_schema_version='1505',db_schema_update_date=NOW() where db_schema_version < 1505;
+28 -11
View File
@@ -117,10 +117,11 @@
# 170301-1649 - Added validation that sounds web dir exists to sounds_list function
# 170409-1603 - Added IP List validation code
# 170423-0800 - Added force_entry_list_id option for update_lead
# 170508-1048 - Added blind_monitor logging
#
$version = '2.14-93';
$build = '170423-0800';
$version = '2.14-94';
$build = '170508-1048';
$api_url_log = 0;
$startMS = microtime();
@@ -1722,26 +1723,39 @@ if ($function == 'blind_monitor')
if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";}
$monitor_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S";
$PADuser = sprintf("%08s", $user);
while (strlen($PADuser) > 8) {$PADuser = substr("$PADuser", 0, -1);}
$BMquery = "BM$StarTtime$PADuser";
$monitor_type='LISTEN'; $cid_prefix='BM';
if ( (preg_match('/MONITOR/',$stage)) or (strlen($stage)<1) ) {$stage = '0';}
if (preg_match('/BARGE/',$stage)) {$stage = '';}
if (preg_match('/HIJACK/',$stage)) {$stage = '';}
if (preg_match('/BARGE/',$stage)) {$stage = ''; $monitor_type='BARGE'; $cid_prefix='BB';}
if (preg_match('/HIJACK/',$stage)) {$stage = ''; $monitor_type='HIJACK'; $cid_prefix='BB';}
if (preg_match('/WHISPER/',$stage))
{
if ($agent_whisper_enabled == '1')
{$stage = '47378218';}
{$stage = '47378218'; $monitor_type='WHISPER'; $cid_prefix='BW';}
else
{
# WHISPER not enabled
$stage = '0';
}
}
$PADuser = sprintf("%08s", $user);
while (strlen($PADuser) > 8) {$PADuser = substr("$PADuser", 0, -1);}
$BMquery = "$cid_prefix$StarTtime$PADuser";
$stmt = "SELECT user,lead_id,campaign_id,status FROM vicidial_live_agents where conf_exten='$session_id' and server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$AGENTuser = $row[0];
$AGENTlead_id = $row[1];
$AGENTcampaign = $row[2];
$AGENTstatus = $row[3];
}
### insert a new lead in the system with this phone number
$stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$monitor_server_ip','','Originate','$BMquery','Channel: Local/$monitor_dialstring$stage$session_id@default','Context: default','Exten: $dialplan_number','Priority: 1','Callerid: \"VC Blind Monitor\" <$outbound_cid>','','','','','');";
$stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$monitor_server_ip','','Originate','$BMquery','Channel: Local/$monitor_dialstring$stage$session_id@default','Context: default','Exten: $dialplan_number','Priority: 1','Callerid: \"$BMquery\" <$outbound_cid>','','','','','');";
if ($DB>0) {echo "DEBUG: blind_monitor query - $stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
@@ -1749,7 +1763,10 @@ if ($function == 'blind_monitor')
{
$man_id = mysqli_insert_id($link);
$stmt = "INSERT INTO vicidial_dial_log SET caller_code='$BMquery',lead_id='0',server_ip='$monitor_server_ip',call_date='$NOW_TIME',extension='$dialplan_number',channel='Local/$monitor_dialstring$stage$session_id@default',timeout='0',outbound_cid='\"VC Blind Monitor\" <$outbound_cid>',context='default';";
$stmt = "INSERT INTO vicidial_dial_log SET caller_code='$BMquery',lead_id='0',server_ip='$monitor_server_ip',call_date='$NOW_TIME',extension='$dialplan_number',channel='Local/$monitor_dialstring$stage$session_id@default',timeout='0',outbound_cid='\"$BMquery\" <$outbound_cid>',context='default';";
$rslt=mysql_to_mysqli($stmt, $link);
$stmt = "INSERT INTO vicidial_rt_monitor_log SET manager_user='$user',manager_server_ip='$monitor_server_ip',manager_phone='$phone_login',manager_ip='$ip',agent_user='$AGENTuser',agent_server_ip='$server_ip',agent_status='$AGENTstatus',agent_session='$session_id',lead_id='$AGENTlead_id',campaign_id='$AGENTcampaign',caller_code='$BMquery',monitor_start_time=NOW(),monitor_type='$monitor_type';";
$rslt=mysql_to_mysqli($stmt, $link);
##### BEGIN log visit to the vicidial_report_log table #####