From c12ef1a6f0cd2d0b2e883b2403572a54aa670b13 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 4 Sep 2026 19:22:59 +0000 Subject: [PATCH] Changed default logger.conf to do millisecond logging Several updates to Remote Agent back-end script Added -ra-delay=X flag to keepalive script git-svn-id: svn://192.168.202.10@4022 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl | 22 ++- agc_2-X/trunk/bin/AST_VDremote_agents.pl | 136 ++++++++++++++---- .../docs/conf_examples/logger.conf.sample | 3 + 3 files changed, 132 insertions(+), 29 deletions(-) diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl index 8d31fabf..b56996b1 100644 --- a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl @@ -187,9 +187,10 @@ # 260605-1002 - Added end-of-day log processing log entry for the vicidial_internal_log # 260826-1814 - Added FastAGIServer code # 260902-1718 - Fix for PJSIP monitoring +# 260903-1914 - Added -ra-delay=X flag # -$build = '260902-1718'; +$build = '260903-1914'; $DB=0; # Debug flag $teodDB=0; # flag to log Timeclock End of Day processes to log file @@ -202,6 +203,7 @@ $cu3way_delay=''; $autodial_delay=''; $adfill_delay=''; $fill_staggered=''; +$ra_delay=''; $recmon=0; $reserved_exten_skip=0; $reserved_exten_message=''; @@ -312,6 +314,7 @@ if (length($ARGV[0])>1) print " [-autodial-delay=X] = setting delay seconds on local auto-dial process\n"; print " [-adfill-delay=X] = setting delay seconds on auto-dial FILL process\n"; print " [-fill-staggered] = enable experimental staggered auto-dial FILL process\n"; + print " [-ra-delay=X] = setting delay seconds on Remote Agent process\n"; print " [-cu3way] = keepalive for the optional 3way conference checker\n"; print " [-lstn-buffer] = use special enhanced telnet buffer listen process(depricated)\n"; print " [-cu3way-delay=X] = setting delay seconds on 3way conference checker\n"; @@ -432,6 +435,21 @@ if (length($ARGV[0])>1) } @CLIvarARY=@MT; @CLIvarARY=@MT; } + if ($args =~ /-ra-delay=/i) # CLI defined delay for Remote Agent script + { + @CLIvarRADLY = split(/-ra-delay=/,$args); + @CLIvarRADLX = split(/ /,$CLIvarRADLY[1]); + if (length($CLIvarRADLX[0])>0) + { + $CLIradelay = $CLIvarRADLX[0]; + $CLIradelay =~ s/\/$| |\r|\n|\t//gi; + $CLIradelay =~ s/\D//gi; + if ( ($CLIradelay > 0) && (length($CLIradelay)> 0) ) + {$ra_delay = "--delay=$CLIradelay";} + if ($DB > 0) {print "Remote Agent Delay set to $CLIradelay $ra_delay \n";} + } + @CLIvarRADLY=@MT; @CLIvarRADLY=@MT; + } if ($args =~ /-test/i) { $TEST=1; @@ -1115,7 +1133,7 @@ else { if ($DB) {print "starting AST_VDremote_agents...\n";} # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTVDremote $PATHhome/AST_VDremote_agents.pl --debug $debug_string`; + `/usr/bin/screen -d -m -S ASTVDremote $PATHhome/AST_VDremote_agents.pl --debug $ra_delay $debug_string`; if ($megaDB) { `/usr/bin/screen -S ASTVDremote -X logfile $PATHlogs/ASTVDremote-screenlog.0`; diff --git a/agc_2-X/trunk/bin/AST_VDremote_agents.pl b/agc_2-X/trunk/bin/AST_VDremote_agents.pl index 0dc1e90b..2a675b69 100644 --- a/agc_2-X/trunk/bin/AST_VDremote_agents.pl +++ b/agc_2-X/trunk/bin/AST_VDremote_agents.pl @@ -60,9 +60,10 @@ # 240516-2149 - Allow for ALT start_call_url, added --version flag # 260403-2253 - Added vicidial_max_inbound_cache logging # 260515-1935 - Added internal logging +# 260903-1936 - Changed inactive agent and queue-status agents processing to run more often if short --delay is used, added INCALL/QUEUE status no-call check # -$build = '260515-1933'; +$build = '260903-1936'; $script_name = 'AST_VDremote_agents.pl'; ### begin parsing run-time options ### @@ -266,7 +267,9 @@ while($one_day_interval > 0) $VDRLOGfile = "$PATHlogs/remoteagent.$year-$mon-$mday"; - if ($endless_loop =~ /0$|5$/) + ### Remove inactive remote agents and process QUEUE agents into INCALL status + ### By default, every 5 loops(10 seconds), or if delay override to 1 second, run this section every 2 seconds + if ( ( ($endless_loop =~ /0$|5$/) && ($loop_delay >= 2000) ) || ( ($endless_loop =~ /0$|2$|4$|6$|8$/) && ($loop_delay < 2000) ) ) { ### Grab Server values from the database $stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';"; @@ -563,7 +566,7 @@ while($one_day_interval > 0) $concurrent_calls=0; $incalls_count=0; - ### Get count of concurrent calls for this in-group + ### Get count of concurrent calls for this user $stmtA = "SELECT count(*) FROM vicidial_live_agents where ra_user='$QHra_user[$w]' and extension LIKE \"R/%\" and status IN('QUEUE','INCALL','DONE');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -682,6 +685,11 @@ while($one_day_interval > 0) @VD_uniqueid=@MT; @VD_callerid=@MT; @VD_random=@MT; + @dVD_user=@MT; + @dVD_extension=@MT; + @dVD_status=@MT; + @dVD_campaign_id=@MT; + @dVD_random=@MT; @autocallexists=@MT; @calllogfinished=@MT; @@ -1011,8 +1019,8 @@ while($one_day_interval > 0) ############################################################################### - ###### fourth, validate that the calls that the vicidial_live_agents are on and not dead - ###### and if they are wipe out the values and set the agent record back to READY + ###### fourth, validate that the calls that the vicidial_live_agents are on are not dead + ###### and if they are, wipe out the values and set the agent record back to READY ############################################################################### $stmtA = "SELECT user,extension,status,uniqueid,callerid,lead_id,campaign_id,call_server_ip FROM vicidial_live_agents where extension LIKE \"R/%\" and server_ip='$server_ip' and uniqueid > 10;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1064,16 +1072,19 @@ while($one_day_interval > 0) } $sthA->finish(); - $stmtA = "SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$VD_campaign_id[$z]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) + if ($enable_queuemetrics_logging > 0) { - @aryA = $sthA->fetchrow_array; - $USER_queuemetrics_phone_environment[$z] = $aryA[0]; + $stmtA = "SELECT queuemetrics_phone_environment FROM vicidial_campaigns where campaign_id='$VD_campaign_id[$z]';"; + $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; + $USER_queuemetrics_phone_environment[$z] = $aryA[0]; + } + $sthA->finish(); } - $sthA->finish(); if ($autocallexists[$z] < 1) { @@ -1083,10 +1094,12 @@ while($one_day_interval > 0) if ($DELusers =~ /R\/$VD_user[$z]\|/) { - $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',status='PAUSED', last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='',last_state_change='$SQLdate' where user='$VD_user[$z]' and server_ip='$server_ip';"; - $affected_rows = $dbhA->do($stmtA); - if ($DB) {print STDERR "$VD_user[$z] CALL WIPE DELETE UPDATE: $affected_rows|PAUSED|$VD_uniqueid[$z]|$VD_user[$z]|\n";} - if ($affected_rows>0) + $newRAstatus='PAUSED'; + $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',status='$newRAstatus', last_call_finish='$SQLdate',lead_id=0,uniqueid='',callerid='',channel='',last_state_change='$SQLdate' where user='$VD_user[$z]' and server_ip='$server_ip';"; + $affected_rowsA = $dbhA->do($stmtA); + $affected_rowsB=0; + if ($DB) {print STDERR "SQLdate - $VD_user[$z] CALL WIPE DELETE UPDATE: $affected_rowsA|$newRAstatus|$VD_uniqueid[$z]| \n";} + if ($affected_rowsA>0) { if ($enable_queuemetrics_logging > 0) { @@ -1187,14 +1200,15 @@ while($one_day_interval > 0) } else { - $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]', last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='',last_state_change='$SQLdate' where user='$VD_user[$z]' and server_ip='$server_ip';"; - $affected_rows = $dbhA->do($stmtA); - if ($DB) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_user[$z]|\n";} + $newRAstatus='READY'; + $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]', last_call_finish='$SQLdate',lead_id=0,uniqueid='',callerid='',channel='',last_state_change='$SQLdate' where user='$VD_user[$z]' and server_ip='$server_ip';"; + $affected_rowsA = $dbhA->do($stmtA); + if ($DB) {print STDERR "$SQLdate - $VD_user[$z] CALL WIPE UPDATE: $affected_rowsA|$VD_uniqueid[$z]| \n";} - $stmtA = "UPDATE vicidial_live_agents set status='READY' where user='$VD_user[$z]' and server_ip='$server_ip';"; - $affected_rows = $dbhA->do($stmtA); - if ($DB) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_user[$z]|\n";} - if ($affected_rows>0) + $stmtA = "UPDATE vicidial_live_agents set status='$newRAstatus' where user='$VD_user[$z]' and server_ip='$server_ip';"; + $affected_rowsB = $dbhA->do($stmtA); + if ($DB) {print STDERR "$SQLdate - $VD_user[$z] CALL WIPE STATUS UPDATE: $affected_rowsB|$newRAstatus|$VD_uniqueid[$z]| \n";} + if ($affected_rowsB > 0) { if ($enable_queuemetrics_logging > 0) { @@ -1216,6 +1230,11 @@ while($one_day_interval > 0) } } } + if ( ($affected_rowsA > 0) || ($affected_rowsB > 0) ) + { + $event_string = "| CALL WIPE AGENT UPDATE: |$affected_rowsA|$affected_rowsB| |$VD_user[$z]|$VD_callerid[$z]|$VD_uniqueid[$z]|$newRAstatus|"; + &event_logger; + } } ### possible future active call checker # else @@ -1234,7 +1253,7 @@ while($one_day_interval > 0) # $sthA->finish(); # if ($calllogfinished[$z] > 1) # { - # $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',status='READY', last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='' where user='$VD_user[$z]' and server_ip='$server_ip';"; + # $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',status='READY', last_call_finish='$SQLdate',lead_id=0,uniqueid='',callerid='',channel='' where user='$VD_user[$z]' and server_ip='$server_ip';"; # $affected_rows = $dbhA->do($stmtA); # if ($DB) {print STDERR "$VD_user[$z] AGENT READY UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_callerid[$z]|$VD_user[$z]|\n";} @@ -1249,6 +1268,69 @@ while($one_day_interval > 0) + ############################################################################### + ###### fifth, look for vicidial_live_agents remote agents that are INCALL but with no call + ###### if found, wipe out the values and set the agent record back to READY + ############################################################################### + $stmtA = "SELECT user,extension,status,campaign_id FROM vicidial_live_agents where extension LIKE \"R/%\" and server_ip='$server_ip' and uniqueid='' and callerid='' and lead_id=0 and status IN('INCALL','QUEUE');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + $z=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $VDuser = $aryA[0]; + $VDextension = $aryA[1]; + $VDstatus = $aryA[2]; + $VDcampaign_id = $aryA[3]; + $VDrandom = int( rand(9999999)) + 10000000; + + $dVD_user[$z] = $VDuser; + $dVD_extension[$z] = $VDextension; + $dVD_status[$z] = $VDstatus; + $dVD_campaign_id[$z] = $VDcampaign_id; + $dVD_random[$z] = $VDrandom; + + $z++; + $rec_count++; + } + $sthA->finish(); + if ($DB) {print STDERR "$z remote agents INCALL/QUEUE with no call \n";} + + $z=0; + foreach(@dVD_user) + { + if ($DELusers =~ /R\/$dVD_user[$z]\|/) + { + $newRAstatus='PAUSED'; + $stmtA = "UPDATE vicidial_live_agents set random_id='$dVD_random[$z]',status='$newRAstatus', last_call_finish='$SQLdate',lead_id=0,uniqueid='',callerid='',channel='',last_state_change='$SQLdate' where user='$dVD_user[$z]' and server_ip='$server_ip';"; + $affected_rowsA = $dbhA->do($stmtA); + if ($DB) {print STDERR "$SQLdate - $dVD_user[$z] RA user NO-CALL WIPE DELETE UPDATE: $affected_rowsA|$newRAstatus|$dVD_extension[$z]|$dVD_user[$z]|\n";} + $affected_rowsB=0; + } + else + { + $newRAstatus='READY'; + $stmtA = "UPDATE vicidial_live_agents set random_id='$dVD_random[$z]', last_call_finish='$SQLdate',lead_id=0,uniqueid='',callerid='',channel='',last_state_change='$SQLdate' where user='$dVD_user[$z]' and server_ip='$server_ip';"; + $affected_rowsA = $dbhA->do($stmtA); + if ($DB) {print STDERR "$SQLdate - $dVD_user[$z] RA user NO-CALL WIPE UPDATE: $affected_rowsA|$SQLdate|$dVD_extension[$z]| \n";} + + $stmtA = "UPDATE vicidial_live_agents set status='$newRAstatus' where user='$dVD_user[$z]' and server_ip='$server_ip';"; + $affected_rowsB = $dbhA->do($stmtA); + if ($DB) {print STDERR "$SQLdate - $dVD_user[$z] RA user NO-CALL WIPE STATUS UPDATE: $affected_rowsB|$newRAstatus|$dVD_extension[$z]| \n";} + } + + if ( ($affected_rowsA > 0) || ($affected_rowsB > 0) ) + { + $event_string = "| NO-CALL WIPE AGENT UPDATE: |$affected_rowsA|$affected_rowsB| |$VD_user[$z]|$dVD_extension[$z]|$newRAstatus|"; + &event_logger; + } + $z++; + } + + ############################################################################### ###### last, wait for a little bit and repeat the loop ############################################################################### @@ -1325,8 +1407,6 @@ sub get_time_now #get the current date and time and epoch for logging call lengt if ($hour < 10) {$hour = "0$hour";} if ($min < 10) {$min = "0$min";} - if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = ($year + 1900); $mon++; @@ -1344,6 +1424,8 @@ sub get_time_now #get the current date and time and epoch for logging call lengt $filedate = "$year-$mon-$mday"; $YMD = "$year-$mon-$mday"; + if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min $SQLdate \n";} + $FDtarget = ($secX + 10); ($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime($FDtarget); $Fyear = ($Fyear + 1900); diff --git a/agc_2-X/trunk/docs/conf_examples/logger.conf.sample b/agc_2-X/trunk/docs/conf_examples/logger.conf.sample index 606add1f..d4ca0ee9 100644 --- a/agc_2-X/trunk/docs/conf_examples/logger.conf.sample +++ b/agc_2-X/trunk/docs/conf_examples/logger.conf.sample @@ -1,3 +1,6 @@ +[general] +dateformat = %F %T.%3q + [logfiles] console => notice,warning,error,dtmf messages => notice,warning,error,debug,verbose,dtmf