diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index 3ee9ccca..9d7bac38 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -94,6 +94,7 @@ # 140126-2252 - Added voicemail_instructions option for phones # 140214-1519 - Added reload_timestamp value to conf files # 140619-1001 - Added new ASTplay loop IAX trunk +# 141113-1555 - Changed FILL process screen from ASTVDautoFILL to ASTVDadFILL for easier admin # $build = '140619-1001'; @@ -677,7 +678,7 @@ else { if ($DB) {print "starting AST_VDauto_dial_FILL...\n";} # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTVDautoFILL $PATHhome/AST_VDauto_dial_FILL.pl --debug $fill_staggered $adfill_delay`; + `/usr/bin/screen -d -m -S ASTVDadFILL $PATHhome/AST_VDauto_dial_FILL.pl --debug $fill_staggered $adfill_delay`; } if ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) { diff --git a/bin/AST_VDadapt.pl b/bin/AST_VDadapt.pl index f6e7c5d1..37456ee0 100644 --- a/bin/AST_VDadapt.pl +++ b/bin/AST_VDadapt.pl @@ -40,12 +40,14 @@ # 111223-0924 - Added check for logged-in agents # 131122-1314 - Added several missing sthA->finish # 141109-1957 - Fixed issue #793 +# 141113-1616 - Added concurrency check # # constants $DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute $US='__'; $MT[0]=''; +$run_check=1; # concurrency check ##### table definitions(used to force index usage for better performance): $vicidial_log = 'vicidial_log FORCE INDEX (call_date) '; @@ -333,6 +335,21 @@ $sthA->finish(); ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + $master_loop=0; ### Start master loop ### diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index 0b62f4f9..77021410 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_VDauto_dial.pl version 2.8 +# AST_VDauto_dial.pl version 2.10 # # DESCRIPTION: # Places auto_dial calls on the VICIDIAL dialer system @@ -117,6 +117,7 @@ # 131122-1233 - Added several missing sthA->finish # 131209-1557 - Added called_count logging # 140426-1941 - Added pause_type to vicidial_agent_log +# 141113-1556 - Added concurrency check # @@ -179,6 +180,7 @@ $RECcount=''; ### leave blank for no REC count $RECprefix='7'; ### leave blank for no REC prefix $useJAMdebugFILE='1'; ### leave blank for no Jam call debug file writing $max_vicidial_trunks=0; ### setting a default value for max_vicidial_trunks +$run_check=1; # concurrency check # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -299,6 +301,21 @@ $sthA->finish(); ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + $one_day_interval = 12; # 1 month loops for one year while($one_day_interval > 0) diff --git a/bin/AST_VDremote_agents.pl b/bin/AST_VDremote_agents.pl index 9de3e9f6..8dd69f34 100644 --- a/bin/AST_VDremote_agents.pl +++ b/bin/AST_VDremote_agents.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_VDremote_agents.pl version 2.8 +# AST_VDremote_agents.pl version 2.10 # # SUMMARY: # To use VICIDIAL with remote agents, this must always be running @@ -49,6 +49,7 @@ # 131122-1104 - Small fixes and formatting changes # 140417-0934 - Added max inbound calls feature # 140428-1449 - Added pause_type +# 141113-1559 - Added concurrency check # ### begin parsing run-time options ### @@ -116,6 +117,7 @@ $local_DEF = 'Local/'; $conf_silent_prefix = '7'; $local_AMP = '@'; $agents = '@agents'; +$run_check=1; # concurrency check # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -197,6 +199,21 @@ $event_string='PROGRAM STARTED|||||||||||||||||||||||||||||||||||||||||||||||||| $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; &event_logger; +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + #$one_day_interval = 12; # 1 month loops for one year $one_day_interval = 1; # 1 day while($one_day_interval > 0) diff --git a/bin/AST_manager_listen.pl b/bin/AST_manager_listen.pl index a3dee936..1c1e0775 100644 --- a/bin/AST_manager_listen.pl +++ b/bin/AST_manager_listen.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_manager_listen.pl version 2.8 +# AST_manager_listen.pl version 2.10 # # Part of the Asterisk Central Queue System (ACQS) # @@ -41,6 +41,7 @@ # 130412-1216 - Added sip hangup cause logging from new patch AMI event # 130418-1946 - Changed asterisk 1.8 compatibility for CPD and SIP Hangup # 140524-0900 - Fixed issue with consultative agent transfers in Asterisk 1.8 +# 141113-1605 - Added concurrency check # # constants @@ -49,6 +50,7 @@ $US='__'; $MT[0]=''; $vdcl_update=0; $vddl_update=0; +$run_check=1; # concurrency check ### begin parsing run-time options ### if (length($ARGV[0])>1) @@ -190,6 +192,21 @@ if (!$telnet_port) {$telnet_port = '5038';} $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; &event_logger; +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + $one_day_interval = 90; # 1 day loops for 3 months while($one_day_interval > 0) { diff --git a/bin/AST_manager_send.pl b/bin/AST_manager_send.pl index 43deb451..3b85bbec 100644 --- a/bin/AST_manager_send.pl +++ b/bin/AST_manager_send.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_manager_send.pl version 2.2.0 +# AST_manager_send.pl version 2.10 # # Part of the Asterisk Central Queue System (ACQS) # @@ -16,7 +16,7 @@ # scalability over just using a single process. Also, this means that a single # action execution lock cannot bring the entire system down. # -# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2014 Matt Florell LICENSE: AGPLv2 # # CHANGES # 50823-1514 - Added commandline debug options with debug printouts @@ -29,6 +29,7 @@ # 61221-1926 - optimize and clean code, lc # 80418-0901 - reduced time between Actions being sent, raised endless loop timer # 91129-2146 - removed SELECT STAR and formatting fixes +# 141113-1356 - Added more logging, check for number of running instances, processing of QUEUE but not SENT commands # $|++; @@ -37,6 +38,8 @@ use DBI; use Getopt::Long; use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +my $run_check=1; # concurrency check + # constants and globals my $servConf; my %conf; @@ -104,7 +107,22 @@ $SYSLOG = 1 if ($servConf->{vd_server_logs} =~ /Y/); my $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; eventLogger($conf{PATHlogs}, 'process', $event_string); +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + my $event_string="I am not alone! Another $0 is running! Exiting..."; + eventLogger($conf{PATHlogs}, 'process', $event_string); + exit; + } + } +my $processed_actions=0; my $one_day_interval = 182; # 2 day loops for 12 months while ($one_day_interval > 0) { @@ -113,22 +131,34 @@ while ($one_day_interval > 0) my $NEW_actions; while ($endless_loop > 0) { - my $stmtA = "SELECT count(*) from vicidial_manager where server_ip = '" . $conf{VARserver_ip} . "' and status = 'NEW'"; + my $stmtA = "SELECT count(*) from vicidial_manager where server_ip = '" . $conf{VARserver_ip} . "' and status = 'NEW';"; my $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; my $NEW_actions = ($sthA->fetchrow_array)[0]; - print STDERR $NEW_actions . " NEW Actions to send on server " . $conf{VARserver_ip} . " $endless_loop\n" if ($DB); - $sthA->finish(); + $sthA->finish(); - if ($NEW_actions) + my $stmtA = "SELECT count(*) from vicidial_manager where server_ip = '" . $conf{VARserver_ip} . "' and status = 'QUEUE';"; + my $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + my $QUEUE_actions = ($sthA->fetchrow_array)[0]; + print STDERR $NEW_actions . " NEW and " . $QUEUE_actions . " QUEUE Actions to send on server " . $conf{VARserver_ip} . " $endless_loop\n" if ($DB); + $sthA->finish(); + + $affected_rows = 0; + if ($NEW_actions > 0) { - my $stmtA = "UPDATE vicidial_manager set status='QUEUE' where server_ip = '" . $conf{VARserver_ip} . "' and status = 'NEW' order by man_id limit 1"; + my $stmtA = "UPDATE vicidial_manager set status='QUEUE' where server_ip = '" . $conf{VARserver_ip} . "' and status = 'NEW' order by man_id limit 1;"; $affected_rows = $dbhA->do($stmtA); print STDERR "rows updated to QUEUE: |$affected_rows|\n" if ($DB); } else { - $affected_rows = 0; + if ($QUEUE_actions > 0) + { + $affected_rows = $QUEUE_actions; + my $event_string=nowDate() . "No NEW actions, but " . $QUEUE_actions . " QUEUE actions in vicidial_manager|" . $affected_rows; + eventLogger($conf{PATHlogs}, 'process', $event_string); + } } if ($affected_rows) @@ -144,6 +174,10 @@ while ($one_day_interval > 0) print STDERR $vdm->{man_id} . "|" . $vdm->{uniqueid} . "|" . $vdm->{channel} . "|" . $vdm->{action} . "|" . $vdm->{callerid} . "\n" if ($DB); + my $event_string=nowDate() . "|" . $vdm->{entry_date} . "|" . $vdm->{man_id} . "|" . $vdm->{uniqueid} . "|" . $vdm->{channel} . "|" . + $vdm->{action} . "|" . $vdm->{callerid}; + eventLogger($conf{PATHlogs}, 'process', $event_string); + my $originate_command = "Action: ". $vdm->{action} . "\n"; $originate_command .= $vdm->{cmd_line_b} . "\n" if ($vdm->{cmd_line_b}); $originate_command .= $vdm->{cmd_line_c} . "\n" if ($vdm->{cmd_line_c}); @@ -224,7 +258,7 @@ while ($one_day_interval > 0) system($launch . ' &'); # $launch = "SENT " . $vdm->{man_id} . " " . $vdm->{callerid} . ' ' . $vdm->{uniqueid} . ' ' . $vdm->{channel}; - # eventLogger($conf{'PATHlogs'}, 'launch', $launch);; + # eventLogger($conf{'PATHlogs'}, 'launch', $launch); my $stmtA = "UPDATE vicidial_manager set status='SENT' where man_id='" . $vdm->{man_id} . "'"; print STDERR "\n|$stmtA|\n" if ($DB); @@ -239,8 +273,9 @@ while ($one_day_interval > 0) print STDERR "\n|$stmtA|\n" if ($DB); $affected_rows = $dbhA->do($stmtA); $event_string="COMMAND NOT SENT, SQL_QUERY|$stmtA|"; - eventLogger($conf{'PATHlogs'}, 'process', $event_string);; + eventLogger($conf{'PATHlogs'}, 'process', $event_string); } + $processed_actions++; } $sthA->finish(); } @@ -274,10 +309,11 @@ while ($one_day_interval > 0) ### Grab Server values from the database $servConf = getServerConfig($dbhA, $conf{VARserver_ip}); - print "checking to see if listener is dead |$sendonlyone|$running_listen|\n" if($COUNTER_OUTPUT or $DB); + print nowDate() . " checking to see if listener is dead |$sendonlyone|$running_listen|$endless_loop|$processed_actions|\n" if($COUNTER_OUTPUT or $DB); + $processed_actions=0; #my @psoutput = `/bin/ps -f --no-headers -A`; my @psoutput = `/bin/ps -o "%p %a" --no-headers -A`; - foreach my $line (@psoutput) + foreach my $line (@psoutput) { chomp($line); print "|$line| \n" if ($DBX); @@ -296,8 +332,8 @@ while ($one_day_interval > 0) $event_string = 'LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT|'; eventLogger($conf{'PATHlogs'}, 'process', $event_string); # `/usr/bin/at now < $PATHhome/ADMIN_keepalive_send_listen.at 2>/dev/null 1>&2`; - my $screencmd = "/usr/bin/screen -d -m " . $conf{PATHhome} . "/ADMIN_keepalive_AST_send_listen.pl 2>/dev/null 1>&2"; - `$screencmd`; + # my $screencmd = "/usr/bin/screen -d -m " . $conf{PATHhome} . "/ADMIN_keepalive_AST_send_listen.pl 2>/dev/null 1>&2"; + # `$screencmd`; } } } diff --git a/bin/AST_update.pl b/bin/AST_update.pl index c341903c..107d9136 100644 --- a/bin/AST_update.pl +++ b/bin/AST_update.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_update.pl version 2.8 +# AST_update.pl version 2.10 # # DESCRIPTION: # uses the Asterisk Manager interface and DBD::MySQL to update the live_channels @@ -61,9 +61,10 @@ # 130413-2125 - Fix for issue #664, formatting fixes and added --quiet flag # 131122-1317 - Small formatting fixes # 140510-0119 - Small formatting and asterisk version changes +# 141113-1601 - Added concurrency check # -$build = '140510-0119'; +$build = '141113-1601'; # constants $SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds @@ -77,6 +78,7 @@ $MT[0]=''; $cpuUSERprev=0; $cpuSYSTprev=0; $cpuIDLEprev=0; +$run_check=1; # concurrency check # find proper locations of bin utils @@ -420,6 +422,21 @@ if ($Q < 1) print STDERR "SIP Clients: $SIP_client_list\n"; } +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + $one_day_interval = 12; # 2 hour loops for one day while($one_day_interval > 0) { diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index 3e076d50..790e2591 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -445,10 +445,11 @@ # 140902-0826 - Added callback_active_limit and callback_active_limit_override # 140918-1606 - Fixed manual dial pause warning issue # 141105-1153 - Fixed issue with AGENTDIRECT transfers to agents with IDs over 7 characters long +# 141113-1431 - Added admin_test option to allow login on active_agent=N servers # -$version = '2.10-416c'; -$build = '141105-1153'; +$version = '2.10-417c'; +$build = '141113-1431'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=80; $one_mysql_log=0; @@ -476,6 +477,8 @@ if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} if (isset($_GET["MGR_override"])) {$MGR_override=$_GET["MGR_override"];} elseif (isset($_POST["MGR_override"])) {$MGR_override=$_POST["MGR_override"];} +if (isset($_GET["admin_test"])) {$admin_test=$_GET["admin_test"];} + elseif (isset($_POST["admin_test"])) {$admin_test=$_POST["admin_test"];} if (!isset($phone_login)) { if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} @@ -504,7 +507,7 @@ $phone_pass=preg_replace("/[^0-9a-zA-Z]/","",$phone_pass); $VD_login=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_login); $VD_pass=preg_replace("/[^-_0-9a-zA-Z]/","",$VD_pass); $VD_campaign = preg_replace("/[^-_0-9a-zA-Z]/","",$VD_campaign); - +$admin_test = preg_replace("/[^0-9a-zA-Z]/","",$admin_test); $forever_stop=0; @@ -938,6 +941,7 @@ if ($relogin == 'YES') echo "\n"; echo "\n"; echo "\n"; + echo "\n"; echo "


"; echo ""; echo ""; @@ -2173,8 +2177,14 @@ else $authphone=0; #$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';"; - $stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and active_agent_login_server='Y' and phones.server_ip=servers.server_ip;"; + + $active_agentSQL = "and active_agent_login_server='Y'"; + if ($admin_test == 'YES') + {$active_agentSQL='';} + $stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and phones.server_ip=servers.server_ip $active_agentSQL;"; if ($DB) {echo "|$stmt|\n";} + echo "\n"; + $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01020',$VD_login,$server_ip,$session_name,$one_mysql_log);} $row=mysqli_fetch_row($rslt); @@ -2245,7 +2255,7 @@ else $row=mysqli_fetch_row($rslt); ### find out whether the server is set to active - $stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' and active_agent_login_server='Y';"; + $stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' $active_agentSQL;"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
\"VICIdial\" "._QXZ("Re-Login")."