From 86d1c93be3bb692998581a337d62bca7ad439b07 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 31 Jul 2006 15:42:08 +0000 Subject: [PATCH] modify timeonVDAD_SIPmonitor script to allow for barge, display fullname of agent and longer pause time git-svn-id: svn://192.168.202.10@94 3d104415-ff17-0410-8863-d5cf3c621b8a --- www/vicidial/AST_timeonVDADall_SIPmonitor.php | 186 ++++++------------ 1 file changed, 57 insertions(+), 129 deletions(-) diff --git a/www/vicidial/AST_timeonVDADall_SIPmonitor.php b/www/vicidial/AST_timeonVDADall_SIPmonitor.php index 5c0f9b56..355a6fcd 100644 --- a/www/vicidial/AST_timeonVDADall_SIPmonitor.php +++ b/www/vicidial/AST_timeonVDADall_SIPmonitor.php @@ -2,6 +2,7 @@ ### AST_timeonVDADall.php ### ### Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +### Contributions by Magma Networks LLC ### # live real-time stats for the VICIDIAL Auto-Dialer all servers # @@ -11,8 +12,11 @@ # 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala # 60619-1708 - Added variable filtering to eliminate SQL injection attack threat # - Added required user/pass to gain access to this page -# 60626-1455 - Added display of system load to bottom (Angelito Manansala) -# +# - Added 10 minutes on call (Magma Networks LLC) +# - Added extended pause (exceeding 60 seconds -> 20 minutes) (Magma Networks LLC) +# - Added Full Name Field to extract from Database (Magma Networks LLC) +# - Added Barge Link (Magma Networks LLC) +# 60731-1138 - fixed fullname formatting header ("Content-type: text/html; charset=utf-8"); @@ -21,62 +25,13 @@ require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; -if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} - elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} -if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} - elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} -if (isset($_GET["RR"])) {$RR=$_GET["RR"];} - elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} -if (isset($_GET["group"])) {$group=$_GET["group"];} - elseif (isset($_POST["group"])) {$group=$_POST["group"];} -if (isset($_GET["DB"])) {$DB=$_GET["DB"];} - elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} -if (isset($_GET["submit"])) {$submit=$_GET["submit"];} - elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} -if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} - elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} - -if (!isset($group)) {$group='';} - -function get_server_load($windows = false) { -$os = strtolower(PHP_OS); -if(strpos($os, "win") === false) { -if(file_exists("/proc/loadavg")) { -$load = file_get_contents("/proc/loadavg"); -$load = explode(' ', $load); -return $load[0]; -} -elseif(function_exists("shell_exec")) { -$load = explode(' ', `uptime`); -return $load[count($load)-1]; -} -else { -return false; -} -} -elseif($windows) { -if(class_exists("COM")) { -$wmi = new COM("WinMgmts:\\\\."); -$cpus = $wmi->InstancesOf("Win32_Processor"); - -$cpuload = 0; -$i = 0; -while ($cpu = $cpus->Next()) { -$cpuload += $cpu->LoadPercentage; -$i++; -} - -$cpuload = round($cpuload / $i, 2); -return "$cpuload%"; -} -else { -return false; -} -} -} - -$load_ave = get_server_load(true); - +$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];} +$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];} +$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];} +$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];} +$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];} +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -96,15 +51,12 @@ $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); } $NOW_TIME = date("Y-m-d H:i:s"); -$NOW_DAY = date("Y-m-d"); -$NOW_HOUR = date("H:i:s"); $STARTtime = date("U"); $epochSIXhoursAGO = ($STARTtime - 21600); $timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); -$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$stmt="select campaign_id from vicidial_campaigns;"; $rslt=mysql_query($stmt, $link); -if (!isset($DB)) {$DB=0;} if ($DB) {echo "$stmt\n";} $groups_to_print = mysql_num_rows($rslt); $i=0; @@ -115,14 +67,13 @@ while ($i < $groups_to_print) $i++; } -if (!isset($RR)) {$RR=40;} +if (!$RR) {$RR=40;} $NFB = ''; $NFE = ''; $F=''; $FG=''; $B=''; $BG=''; $reset_counter++; -if (!isset($reset_counter)) {$reset_counter=0;} if ($reset_counter > 7) { $reset_counter=0; @@ -174,65 +125,24 @@ echo "STOP | MODIFY | REPORTS \n"; echo "\n\n"; - if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} else { -$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$HOPlev = $row[8]; - -echo "
"; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; - -$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; -$rslt=mysql_query($stmt, $link); -$row=mysql_fetch_row($rslt); -$VDhop = $row[0]; - -$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; -$rslt=mysql_query($stmt, $link); -$row=mysql_fetch_row($rslt); -$DAleads = $row[0]; -$callsTODAY = $row[1]; -$dropsTODAY = $row[2]; -$drpctTODAY = $row[3]; - -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; - +echo "
"; +echo "DIAL LEVEL: $row[0]         "; +echo "STATUSES: $row[1], $row[2], $row[3], $row[4], $row[5]         "; +echo "ORDER: $row[6]"; echo "\n\n"; } ################################################################################### ###### OUTBOUND CALLS ################################################################################### if (eregi("CLOSER",$group)) - { - $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); - $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); - $closer_campaigns = "'$closer_campaigns'"; - - $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; - } + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";} else {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} $rslt=mysql_query($stmt, $link); @@ -290,13 +200,32 @@ $agent_paused=0; $agent_total=0; $Aecho = ''; -$Aecho .= "VICIDIAL: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; -$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; -$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; -$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "VF DIALER: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------------+----------------+-------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | FULL NAME | SESSIONID | BARGE | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------------+----------------+-------+--------+-----------------+-----------------+---------+------------+\n"; -$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$stmt=" + select + extension, + vicidial_live_agents.user, + conf_exten, + status, + server_ip, + UNIX_TIMESTAMP(last_call_time), + UNIX_TIMESTAMP(last_call_finish), + call_server_ip, + campaign_id, + vicidial_users.full_name as full_name + from vicidial_live_agents + left join vicidial_users on vicidial_live_agents.user = vicidial_users.user + where + campaign_id='" . mysql_real_escape_string($group) . "' + order by + status, + last_call_time; +"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $talking_to_print = mysql_num_rows($rslt); @@ -318,6 +247,8 @@ $talking_to_print = mysql_num_rows($rslt); $server_ip = sprintf("%-15s", $row[4]); $call_server_ip = sprintf("%-15s", $row[7]); $campaign_id = sprintf("%-10s", $row[8]); + $full_name = sprintf("%-15s", $row[9]); + while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);} $call_time_S = ($STARTtime - $row[5]); $call_time_M = ($call_time_S / 60); @@ -331,10 +262,10 @@ $talking_to_print = mysql_num_rows($rslt); $call_time_MS = sprintf("%7s", $call_time_MS); $G = ''; $EG = ''; if ($call_time_M_int >= 5) {$G=''; $EG='';} -# if ($call_time_M_int >= 10) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} if (eregi("PAUSED",$row[3])) { - if ($call_time_M_int >= 5) + if ($call_time_M_int >= 20) {$i++; continue;} else {$G=''; $EG=''; $agent_paused++; $agent_total++;} @@ -345,26 +276,24 @@ $talking_to_print = mysql_num_rows($rslt); if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + $sessionid = trim($sessionid); $agentcount++; - #$Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; - $sessionid=trim($sessionid); - $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$full_name$EG | $G$sessionid$EG LISTEN | BARGE | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; $i++; } - $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= "+------------|--------+-----------------+----------------+--------+--------+-----------------+-----------------+---------+------------+\n"; $Aecho .= " $agentcount agents logged in on all servers\n"; - $Aecho .= " System Load Average: $load_ave\n\n"; + $Aecho .= " NOTE: Click LISTEN to monitor agent call, you must have installed softphone on you machine.\n\n"; + $Aecho .= " - Paused agents\n"; # $Aecho .= " - Balanced call\n"; $Aecho .= " - Agent waiting for call\n"; - $Aecho .= " - Over 5 minutes on call\n\n"; - $Aecho .= " NOTE: Click LISTEN to monitor agent call, you must have softphone installed on you machine.\n\n"; - - + $Aecho .= " - Over 5 minutes on call\n"; + $Aecho .= " - Over 10 minutes on call\n"; if ($agent_ready > 0) {$B=''; $BG='';} if ($agent_ready > 4) {$B=''; $BG='';} if ($agent_ready > 9) {$B=''; $BG='';} @@ -374,6 +303,7 @@ $talking_to_print = mysql_num_rows($rslt); echo "\n
\n"; echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; echo "$NFB$agent_paused$NFE paused agents       \n"; @@ -391,5 +321,3 @@ $talking_to_print = mysql_num_rows($rslt); - -