diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index 28c1c3fd..f29c3619 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -13,6 +13,7 @@ # - Synchronizes the audio store files # - Runs trigger processes at defined times # - Auto reset lists at defined times +# - Auto restarts Asterisk process if enabled in servers settings # # Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # @@ -87,8 +88,11 @@ # 130624-0733 - Added optimize for vicidial_users due to logging IP and auth timestamp # 130716-1441 - Clear out vicidial_monitor_calls records older than 1 day old # 130921-1044 - Small change to triggers allowing for them to be launched in a screen session if SCREEN is in the name +# 131022-1746 - Added uptime gathering and asterisk auto-restart feature # +$build = '131022-1746'; + $DB=0; # Debug flag $MT[0]=''; $MT[1]=''; @psline=@MT; @@ -124,6 +128,7 @@ if (length($ARGV[0])>1) { print "allowed run time options:\n"; print " [-test] = test\n"; + print " [--version] = print version of this script, then exit\n"; print " [-autodial-delay=X] = setting delay milliseconds on local auto-dial process\n"; print " [-adfill-delay=X] = setting delay milliseconds on auto-dial FILL process\n"; print " [-fill-staggered] = enable experimental staggered auto-dial FILL process\n"; @@ -137,6 +142,11 @@ if (length($ARGV[0])>1) } else { + if ($args =~ /--version/i) + { + print "version: $build\n"; + exit; + } if ($args =~ /-debug/i) { $DB=1; # Debug flag @@ -254,188 +264,100 @@ foreach(@conf) if ($VARactive_keepalives =~ /X/) { - if ($DB) {print "X in active_keepalives, exiting...\n";} - exit; + if ($DB) {print "X in active_keepalives, skipping this section...\n";} } - -$AST_update=0; -$AST_send_listen=0; -$AST_VDauto_dial=0; -$AST_VDremote_agents=0; -$AST_VDadapt=0; -$FastAGI_log=0; -$email_inbound=0; -$AST_VDauto_dial_FILL=0; -$ip_relay=0; -$timeclock_auto_logout=0; -$runningAST_update=0; -$runningAST_send=0; -$runningAST_listen=0; -$runningAST_VDauto_dial=0; -$runningAST_VDremote_agents=0; -$runningAST_VDadapt=0; -$runningFastAGI_log=0; -$runningAST_VDauto_dial_FILL=0; -$runningip_relay=0; -$runningAST_conf_3way=0; -$runningemail_inbound=0; -$AST_conf_3way=0; - -if ($VARactive_keepalives =~ /1/) - { - $AST_update=1; - if ($DB) {print "AST_update set to keepalive\n";} - } -if ($VARactive_keepalives =~ /2/) - { - $AST_send_listen=1; - if ($DB) {print "AST_send_listen set to keepalive\n";} - } -if ($VARactive_keepalives =~ /3/) - { - $AST_VDauto_dial=1; - if ($DB) {print "AST_VDauto_dial set to keepalive\n";} - } -if ($VARactive_keepalives =~ /4/) - { - $AST_VDremote_agents=1; - if ($DB) {print "AST_VDremote_agents set to keepalive\n";} - } -if ($VARactive_keepalives =~ /5/) - { - $AST_VDadapt=1; - if ($DB) {print "AST_VDadapt set to keepalive\n";} - } -if ($VARactive_keepalives =~ /6/) - { - $FastAGI_log=1; - if ($DB) {print "FastAGI_log set to keepalive\n";} - } -if ($VARactive_keepalives =~ /7/) - { - $AST_VDauto_dial_FILL=1; - if ($DB) {print "AST_VDauto_dial_FILL set to keepalive\n";} - } -if ($VARactive_keepalives =~ /8/) - { - $ip_relay=1; - if ($DB) {print "ip_relay set to keepalive\n";} - } -if ($VARactive_keepalives =~ /9/) - { - $timeclock_auto_logout=1; - if ($DB) {print "Check to see if Timeclock auto logout should run\n";} - } -if ($VARactive_keepalives =~ /E/) - { - $email_inbound=1; - if ($DB) {print "Check to see if email parser should run\n";} - } -if ($cu3way > 0) - { - $AST_conf_3way=1; - if ($DB) {print "AST_conf_3way set to keepalive\n";} - } - - -$REGhome = $PATHhome; -$REGhome =~ s/\//\\\//gi; - - - - - - -##### First, check and see which processes are running ##### - -### you may have to use a different ps command if you're not using Slackware Linux -# @psoutput = `ps -f -C AST_update --no-headers`; -# @psoutput = `ps -f -C AST_updat* --no-headers`; -# @psoutput = `/bin/ps -f --no-headers -A`; -# @psoutput = `/bin/ps -o pid,args -A`; ### use this one for FreeBSD -@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; - -$i=0; -foreach (@psoutput) - { - chomp($psoutput[$i]); - if ($DBX) {print "$i|$psoutput[$i]| \n";} - @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); - - if ($psline[1] =~ /$REGhome\/AST_update\.pl/) - { - $runningAST_update++; - if ($DB) {print "AST_update RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /AST_manager_se/) - { - $runningAST_send++; - if ($DB) {print "AST_send RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /AST_manager_li/) - { - $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; - $listen_pid[$runningAST_listen] = $psoutput[$i]; - $runningAST_listen++; - if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/) - { - $runningAST_VDauto_dial++; - if ($DB) {print "AST_VDauto_dial RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /$REGhome\/AST_VDremote_agents\.pl/) - { - $runningAST_VDremote_agents++; - if ($DB) {print "AST_VDremote_agents RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /$REGhome\/AST_VDadapt\.pl/) - { - $runningAST_VDadapt++; - if ($DB) {print "AST_VDadapt RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /$REGhome\/FastAGI_log\.pl/) - { - $runningFastAGI_log++; - if ($DB) {print "FastAGI_log RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /$REGhome\/AST_VDauto_dial_FILL\.pl/) - { - $runningAST_VDauto_dial_FILL++; - if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";} - } - if ($psline[1] =~ /$REGhome\/VD_email_inbound\.pl/) - { - $runningemail_inbound++; - if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";} - } - if ($psoutput[$i] =~ / ip_relay /) - { - $runningip_relay++; - if ($DB) {print "ip_relay RUNNING: |$psoutput[$i]|\n";} - } - if ($psline[1] =~ /$REGhome\/AST_conf_update_3way\.pl/) - { - $runningAST_conf_3way++; - if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";} - } - - $i++; - } - - - - - -##### Second, IF MORE THAN ONE LISTEN INSTANCE IS RUNNING, KILL THE SECOND ONE ##### -@psline=@MT; -@psoutput=@MT; -@listen_pid=@MT; -if ($runningAST_listen > 1) +else { + $AST_update=0; + $AST_send_listen=0; + $AST_VDauto_dial=0; + $AST_VDremote_agents=0; + $AST_VDadapt=0; + $FastAGI_log=0; + $email_inbound=0; + $AST_VDauto_dial_FILL=0; + $ip_relay=0; + $timeclock_auto_logout=0; + $runningAST_update=0; + $runningAST_send=0; $runningAST_listen=0; + $runningAST_VDauto_dial=0; + $runningAST_VDremote_agents=0; + $runningAST_VDadapt=0; + $runningFastAGI_log=0; + $runningAST_VDauto_dial_FILL=0; + $runningip_relay=0; + $runningAST_conf_3way=0; + $runningemail_inbound=0; + $runningASTERISK=0; + $AST_conf_3way=0; - sleep(1); + if ($VARactive_keepalives =~ /1/) + { + $AST_update=1; + if ($DB) {print "AST_update set to keepalive\n";} + } + if ($VARactive_keepalives =~ /2/) + { + $AST_send_listen=1; + if ($DB) {print "AST_send_listen set to keepalive\n";} + } + if ($VARactive_keepalives =~ /3/) + { + $AST_VDauto_dial=1; + if ($DB) {print "AST_VDauto_dial set to keepalive\n";} + } + if ($VARactive_keepalives =~ /4/) + { + $AST_VDremote_agents=1; + if ($DB) {print "AST_VDremote_agents set to keepalive\n";} + } + if ($VARactive_keepalives =~ /5/) + { + $AST_VDadapt=1; + if ($DB) {print "AST_VDadapt set to keepalive\n";} + } + if ($VARactive_keepalives =~ /6/) + { + $FastAGI_log=1; + if ($DB) {print "FastAGI_log set to keepalive\n";} + } + if ($VARactive_keepalives =~ /7/) + { + $AST_VDauto_dial_FILL=1; + if ($DB) {print "AST_VDauto_dial_FILL set to keepalive\n";} + } + if ($VARactive_keepalives =~ /8/) + { + $ip_relay=1; + if ($DB) {print "ip_relay set to keepalive\n";} + } + if ($VARactive_keepalives =~ /9/) + { + $timeclock_auto_logout=1; + if ($DB) {print "Check to see if Timeclock auto logout should run\n";} + } + if ($VARactive_keepalives =~ /E/) + { + $email_inbound=1; + if ($DB) {print "Check to see if email parser should run\n";} + } + if ($cu3way > 0) + { + $AST_conf_3way=1; + if ($DB) {print "AST_conf_3way set to keepalive\n";} + } + + + $REGhome = $PATHhome; + $REGhome =~ s/\//\\\//gi; + + + + + + + ##### First, check and see which processes are running ##### ### you may have to use a different ps command if you're not using Slackware Linux # @psoutput = `ps -f -C AST_update --no-headers`; @@ -447,73 +369,15 @@ if ($runningAST_listen > 1) $i=0; foreach (@psoutput) { - chomp($psoutput[$i]); + chomp($psoutput[$i]); if ($DBX) {print "$i|$psoutput[$i]| \n";} @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); - $psoutput[$i] =~ s/^ *//gi; - $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; - if ($psline[1] =~ /AST_manager_li/) + if ($psoutput[$i] =~ /bin\/asterisk/) { - $listen_pid[$runningAST_listen] = $psoutput[$i]; - if ($DB) {print "AST_listen RUNNING: |$psline[1]|$listen_pid[$runningAST_listen]|\n";} - $runningAST_listen++; + $runningASTERISK++; + if ($DB) {print "asterisk RUNNING: |$psoutput[$i]|\n";} } - - $i++; - } - - if ($runningAST_listen > 1) - { - if ($DB) {print "Killing AST_manager_listen... |$listen_pid[1]|\n";} - `/bin/kill -s 9 $listen_pid[1]`; - } - } - - - - - - - -##### Third, double-check that non-running scripts are not running ##### -@psline=@MT; -@psoutput=@MT; - -if ( - ( ($AST_update > 0) && ($runningAST_update < 1) ) || - ( ($AST_send_listen > 0) && ($runningAST_send < 1) ) || - ( ($AST_send_listen > 0) && ($runningAST_listen < 1) ) || - ( ($AST_VDauto_dial > 0) && ($runningAST_VDauto_dial < 1) ) || - ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) || - ( ($AST_VDadapt > 0) && ($runningAST_VDadapt < 1) ) || - ( ($FastAGI_log > 0) && ($runningFastAGI_log < 1) ) || - ( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) || - ( ($ip_relay > 0) && ($runningip_relay < 1) ) || - ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) || - ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) - ) - { - - if ($DB) {print "double check that processes are not running...\n";} - - sleep(1); - - #`PERL5LIB="$PATHhome/libs"; export PERL5LIB`; # issue #457 - $ENV{'PERL5LIB'} = "$PATHhome/libs"; - ### you may have to use a different ps command if you're not using Slackware Linux - # @psoutput = `ps -f -C AST_update --no-headers`; - # @psoutput = `ps -f -C AST_updat* --no-headers`; - # @psoutput = `/bin/ps -f --no-headers -A`; - # @psoutput = `/bin/ps -o pid,args -A`; ### use this one for FreeBSD - @psoutput2 = `/bin/ps -o "%p %a" --no-headers -A`; - $i=0; - foreach (@psoutput2) - { - chomp($psoutput2[$i]); - if ($DBX) {print "$i|$psoutput2[$i]| \n";} - @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); - if ($psline[1] =~ /$REGhome\/AST_update\.pl/) { $runningAST_update++; @@ -526,6 +390,8 @@ if ( } if ($psline[1] =~ /AST_manager_li/) { + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + $listen_pid[$runningAST_listen] = $psoutput[$i]; $runningAST_listen++; if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";} } @@ -559,90 +425,244 @@ if ( $runningemail_inbound++; if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";} } - if ($psoutput2[$i] =~ / ip_relay /) + if ($psoutput[$i] =~ / ip_relay /) { $runningip_relay++; - if ($DB) {print "ip_relay RUNNING: |$psoutput2[$i]|\n";} + if ($DB) {print "ip_relay RUNNING: |$psoutput[$i]|\n";} } if ($psline[1] =~ /$REGhome\/AST_conf_update_3way\.pl/) { $runningAST_conf_3way++; if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";} } + $i++; } - if ( ($AST_update > 0) && ($runningAST_update < 1) ) - { - if ($DB) {print "starting AST_update...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTupdate $PATHhome/AST_update.pl`; - } - if ( ($AST_send_listen > 0) && ($runningAST_send < 1) ) - { - if ($DB) {print "starting AST_manager_send...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTsend $PATHhome/AST_manager_send.pl`; - } - if ( ($AST_send_listen > 0) && ($runningAST_listen < 1) ) - { - if ($DB) {print "starting AST_manager_listen...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listen.pl`; - } - if ( ($AST_VDauto_dial > 0) && ($runningAST_VDauto_dial < 1) ) - { - if ($DB) {print "starting AST_VDauto_dial...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTVDauto $PATHhome/AST_VDauto_dial.pl $autodial_delay`; - } - if ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) - { - 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`; - } - if ( ($AST_VDadapt > 0) && ($runningAST_VDadapt < 1) ) - { - if ($DB) {print "starting AST_VDadapt...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTVDadapt $PATHhome/AST_VDadapt.pl --debug`; - } - if ( ($FastAGI_log > 0) && ($runningFastAGI_log < 1) ) - { - if ($DB) {print "starting FastAGI_log...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTfastlog $PATHhome/FastAGI_log.pl --debug`; - } - if ( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) - { - 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`; - } - if ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) - { - if ($DB) {print "starting VD_email_inbound...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTemail $PATHhome/VD_email_inbound.pl`; - } - if ( ($ip_relay > 0) && ($runningip_relay < 1) ) - { - if ($DB) {print "starting ip_relay through relay_control...\n";} - `$PATHhome/ip_relay/relay_control start 2>/dev/null 1>&2`; - } - if ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) - { - if ($DB) {print "starting AST_conf_3way...\n";} - # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTconf3way $PATHhome/AST_conf_update_3way.pl --debug $cu3way_delay`; + + + + ##### Second, IF MORE THAN ONE LISTEN INSTANCE IS RUNNING, KILL THE SECOND ONE ##### + @psline=@MT; + @psoutput=@MT; + @listen_pid=@MT; + if ($runningAST_listen > 1) + { + $runningAST_listen=0; + + sleep(1); + + ### you may have to use a different ps command if you're not using Slackware Linux + # @psoutput = `ps -f -C AST_update --no-headers`; + # @psoutput = `ps -f -C AST_updat* --no-headers`; + # @psoutput = `/bin/ps -f --no-headers -A`; + # @psoutput = `/bin/ps -o pid,args -A`; ### use this one for FreeBSD + @psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + + $i=0; + foreach (@psoutput) + { + chomp($psoutput[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + $psoutput[$i] =~ s/^ *//gi; + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + + if ($psline[1] =~ /AST_manager_li/) + { + $listen_pid[$runningAST_listen] = $psoutput[$i]; + if ($DB) {print "AST_listen RUNNING: |$psline[1]|$listen_pid[$runningAST_listen]|\n";} + $runningAST_listen++; + } + + $i++; + } + + if ($runningAST_listen > 1) + { + if ($DB) {print "Killing AST_manager_listen... |$listen_pid[1]|\n";} + `/bin/kill -s 9 $listen_pid[1]`; + } } + + + + + + + ##### Third, double-check that non-running scripts are not running ##### + @psline=@MT; + @psoutput=@MT; + + if ( + ( ($AST_update > 0) && ($runningAST_update < 1) ) || + ( ($AST_send_listen > 0) && ($runningAST_send < 1) ) || + ( ($AST_send_listen > 0) && ($runningAST_listen < 1) ) || + ( ($AST_VDauto_dial > 0) && ($runningAST_VDauto_dial < 1) ) || + ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) || + ( ($AST_VDadapt > 0) && ($runningAST_VDadapt < 1) ) || + ( ($FastAGI_log > 0) && ($runningFastAGI_log < 1) ) || + ( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) || + ( ($ip_relay > 0) && ($runningip_relay < 1) ) || + ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) || + ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) + ) + { + + if ($DB) {print "double check that processes are not running...\n";} + + sleep(1); + + #`PERL5LIB="$PATHhome/libs"; export PERL5LIB`; # issue #457 + $ENV{'PERL5LIB'} = "$PATHhome/libs"; + ### you may have to use a different ps command if you're not using Slackware Linux + # @psoutput = `ps -f -C AST_update --no-headers`; + # @psoutput = `ps -f -C AST_updat* --no-headers`; + # @psoutput = `/bin/ps -f --no-headers -A`; + # @psoutput = `/bin/ps -o pid,args -A`; ### use this one for FreeBSD + @psoutput2 = `/bin/ps -o "%p %a" --no-headers -A`; + $i=0; + foreach (@psoutput2) + { + chomp($psoutput2[$i]); + if ($DBX) {print "$i|$psoutput2[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + + if ($psoutput2[$i] =~ /bin\/asterisk/) + { + $runningASTERISK++; + if ($DB) {print "asterisk RUNNING: |$psoutput2[$i]|\n";} + } + if ($psline[1] =~ /$REGhome\/AST_update\.pl/) + { + $runningAST_update++; + if ($DB) {print "AST_update RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /AST_manager_se/) + { + $runningAST_send++; + if ($DB) {print "AST_send RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /AST_manager_li/) + { + $runningAST_listen++; + if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/) + { + $runningAST_VDauto_dial++; + if ($DB) {print "AST_VDauto_dial RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /$REGhome\/AST_VDremote_agents\.pl/) + { + $runningAST_VDremote_agents++; + if ($DB) {print "AST_VDremote_agents RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /$REGhome\/AST_VDadapt\.pl/) + { + $runningAST_VDadapt++; + if ($DB) {print "AST_VDadapt RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /$REGhome\/FastAGI_log\.pl/) + { + $runningFastAGI_log++; + if ($DB) {print "FastAGI_log RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /$REGhome\/AST_VDauto_dial_FILL\.pl/) + { + $runningAST_VDauto_dial_FILL++; + if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";} + } + if ($psline[1] =~ /$REGhome\/VD_email_inbound\.pl/) + { + $runningemail_inbound++; + if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";} + } + if ($psoutput2[$i] =~ / ip_relay /) + { + $runningip_relay++; + if ($DB) {print "ip_relay RUNNING: |$psoutput2[$i]|\n";} + } + if ($psline[1] =~ /$REGhome\/AST_conf_update_3way\.pl/) + { + $runningAST_conf_3way++; + if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";} + } + $i++; + } + + + if ( ($AST_update > 0) && ($runningAST_update < 1) ) + { + if ($DB) {print "starting AST_update...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTupdate $PATHhome/AST_update.pl`; + } + if ( ($AST_send_listen > 0) && ($runningAST_send < 1) ) + { + if ($DB) {print "starting AST_manager_send...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTsend $PATHhome/AST_manager_send.pl`; + } + if ( ($AST_send_listen > 0) && ($runningAST_listen < 1) ) + { + if ($DB) {print "starting AST_manager_listen...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listen.pl`; + } + if ( ($AST_VDauto_dial > 0) && ($runningAST_VDauto_dial < 1) ) + { + if ($DB) {print "starting AST_VDauto_dial...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTVDauto $PATHhome/AST_VDauto_dial.pl $autodial_delay`; + } + if ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) + { + 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`; + } + if ( ($AST_VDadapt > 0) && ($runningAST_VDadapt < 1) ) + { + if ($DB) {print "starting AST_VDadapt...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTVDadapt $PATHhome/AST_VDadapt.pl --debug`; + } + if ( ($FastAGI_log > 0) && ($runningFastAGI_log < 1) ) + { + if ($DB) {print "starting FastAGI_log...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTfastlog $PATHhome/FastAGI_log.pl --debug`; + } + if ( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) + { + 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`; + } + if ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) + { + if ($DB) {print "starting VD_email_inbound...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTemail $PATHhome/VD_email_inbound.pl`; + } + if ( ($ip_relay > 0) && ($runningip_relay < 1) ) + { + if ($DB) {print "starting ip_relay through relay_control...\n";} + `$PATHhome/ip_relay/relay_control start 2>/dev/null 1>&2`; + } + if ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) + { + if ($DB) {print "starting AST_conf_3way...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTconf3way $PATHhome/AST_conf_update_3way.pl --debug $cu3way_delay`; + } + } } - ### run the Timeclock auto-logout process ### if ($timeclock_auto_logout > 0) { @@ -1279,7 +1299,7 @@ $sthA->finish(); if ($DBXXX > 0) {print "SYSTEM SETTINGS: $sounds_central_control_active|$active_voicemail_server|$SScustom_dialplan_entry|$SSdefault_codecs\n";} ##### Get the settings for this server's server_ip ##### -$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update,conf_secret,custom_dialplan_entry FROM servers where server_ip='$server_ip';"; +$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update,conf_secret,custom_dialplan_entry,auto_restart_asterisk,asterisk_temp_no_restart FROM servers where server_ip='$server_ip';"; # print "$stmtA\n"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1294,6 +1314,8 @@ if ($sthArows > 0) $sounds_update = $aryA[4]; $self_conf_secret = $aryA[5]; $SERVERcustom_dialplan_entry = $aryA[6]; + $auto_restart_asterisk = $aryA[7]; + $asterisk_temp_no_restart = $aryA[8]; } $sthA->finish(); @@ -3151,6 +3173,115 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r +################################################################################ +##### BEGIN Find system uptime and update server record with the data +################################################################################ +$uptimebin = ''; +$system_uptime=''; +$recent_reboot=0; + +### find uptime binary +if ( -e ('/bin/uptime')) {$uptimebin = '/bin/uptime';} +else + { + if ( -e ('/usr/bin/uptime')) {$uptimebin = '/usr/bin/uptime';} + else + { + if ( -e ('/usr/local/bin/uptime')) {$uptimebin = '/usr/local/bin/uptime';} + else + { + print "Can't find uptime binary! Exiting...\n"; + } + } + } + +if (length($uptimebin)>3) + { + @sysuptime = `$uptimebin`; + # 18:26:14 up 153 days, 23:59, 4 users, load average: 0.01, 0.01, 0.00 + # 10:03am up 123 days 0:10, 1 user, load average: 0.11, 0.05, 0.01 + # 10:03am up 3:17, 2 users, load average: 0.41, 0.28, 0.21 + + if ($DBX) {print "Uptime debug 1: |$sysuptime[0]|\n";} + $sysuptime[0] =~ s/ days, / days /gi; + $sysuptime[0] =~ s/,.*//gi; + $sysuptime[0] =~ s/ / /gi; + $sysuptime[0] =~ s/ / /gi; + $sysuptime[0] =~ s/\r|\n|\t//gi; + @uptimedata = split(/ up /,$sysuptime[0]); + $system_uptime = $uptimedata[1]; + + # If server was just restarted, reset the temp-no-restart setting to N + $asterisk_temp_no_restartSQL=''; + if ($system_uptime =~ /^0:00|^0:01|^0:02|^0:03|^0:04|^0:05/) + { + $asterisk_temp_no_restartSQL=",asterisk_temp_no_restart='N'"; + $recent_reboot++; + } + if ($DBX) {print "Uptime debug 2: |$sysuptime[0]|$system_uptime|$recent_reboot|\n";} + + $stmtA = "UPDATE servers SET system_uptime='$system_uptime' $asterisk_temp_no_restartSQL where server_ip='$server_ip';"; + $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + if ($DBX) {print "Uptime debug 3: |$affected_rows|$stmtA|\n";} + } +################################################################################ +##### END Find system uptime and update server record with the data +################################################################################ + + +################################################################################ +##### BEGIN Confirm Asterisk is running, and if not restart it from the screen +################################################################################ +if ($DBX > 0) + {print "CONFIRM ASTERISK IS RUNNING: |$active_asterisk_server|$runningASTERISK|$auto_restart_asterisk|$asterisk_temp_no_restart|$recent_reboot|\n";} +if ($active_asterisk_server =~ /Y/) + { + if ( ($runningASTERISK < 1) && ($auto_restart_asterisk =~ /Y/) && ($asterisk_temp_no_restart =~ /N/) && ($recent_reboot < 1) ) + { + $asteriskSCREEN=0; + @screenoutput = `/usr/bin/screen -ls`; + + $i=0; + foreach (@screenoutput) + { + chomp($screenoutput[$i]); + if ($DBX) {print "$i|$screenoutput[$i]| \n";} + if ($screenoutput[$i] =~ /\.asterisk/) + { + $asteriskSCREEN++; + if ($DB) {print "asterisk screen session open: |$screenoutput[$i]|\n";} + } + $i++; + } + + if ($asteriskSCREEN > 0) + { + if ($DB) {print "restarting Asterisk process...\n";} + $stmtA="INSERT INTO vicidial_admin_log set event_date=NOW(), user='VDAD', ip_address='1.1.1.1', event_section='SERVERS', event_type='RESET', record_id='$server_ip', event_code='AUTO RESTART ASTERISK', event_sql='', event_notes='$system_uptime system uptime';"; + $Iaffected_rows = $dbhA->do($stmtA); + if ($DBX) {print "Restart asterisk debug 1: |$Iaffected_rows|$stmtA|\n";} + + `screen -XS asterisk eval 'stuff "/usr/sbin/asterisk -vvvvgcT\015"'`; + } + else + { + if ($DB) {print "starting Asterisk process...\n";} + $stmtA="INSERT INTO vicidial_admin_log set event_date=NOW(), user='VDAD', ip_address='1.1.1.1', event_section='SERVERS', event_type='RESET', record_id='$server_ip', event_code='AUTO START ASTERISK', event_sql='', event_notes='$system_uptime system uptime';"; + $Iaffected_rows = $dbhA->do($stmtA); + if ($DBX) {print "Restart asterisk debug 1: |$Iaffected_rows|$stmtA|\n";} + + `$PATHhome/start_asterisk_boot.pl`; + } + } + } +################################################################################ +##### END Confirm Asterisk is running, and if not restart it from the screen +################################################################################ + + + + + ################################################################################ ##### BEGIN Audio Store sync @@ -3330,52 +3461,52 @@ exit; sub leading_zero($) -{ + { $_ = $_[0]; s/^(\d)$/0$1/; s/^(\d\d)$/0$1/; return $_; -} # End of the leading_zero() routine. + } # End of the leading_zero() routine. # subroutine to parse the asterisk version # and return a hash with the various part sub parse_asterisk_version -{ - # grab the arguments - my $ast_ver_str = $_[0]; + { + # grab the arguments + my $ast_ver_str = $_[0]; - # get everything after the - and put it in $ast_ver_postfix - my @hyphen_parts = split( /-/ , $ast_ver_str ); + # get everything after the - and put it in $ast_ver_postfix + my @hyphen_parts = split( /-/ , $ast_ver_str ); - my $ast_ver_postfix = $hyphen_parts[1]; + my $ast_ver_postfix = $hyphen_parts[1]; - # now split everything before the - up by the . - my @dot_parts = split( /\./ , $hyphen_parts[0] ); + # now split everything before the - up by the . + my @dot_parts = split( /\./ , $hyphen_parts[0] ); - my %ast_ver_hash; + my %ast_ver_hash; - if ( $dot_parts[0] <= 1 ) + if ( $dot_parts[0] <= 1 ) { - %ast_ver_hash = ( - "major" => $dot_parts[0], - "minor" => $dot_parts[1], - "build" => $dot_parts[2], - "revision" => $dot_parts[3], - "postfix" => $ast_ver_postfix - ); + %ast_ver_hash = ( + "major" => $dot_parts[0], + "minor" => $dot_parts[1], + "build" => $dot_parts[2], + "revision" => $dot_parts[3], + "postfix" => $ast_ver_postfix + ); } - # digium dropped the 1 from asterisk 10 but we still need it - if ( $dot_parts[0] > 1 ) + # digium dropped the 1 from asterisk 10 but we still need it + if ( $dot_parts[0] > 1 ) { - %ast_ver_hash = ( - "major" => 1, - "minor" => $dot_parts[0], - "build" => $dot_parts[1], - "revision" => $dot_parts[2], - "postfix" => $ast_ver_postfix - ); + %ast_ver_hash = ( + "major" => 1, + "minor" => $dot_parts[0], + "build" => $dot_parts[1], + "revision" => $dot_parts[2], + "postfix" => $ast_ver_postfix + ); } - return ( %ast_ver_hash ); -} + return ( %ast_ver_hash ); + } diff --git a/bin/AST_VDadapt.pl b/bin/AST_VDadapt.pl index deda2665..c66788f5 100644 --- a/bin/AST_VDadapt.pl +++ b/bin/AST_VDadapt.pl @@ -1,12 +1,12 @@ #!/usr/bin/perl # -# AST_VDadapt.pl version 2.4 +# AST_VDadapt.pl version 2.8 # # DESCRIPTION: # adjusts the auto_dial_level for vicidial adaptive-predictive campaigns. # gather call stats for campaigns and in-groups # -# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # 60823-1302 - First build from AST_VDhopper.pl @@ -38,6 +38,7 @@ # 111103-0626 - Added MAXCAL as a drop status # 111219-1420 - Added daily stats updates to new table for total, in-group and campaign # 111223-0924 - Added check for logged-in agents +# 131122-1314 - Added several missing sthA->finish # # constants @@ -286,10 +287,12 @@ if ($DBX) {print "CONNECTED TO DATABASE: $VARDB_server|$VARDB_database\n";} $stmtA = "INSERT IGNORE into vicidial_campaign_stats (campaign_id) select campaign_id from vicidial_campaigns;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthA->finish(); $stmtA = "INSERT IGNORE into vicidial_campaign_stats_debug (campaign_id,server_ip) select campaign_id,'ADAPT' from vicidial_campaigns;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthA->finish(); &get_time_now; @@ -467,6 +470,7 @@ while ($master_loop < $CLIloops) if ($DBXXX) {print " |$stmtA|\n";} } $sthA->finish(); + ### Find out how many agents are logged in to a specific campaign $stmtA = "SELECT count(*) from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -481,6 +485,7 @@ while ($master_loop < $CLIloops) if ($DBXXX) {print " |$stmtA|\n";} } $sthA->finish(); + $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]|$diff_ratio_updater|$drop_count_updater|"; if ($DBX) {print "$i $event_string\n";} $debug_camp_output .= "$i $event_string\n"; @@ -881,6 +886,7 @@ sub calculate_drops $rec_count++; } $sthA->finish(); + chop($camp_ANS_STAT_SQL); $debug_camp_output .= " CAMPAIGN ANSWERED STATUSES: $campaign_id[$i]|$camp_ANS_STAT_SQL|\n"; @@ -928,6 +934,7 @@ sub calculate_drops $VCScalls_one[$i] = $aryA[0]; } $sthA->finish(); + if ($VCScalls_one[$i] > 0) { # LAST MINUTE ANSWERS @@ -941,6 +948,7 @@ sub calculate_drops $VCSanswers_one[$i] = $aryA[0]; } $sthA->finish(); + # LAST MINUTE DROPS $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -970,6 +978,7 @@ sub calculate_drops $VCScalls_today[$i] = $aryA[0]; } $sthA->finish(); + if ($VCScalls_today[$i] > 0) { # TODAY ANSWERS @@ -983,6 +992,7 @@ sub calculate_drops $VCSanswers_today[$i] = $aryA[0]; } $sthA->finish(); + # TODAY DROPS $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1016,6 +1026,7 @@ sub calculate_drops $VCScalls_hour[$i] = $aryA[0]; } $sthA->finish(); + if ($VCScalls_hour[$i] > 0) { # ANSWERS LAST HOUR @@ -1029,6 +1040,7 @@ sub calculate_drops $VCSanswers_hour[$i] = $aryA[0]; } $sthA->finish(); + # DROP LAST HOUR $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1059,6 +1071,7 @@ sub calculate_drops $VCScalls_halfhour[$i] = $aryA[0]; } $sthA->finish(); + if ($VCScalls_halfhour[$i] > 0) { # ANSWERS HALFHOUR @@ -1072,6 +1085,7 @@ sub calculate_drops $VCSanswers_halfhour[$i] = $aryA[0]; } $sthA->finish(); + # DROPS HALFHOUR $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1115,6 +1129,7 @@ sub calculate_drops $VCSanswers_five[$i] = $aryA[0]; } $sthA->finish(); + # DROPS FIVEMINUTE $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1169,6 +1184,8 @@ sub calculate_drops $CATstatusesSQL .= "'$aryA[0]',"; $rec_count++; } + $sthA->finish(); + # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory' and campaign_id='$campaign_id[$i]';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1181,6 +1198,8 @@ sub calculate_drops $CATstatusesSQL .= "'$aryA[0]',"; $rec_count++; } + $sthA->finish(); + chop($CATstatusesSQL); if (length($CATstatusesSQL) > 2) { @@ -1195,6 +1214,7 @@ sub calculate_drops @aryA = $sthA->fetchrow_array; $VSCtally = $aryA[0]; } + $sthA->finish(); } $g++; $debug_camp_output .= " $campaign_id[$i]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n"; @@ -1271,6 +1291,7 @@ sub calculate_drops $VCSagent_custtalk_today[$i] = $aryA[2]; $VCSagent_acw_today[$i] = $aryA[3]; } + $sthA->finish(); $stmtA = "SELECT count(*) from vicidial_agent_log where event_time > '$VDL_date' and campaign_id='$campaign_id[$i]' and lead_id > 0;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1283,7 +1304,6 @@ sub calculate_drops if ($DBX) {print " AGENT CALLS: $aryA[0]|$stmtA\n";} $VCSagent_calls_today[$i] = $aryA[0]; } - $sthA->finish(); } @@ -1474,7 +1494,6 @@ sub launch_max_calls_gather @aryA = $sthA->fetchrow_array; $tcalls_count = $aryA[0]; } - $sthA->finish(); $stmtA = "SELECT count(*) from vicidial_auto_calls where call_type='IN' and server_ip IN($serversSQL);"; @@ -1510,8 +1529,8 @@ sub launch_max_calls_gather { @aryA = $sthA->fetchrow_array; $live_agents = $aryA[0]; - $sthA->finish(); } + $sthA->finish(); $stmtA = "SELECT count(*) from vicidial_live_agents where last_update_time > '$VDL_one' and extension LIKE \"R/%\" and server_ip IN($serversSQL);"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1522,8 +1541,8 @@ sub launch_max_calls_gather { @aryA = $sthA->fetchrow_array; $live_remote_agents = $aryA[0]; - $sthA->finish(); } + $sthA->finish(); if ($DB) {print "$now_date MAX CHANNELS TOTALS: $tc_count($lsc_count+$lc_count)|$tcalls_count|$incalls_count|$outcalls_count|$live_agents|$live_remote_agents\n";} @@ -1692,8 +1711,8 @@ sub calculate_drops_inbound { @aryA = $sthA->fetchrow_array; $iVCSlive_calls[$p] = $aryA[0]; - $sthA->finish(); } + $sthA->finish(); $stmtA = "SELECT count(*) from vicidial_live_agents where closer_campaigns LIKE \"% $group_id[$p] %\" and last_update_time > '$VDL_one';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1703,8 +1722,8 @@ sub calculate_drops_inbound { @aryA = $sthA->fetchrow_array; $itotal_agents[$p] = $aryA[0]; - $sthA->finish(); } + $sthA->finish(); $stmtA = "SELECT count(*) from vicidial_live_agents where closer_campaigns LIKE \"% $group_id[$p] %\" and last_update_time > '$VDL_one' and extension LIKE \"R/%\";"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1714,8 +1733,8 @@ sub calculate_drops_inbound { @aryA = $sthA->fetchrow_array; $itotal_remote_agents[$p] = $aryA[0]; - $sthA->finish(); } + $sthA->finish(); $debug_ingroup_output .= " DAILY STATS|$iVCSlive_calls[$p]|$itotal_agents[$p]|$itotal_remote_agents[$p]|"; } @@ -1730,6 +1749,7 @@ sub calculate_drops_inbound $iVCScalls_today[$p] = $aryA[0]; } $sthA->finish(); + if ($iVCScalls_today[$p] > 0) { # TODAY ANSWERS @@ -1743,6 +1763,7 @@ sub calculate_drops_inbound $iVCSanswers_today[$p] = $aryA[0]; } $sthA->finish(); + # TODAY DROPS $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1775,6 +1796,7 @@ sub calculate_drops_inbound $answer_sec_pct_rt_stat_one_PCT[$p] = $aryA[0]; } $sthA->finish(); + $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1784,6 +1806,7 @@ sub calculate_drops_inbound @aryA = $sthA->fetchrow_array; $answer_sec_pct_rt_stat_two_PCT[$p] = $aryA[0]; } + $sthA->finish(); # TODAY TOTAL HOLD TIME FOR ANSWERED CALLS $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL');"; @@ -1796,6 +1819,8 @@ sub calculate_drops_inbound if ($aryA[0] > 0) {$hold_sec_answer_calls[$p] = $aryA[0];} } + $sthA->finish(); + # TODAY TOTAL HOLD TIME FOR DROP CALLS $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1807,6 +1832,8 @@ sub calculate_drops_inbound if ($aryA[0] > 0) {$hold_sec_drop_calls[$p] = $aryA[0];} } + $sthA->finish(); + # TODAY TOTAL QUEUE TIME FOR QUEUE CALLS $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1818,6 +1845,7 @@ sub calculate_drops_inbound if ($aryA[0] > 0) {$hold_sec_queue_calls[$p] = $aryA[0];} } + $sthA->finish(); } @@ -1856,6 +1884,8 @@ sub calculate_drops_inbound $CATstatusesSQL .= "'$aryA[0]',"; $rec_count++; } + $sthA->finish(); + # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1868,6 +1898,8 @@ sub calculate_drops_inbound $CATstatusesSQL .= "'$aryA[0]',"; $rec_count++; } + $sthA->finish(); + chop($CATstatusesSQL); if (length($CATstatusesSQL)>2) { @@ -1882,6 +1914,7 @@ sub calculate_drops_inbound @aryA = $sthA->fetchrow_array; $VSCtally = $aryA[0]; } + $sthA->finish(); } $g++; if ($DBX) {print " $group_id[$p]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n";} diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index 4a8898d6..265eb51f 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -114,6 +114,7 @@ # 130706-2024 - Added disable_auto_dial system option # 130811-1403 - Fix for issue #690 # 131016-0659 - Fix for disable_auto_dial system option +# 131122-1233 - Added several missing sthA->finish # @@ -514,6 +515,7 @@ while($one_day_interval > 0) { $DBIPINCALLcount[$user_CIPct]++; } + $sthA->finish(); } } $user_counter++; @@ -529,6 +531,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $DBIPcampaign_ready_agents[$user_CIPct] = $aryA[0]; } + $sthA->finish(); ### check for vicidial_campaign_server_stats record, if non present then create it $stmtA = "SELECT local_trunk_shortage FROM vicidial_campaign_server_stats where campaign_id='$DBIPcampaign[$user_CIPct]' and server_ip='$server_ip';"; @@ -542,6 +545,8 @@ while($one_day_interval > 0) $DBIPold_trunk_shortage[$user_CIPct] = $aryA[0]; $rec_count++; } + $sthA->finish(); + if ($rec_count < 1) { $stmtA = "INSERT INTO vicidial_campaign_server_stats SET local_trunk_shortage='0', server_ip='$server_ip',campaign_id='$DBIPcampaign[$user_CIPct]';"; @@ -569,6 +574,8 @@ while($one_day_interval > 0) $DBIPserver_trunks_limit[$user_CIPct] = $aryA[0]; $rec_count++; } + $sthA->finish(); + $stmtA = "SELECT sum(dedicated_trunks) FROM vicidial_server_trunks where campaign_id NOT IN('$DBIPcampaign[$user_CIPct]') and server_ip='$server_ip';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -580,6 +587,7 @@ while($one_day_interval > 0) $DBIPserver_trunks_other[$user_CIPct] = $aryA[0]; $rec_count++; } + $sthA->finish(); $DBIPserver_trunks_allowed[$user_CIPct] = ($max_vicidial_trunks - $DBIPserver_trunks_other[$user_CIPct]); @@ -1193,6 +1201,8 @@ while($one_day_interval > 0) $stmtA="UPDATE vicidial_campaign_cid_areacodes set call_count_today=(call_count_today + 1) where campaign_id='$DBIPcampaign[$user_CIPct]' and areacode='$temp_ac' and outbound_cid='$temp_vcca';"; $affected_rows = $dbhA->do($stmtA); } + else + {$sthA->finish();} $temp_CID = $temp_vcca; $temp_CID =~ s/\D//gi; if (length($temp_CID) > 6) @@ -1390,6 +1400,7 @@ while($one_day_interval > 0) $rec_count++; } $sthA->finish(); + $stmtA = "SELECT user FROM vicidial_live_agents where callerid='$KLcallerid[$kill_vac]'"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1400,6 +1411,7 @@ while($one_day_interval > 0) $CLuser = $aryA[0]; } $sthA->finish(); + if ( (length($CLlead_id) < 1) || ($CLlead_id < 1) ) { $CLlead_id = $KLcallerid[$kill_vac]; @@ -1498,7 +1510,6 @@ while($one_day_interval > 0) { @aryA = $sthA->fetchrow_array; $cpd_result = $aryA[0]; - $sthA->finish(); $CPDfound=0; if ($cpd_result =~ /Busy/i) {$CLnew_status='CPDB'; $CPDfound++;} if ($cpd_result =~ /Unknown/i) {$CLnew_status='CPDUK'; $CPDfound++;} @@ -1516,6 +1527,7 @@ while($one_day_interval > 0) if ($cpd_result =~ /Fax|Modem/i) {$CLnew_status='AFAX'; $CPDfound++;} if ($cpd_result =~ /Answering-Machine/i) {$CLnew_status='AA'; $CPDfound++;} } + $sthA->finish(); ############################################################## ### END - CPD Look for result for NA/B/DC calls @@ -1862,6 +1874,7 @@ while($one_day_interval > 0) $VD_list_id = $aryA[2]; } $sthA->finish(); + $alt_dial_phones_count=0; $stmtA="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$CLlead_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -2442,6 +2455,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $multi_alt_count = $aryA[0]; } + $sthA->finish(); if ($multi_alt_count > 0) { @@ -2463,6 +2477,7 @@ while($one_day_interval > 0) $MLaad_statuses[$MLcamp_count] = $aryA[1]; $MLcamp_count++; } + $sthA->finish(); $MLcamp_count=0; foreach(@MLcamp_id) @@ -2479,6 +2494,7 @@ while($one_day_interval > 0) $MLlists[$MLcamp_count] .= "'$aryA[0]',"; $MLlist_count++; } + $sthA->finish(); $MLlists[$MLcamp_count] =~ s/,$//gi; if (length($MLlists[$MLcamp_count]) < 2) {$MLlists[$MLcamp_count]="''";} @@ -2537,6 +2553,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $vac_count = $aryA[0]; } + $sthA->finish(); if ($vac_count < 1) { @@ -2549,6 +2566,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $MLcampaign[$vle_count] = $aryA[0]; $MLstatus[$vle_count] = $aryA[1]; + $sthA->finish(); if ($MLcampaigns =~ /\|$MLcampaign[$vle_count]\|/i) { @@ -2585,6 +2603,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $MLvlc[$vle_count] = $aryA[0]; } + $sthA->finish(); if (length($MLvlc[$vle_count]) > 1) { @@ -2600,6 +2619,8 @@ while($one_day_interval > 0) $MLnonmatch_leadids .= "'$aryA[0]',"; $MLnm_count++; } + $sthA->finish(); + if ($MLnm_count > 0) { chop($MLnonmatch_leadids); @@ -2661,6 +2682,7 @@ while($one_day_interval > 0) } else { + $sthA->finish(); $event_string = " ML no log entry, do nothing: $MLcallerid[$vle_count]|$MLuniqueid[$vle_count]"; &event_logger; } @@ -2699,6 +2721,8 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $ncu_count = $aryA[0]; } + $sthA->finish(); + $stmtA = "SELECT count(*) FROM vicidial_inbound_groups where na_call_url IS NOT NULL and na_call_url!='' and group_calldate > \"$RMSQLdate\";"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -2708,6 +2732,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $ncu_in_count = $aryA[0]; } + $sthA->finish(); if ( ($ncu_count > 0) || ($ncu_in_count > 0) ) { @@ -2732,6 +2757,7 @@ while($one_day_interval > 0) $NCUcamp_count++; $ncu_total_count++; } + $sthA->finish(); } if ($ncu_in_count > 0) { @@ -2749,6 +2775,7 @@ while($one_day_interval > 0) $NCUig_count++; $ncu_total_count++; } + $sthA->finish(); } $event_string = " NA-CALL-URL check: $ncu_total_count active, checking unprocessed calls..."; &event_logger; @@ -2801,6 +2828,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $vac_count = $aryA[0]; } + $sthA->finish(); if ($vac_count < 1) { @@ -2825,6 +2853,7 @@ while($one_day_interval > 0) $NCUuser[$vle_count] = $aryA[2]; $NCUphone[$vle_count] = $aryA[3]; $NCUaltdial[$vle_count] = $aryA[4]; + $sthA->finish(); if ($NCUcampaigns =~ /\|$NCUcampaign[$vle_count]\|/i) { @@ -2905,6 +2934,7 @@ while($one_day_interval > 0) } else { + $sthA->finish(); $event_string = " NCU no log entry, do nothing: $NCUcallerid[$vle_count]|$NCUuniqueid[$vle_count]"; &event_logger; } @@ -2991,6 +3021,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $vac_count = $aryA[0]; } + $sthA->finish(); if ($vac_count < 1) { $stmtA = "SELECT status FROM vicidial_log where uniqueid='$MLuniqueid[$vle_count]' and lead_id='$MLleadid[$vle_count]' and call_date > \"$RMSQLdate\";"; @@ -3001,6 +3032,7 @@ while($one_day_interval > 0) { @aryA = $sthA->fetchrow_array; $MLstatus[$vle_count] = $aryA[0]; + $sthA->finish(); if ($MLincall !~ /\|$MLstatus[$vle_count]\|/i) { @@ -3031,6 +3063,7 @@ while($one_day_interval > 0) $event_string = " VNA ERROR: $MLcallerid[$vle_count]|$MLuniqueid[$vle_count]|$MLleadid[$vle_count]"; &event_logger; } + $sthA->finish(); } else { @@ -3064,6 +3097,7 @@ while($one_day_interval > 0) } else { + $sthA->finish(); $event_string = " VNA status no vicidial_log record, do nothing: $MLcallerid[$vle_count]|$MLuniqueid[$vle_count]|$MLstatus[$vle_count]"; &event_logger; } diff --git a/bin/AST_VDauto_dial_FILL.pl b/bin/AST_VDauto_dial_FILL.pl index c7f27d76..b257e572 100644 --- a/bin/AST_VDauto_dial_FILL.pl +++ b/bin/AST_VDauto_dial_FILL.pl @@ -36,6 +36,7 @@ # 130227-1604 - Cleanup of staggered code, resetting of variables and arrays # 130706-2024 - Added disable_auto_dial system option # 131016-0658 - Fix for disable_auto_dial system option +# 131122-1237 - Formatting fixes and missing sthA->finish # ### begin parsing run-time options ### @@ -51,6 +52,7 @@ if (length($ARGV[0])>1) if ($args =~ /--help/i) { print "allowed run time options:\n"; + print " [--help] = this screen\n"; print " [--test] = test\n"; print " [--debug] = verbose debug messages\n"; print " [--staggered] = experimental staggering of placing calls on large multi-server systems\n"; @@ -381,6 +383,7 @@ while($one_day_interval > 0) $VAC_balance_fill = $aryA[0]; } $sthA->finish(); + $DBfill_current_balance[$camp_CIPct] = "$VAC_balance_fill"; $event_string=" CAMPAIGN: $DBfill_campaign[$camp_CIPct]\n"; @@ -406,6 +409,7 @@ while($one_day_interval > 0) $rec_count++; } $sthA->finish(); + chop($full_serversSQL); if (length($full_serversSQL)<6) {$full_serversSQL="''";} $event_string.="SERVERS WITH TRUNK FULL for $DBfill_campaign[$camp_CIPct]: $full_servers |$full_serversSQL|"; @@ -561,7 +565,6 @@ while($one_day_interval > 0) $event_string.=" Campaign Dial Fill tally: $DBfill_tally[$camp_CIPct]/$DBfill_needed[$camp_CIPct]"; &event_logger; - $stmtA = "SELECT count(*) FROM vicidial_live_agents where campaign_id='$DBfill_campaign[$camp_CIPct]' and status NOT IN('PAUSED');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -784,6 +787,8 @@ while($one_day_interval > 0) $stmtA="UPDATE vicidial_campaign_cid_areacodes set call_count_today=(call_count_today + 1) where campaign_id='$DBfill_campaign[$camp_CIPct]' and areacode='$temp_ac' and outbound_cid='$temp_vcca';"; $affected_rows = $dbhA->do($stmtA); } + else + {$sthA->finish();} $temp_CID = $temp_vcca; $temp_CID =~ s/\D//gi; if (length($temp_CID) > 6) @@ -1012,7 +1017,6 @@ while($one_day_interval > 0) $camp_CIPct++; } - } ################################################################################## ##### END LOOP IF THERE ARE BALANCE SERVERS AND THERE ARE SHORTAGES @@ -1030,7 +1034,6 @@ while($one_day_interval > 0) - &get_time_now; @@ -1052,7 +1055,7 @@ while($one_day_interval > 0) ### sleep for 2 and a half seconds before beginning the loop again usleep(1*$loop_delay*1000); - $endless_loop--; + $endless_loop--; if($DB){print STDERR "\nloop counter: |$endless_loop|\n";} ### putting a blank file called "VDADfull.kill" in the directory will automatically safely kill this program @@ -1066,18 +1069,18 @@ while($one_day_interval > 0) if ($endless_loop =~ /0$/) # run every ten cycles (about 25 seconds) { ### Grab Server values from the database - $stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';"; - $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; - $DBvd_server_logs = $aryA[0]; - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - else {$SYSLOG = '0';} - } - $sthA->finish(); + $stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';"; + $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; + $DBvd_server_logs = $aryA[0]; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + } + $sthA->finish(); ### Grab Server values from the database in case they've changed $stmtA = "SELECT max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';"; @@ -1113,7 +1116,6 @@ while($one_day_interval > 0) &event_logger; $one_day_interval--; - } $event_string='CLOSING DB CONNECTION|'; @@ -1219,9 +1221,6 @@ sub get_time_now #get the current date and time and epoch for logging call lengt } - - - sub event_logger { if ($DB) {print "$now_date|$event_string|\n";} diff --git a/bin/AST_VDremote_agents.pl b/bin/AST_VDremote_agents.pl index 98263165..84748780 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.6 +# AST_VDremote_agents.pl version 2.8 # # SUMMARY: # To use VICIDIAL with remote agents, this must always be running @@ -46,6 +46,7 @@ # 120213-1701 - Added remote-agent daily stats # 121129-1929 - Fix for issue #601, reported by Acidshock # 130322-1939 - Changed to auto-terminate vars to one day so it can restart for systems that don't reboot nightly +# 131122-1104 - Small fixes and formatting changes # ### begin parsing run-time options ### @@ -60,9 +61,13 @@ if (length($ARGV[0])>1) if ($args =~ /--help/i) { print "allowed run time options:\n"; - print " [-t] = test\n"; - print " [-v] = verbose debug messages\n"; - print " [--delay=XXX] = delay of XXX seconds per loop, default 2 seconds\n\n"; + print " [--help] = this screen\n"; + print " [--test] = test\n"; + print " [--debug] = verbose debug messages\n"; + print " [--debugX] = extra verbose debug messages\n"; + print " [--delay=XXX] = delay of XXX seconds per loop, default 2 seconds\n"; + print "\n"; + exit; } else { @@ -87,7 +92,7 @@ if (length($ARGV[0])>1) $DBX=1; print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; } - if ($args =~ /-t/i) + if ($args =~ /--test/i) { $TEST=1; $T=1; @@ -402,6 +407,7 @@ while($one_day_interval > 0) } else { + $sthA->finish(); $stmtA = "INSERT INTO vicidial_daily_ra_stats SET stats_date='$YMD',update_time=NOW(),max_calls='$incalls_count',user='$QHra_user[$w]',stats_flag='OPEN',total_calls=1;"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "DAILY STATS INSERT $channel_group|$affected_rows|$stmtA|"; &agi_output;} @@ -794,7 +800,6 @@ while($one_day_interval > 0) $Baffected_rows = $dbhB->do($stmtB); } } - } $s++; } @@ -972,7 +977,6 @@ while($one_day_interval > 0) $dbhB->disconnect(); } - } } else @@ -1001,9 +1005,7 @@ while($one_day_interval > 0) $dbhB->disconnect(); } - } - } } ### possible future active call checker diff --git a/bin/AST_update.pl b/bin/AST_update.pl index a66b505f..1b9d0494 100644 --- a/bin/AST_update.pl +++ b/bin/AST_update.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_update.pl version 2.6 +# AST_update.pl version 2.8 # # DESCRIPTION: # uses the Asterisk Manager interface and DBD::MySQL to update the live_channels @@ -59,9 +59,10 @@ # 101004-1042 - Updated parked_channels checking for changes to parked calls functions # 130108-1710 - Changes for Asterisk 1.8 compatibility # 130413-2125 - Fix for issue #664, formatting fixes and added --quiet flag +# 131122-1317 - Small formatting fixes # -$build = '130413-2125'; +$build = '131122-1317'; # constants $SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds @@ -149,6 +150,7 @@ if (length($ARGV[0])>1) if ($args =~ /--help/i) { print "allowed run time options:\n"; + print " [--help] = this screen\n"; print " [--test] = test\n"; print " [--sysperf] = system performance logging\n"; print " [--sysperfdebug] = system performance debug output\n"; @@ -1283,7 +1285,6 @@ sub validate_parked_channels $parked_counter++; $rec_count++; } - $sthA->finish(); $run_validate_parked_channels_now=5; # set to run every five times the subroutine runs diff --git a/bin/start_asterisk_boot.pl b/bin/start_asterisk_boot.pl index 3bac7200..b61be967 100644 --- a/bin/start_asterisk_boot.pl +++ b/bin/start_asterisk_boot.pl @@ -1,12 +1,12 @@ #!/usr/bin/perl # -# start_asterisk_boot.pl version 2.0.5 +# start_asterisk_boot.pl version 2.8 # # This script is designed to start Asterisk in the proper way for Vicidial to # operate as intended # # -# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -15,8 +15,10 @@ # 90325-2238 - mattf - Rewrote launching of Asterisk, removed command files # 90506-1443 - mikec - Added the T option to the asterisk command. This enables timestamping. # 91210-1500 - mattf - Added datetimestamp to astshell screen +# 131022-1659 - mattf - Added CLI help display # +$build = '131022-1659'; # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -56,6 +58,46 @@ if ($min < 10) {$min = "0$min";} if ($sec < 10) {$sec = "0$sec";} $launch_date = "$year$mon$mday$hour$min$sec"; +$force_logging=0; +### begin parsing CLI run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + $allow_inactive_list_leads=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options(must stay in this order):\n"; + print " [--help] = this screen\n"; + print " [--version] = print version of this script, then exit\n"; + print " [--force-logging] = forces extra logging of asterisk even if disabled in settings\n"; + print "\n"; + exit; + } + else + { + if ($args =~ /--version/i) + { + print "version: $build\n"; + exit; + } + if ($args =~ /--force-logging/i) + { + $force_logging=1; + print "extra logging forced: $force_logging\n"; + } + } + } +else + { + # print "no command line options set\n"; + } + `PERL5LIB="$PATHhome/libs"; export PERL5LIB`; use DBI; @@ -79,7 +121,7 @@ $sthA->finish(); `ulimit -n 65536`; -if ($SYSLOG) +if ( ($SYSLOG) || ($force_logging > 0) ) { `/usr/bin/screen -d -m -S astershell$launch_date /usr/bin/screen -S astshell$launch_date`; print "started screen\n"; diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index a2fc3eea..cfe20078 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -136,7 +136,10 @@ active_twin_server_ip VARCHAR(15) default '', user_group VARCHAR(20) default '---ALL---', audio_store_purge TEXT, svn_revision INT(9) default '0', -svn_info TEXT +svn_info TEXT, +system_uptime VARCHAR(255) default '', +auto_restart_asterisk ENUM('Y','N') default 'N', +asterisk_temp_no_restart ENUM('Y','N') default 'N' ) ENGINE=MyISAM; CREATE UNIQUE INDEX server_id on servers (server_id); @@ -3215,4 +3218,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='1359',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1360',db_schema_update_date=NOW(); diff --git a/extras/upgrade_2.8.sql b/extras/upgrade_2.8.sql index 8dd097b5..9fa8f388 100644 --- a/extras/upgrade_2.8.sql +++ b/extras/upgrade_2.8.sql @@ -122,3 +122,9 @@ UPDATE system_settings SET db_schema_version='1358',db_schema_update_date=NOW() ALTER TABLE vicidial_campaigns ADD manual_dial_lead_id ENUM('Y','N') default 'N'; UPDATE system_settings SET db_schema_version='1359',db_schema_update_date=NOW() where db_schema_version < 1359; + +ALTER TABLE servers ADD system_uptime VARCHAR(255) default ''; +ALTER TABLE servers ADD auto_restart_asterisk ENUM('Y','N') default 'N'; +ALTER TABLE servers ADD asterisk_temp_no_restart ENUM('Y','N') default 'N'; + +UPDATE system_settings SET db_schema_version='1360',db_schema_update_date=NOW() where db_schema_version < 1360; diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt index 169fa0b7..461e3e4d 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.8.txt @@ -243,6 +243,12 @@ This is the dial plan context that this phone will use to dial out. If you are r Update List Owner|| Advanced Lead Management Tools|| Basic Lead Management Tools|| +System Uptime|| +This field will show the system uptime of this server. This field only updates if configured to do so by your administrator|| +Auto-Restart Asterisk|| +If Asterisk is running on this server and you want the system to make sure that it will be restarted in the event that it crashes, you might want to consider enabling this setting. If enabled, the system will check every minute to see if Asterisk is running, and if it is not it will attempt to restart it. This process will not run in the first 5 minutes after a system has been up. Default is N|| +Temp No-Restart Asterisk|| +If Auto-Restart Asterisk is enabled on this server, turning on this setting will prevent the auto-restart process from running until after the server is rebooted. Default is N|| ########################## CHANGES TO EXISTING PHRASES IN ADMIN TRANSLATION diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 4e0dc387..c02257aa 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1808,6 +1808,10 @@ if (isset($_GET["country_code_list_stats"])) {$country_code_list_stats=$_GET[" elseif (isset($_POST["country_code_list_stats"])) {$country_code_list_stats=$_POST["country_code_list_stats"];} if (isset($_GET["manual_dial_lead_id"])) {$manual_dial_lead_id=$_GET["manual_dial_lead_id"];} elseif (isset($_POST["manual_dial_lead_id"])) {$manual_dial_lead_id=$_POST["manual_dial_lead_id"];} +if (isset($_GET["auto_restart_asterisk"])) {$auto_restart_asterisk=$_GET["auto_restart_asterisk"];} + elseif (isset($_POST["auto_restart_asterisk"])) {$auto_restart_asterisk=$_POST["auto_restart_asterisk"];} +if (isset($_GET["asterisk_temp_no_restart"])) {$asterisk_temp_no_restart=$_GET["asterisk_temp_no_restart"];} + elseif (isset($_POST["asterisk_temp_no_restart"])) {$asterisk_temp_no_restart=$_POST["asterisk_temp_no_restart"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -2228,6 +2232,8 @@ if ($non_latin < 1) $hopper_vlc_dup_check = preg_replace('/[^NY]/','',$hopper_vlc_dup_check); $inventory_report = preg_replace('/[^NY]/','',$inventory_report); $manual_dial_lead_id = preg_replace('/[^NY]/','',$manual_dial_lead_id); + $auto_restart_asterisk = preg_replace('/[^NY]/','',$auto_restart_asterisk); + $asterisk_temp_no_restart = preg_replace('/[^NY]/','',$asterisk_temp_no_restart); $qc_enabled = preg_replace('/[^0-9NY]/','',$qc_enabled); $active = preg_replace('/[^0-9NY]/','',$active); @@ -3240,12 +3246,13 @@ else # 131007-1234 - Fix for copy user on encrypted passwords systems # 131016-2112 - Added manual_dial_lead_id campaign option, fixes some small issues # 131019-0849 - Moved help section to help.php +# 131029-2008 - Added Asterisk auto-restart options to servers # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.8-417a'; -$build = '131019-0849'; +$admin_version = '2.8-418a'; +$build = '131029-2008'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -13722,7 +13729,7 @@ if ($ADD==411111111111) {echo "
SERVER NOT MODIFIED - Please go back and look at the data you entered\n";} else { - $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second',sounds_update='$sounds_update',vicidial_recording_limit='$vicidial_recording_limit',carrier_logging_active='$carrier_logging_active',vicidial_balance_rank='$vicidial_balance_rank',rebuild_music_on_hold='$rebuild_music_on_hold',active_agent_login_server='$active_agent_login_server',conf_secret='$conf_secret',external_server_ip='$external_server_ip',custom_dialplan_entry='$custom_dialplan_entry',active_twin_server_ip='$active_twin_server_ip',user_group='$user_group' where server_id='$old_server_id';"; + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second',sounds_update='$sounds_update',vicidial_recording_limit='$vicidial_recording_limit',carrier_logging_active='$carrier_logging_active',vicidial_balance_rank='$vicidial_balance_rank',rebuild_music_on_hold='$rebuild_music_on_hold',active_agent_login_server='$active_agent_login_server',conf_secret='$conf_secret',external_server_ip='$external_server_ip',custom_dialplan_entry='$custom_dialplan_entry',active_twin_server_ip='$active_twin_server_ip',user_group='$user_group',auto_restart_asterisk='$auto_restart_asterisk',asterisk_temp_no_restart='$asterisk_temp_no_restart' where server_id='$old_server_id';"; $rslt=mysql_to_mysqli($stmt, $link); $stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; @@ -24163,7 +24170,7 @@ if ($ADD==3311) echo "Filter User Route Settings In-Group: $NWB#inbound_dids-user_route_settings_ingroup$NWE\n"; - echo "Filter In-Group ID: "; echo "$FDgroups_menu"; echo "$NWB#inbound_dids-group_id$NWE\n"; echo "Filter In-Group Call Handle Method: $NWB#inbound_dids-call_handle_method$NWE\n"; @@ -26912,7 +26919,7 @@ if ($ADD==311111111111) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; diff --git a/www/vicidial/help.php b/www/vicidial/help.php index 105a89f7..3f6532fc 100644 --- a/www/vicidial/help.php +++ b/www/vicidial/help.php @@ -6,6 +6,7 @@ # CHANGELOG: # 131019-0848 - Moved help from admin.php +# 131029-2058 - Added auto-restart asterisk help # @@ -3731,6 +3732,11 @@ if ($SSoutbound_autodial_active > 0)
Disk Usage - This field will show the disk usage for every partition on this server. This field is updated once every minute. +
+ +
+System Uptime - This field will show the system uptime of this server. This field only updates if configured to do so by your administrator. +

@@ -3861,6 +3867,16 @@ if ($SSoutbound_autodial_active > 0)
Active Asterisk Server - If Asterisk is not running on this server, or if the dialing processes should not be using this server, or if are only using this server for other scripts like the hopper loading script you would want to set this to N. Default is Y. +
+
+
+Auto-Restart Asterisk - If Asterisk is running on this server and you want the system to make sure that it will be restarted in the event that it crashes, you might want to consider enabling this setting. If enabled, the system will check every minute to see if Asterisk is running, and if it is not it will attempt to restart it. This process will not run in the first 5 minutes after a system has been up. Default is N. + +
+
+
+Temp No-Restart Asterisk - If Auto-Restart Asterisk is enabled on this server, turning on this setting will prevent the auto-restart process from running until after the server is rebooted. Default is N. +

\n"; echo ""; - $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage,sounds_update,vicidial_recording_limit,carrier_logging_active,vicidial_balance_rank,rebuild_music_on_hold,active_agent_login_server,conf_secret,external_server_ip,custom_dialplan_entry,active_twin_server_ip,user_group from servers where ( (server_id='$server_id') or (server_ip='$server_ip') ) $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage,sounds_update,vicidial_recording_limit,carrier_logging_active,vicidial_balance_rank,rebuild_music_on_hold,active_agent_login_server,conf_secret,external_server_ip,custom_dialplan_entry,active_twin_server_ip,user_group,system_uptime,auto_restart_asterisk,asterisk_temp_no_restart from servers where ( (server_id='$server_id') or (server_ip='$server_ip') ) $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $server_id = $row[0]; @@ -26958,6 +26965,10 @@ if ($ADD==311111111111) $custom_dialplan_entry = $row[40]; $active_twin_server_ip = $row[41]; $user_group = $row[42]; + $system_uptime = $row[43]; + $auto_restart_asterisk = $row[44]; + $asterisk_temp_no_restart = $row[45]; + $cpu = (100 - $cpu_idle_percent); $disk_usage = preg_replace("/ /"," - ",$disk_usage); @@ -26976,6 +26987,8 @@ if ($ADD==311111111111) echo "
System Load: $sysload - $cpu%   $NWB#servers-sysload$NWE
Live Channels: $channels_total   $NWB#servers-channels_total$NWE
Disk Usage: $disk_usage   $NWB#servers-disk_usage$NWE
System Uptime: $system_uptime   $NWB#servers-system_uptime$NWE
Admin User Group:
External Server IP: $NWB#servers-external_server_ip$NWE
Active Twin Server IP: $NWB#servers-active_twin_server_ip$NWE
Active Asterisk Server: $NWB#servers-active_asterisk_server$NWE
Auto-Restart Asterisk:     $NWB#servers-auto_restart_asterisk$NWE
Temp No-Restart Asterisk:     $NWB#servers-asterisk_temp_no_restart$NWE
Active Agent Server: $NWB#servers-active_agent_login_server$NWE
Generate conf files: $NWB#servers-generate_conf$NWE
Rebuild conf files: $NWB#servers-rebuild_conf_files$NWE