From e4bf160b615b4b412be6504a1d39cec94c27fc2e Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 11 Feb 2010 15:00:13 +0000 Subject: [PATCH] added voicemail and crontab backups to ADMIN_backup.pl script improved staggered dialing in the FILL script other small fixes git-svn-id: svn://192.168.202.10@1335 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-VDAD_ALL_inbound.agi | 4 +-- bin/ADMIN_backup.pl | 64 ++++++++++++++++++++++++++--------- bin/ADMIN_update_server_ip.pl | 21 +++++++----- bin/AST_VDauto_dial_FILL.pl | 18 +++++++--- 4 files changed, 76 insertions(+), 31 deletions(-) diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index 1782451c..007797b5 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -1759,7 +1759,7 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Originate','$VHqueryCID','Exten: 83047777777777','Context: vicidial-auto','Channel: Local/$dtmf_silent_prefix$VDADconf_exten$at$ext_context','Priority: 1','Callerid: $agent_alert_exten','Timeout: 10','','','','')"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02048'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|7$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|7$VDADconf_exten|$channel|$agent_alert_exten|insert to vicidial_manager"; &agi_output;} usleep(1 * $agent_alert_delay * 1000); } @@ -2161,7 +2161,7 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) ) $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VDADserver_ip','','Originate','$VHqueryCID','Exten: 83047777777777','Context: vicidial-auto','Channel: Local/$alertVDADremDIALstr$at$ext_context','Priority: 1','Callerid: $agent_alert_exten','Timeout: 10','','','','')"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02068'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|$alertVDADremDIALstr|$channel|insert to vicidial_manager"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|$alertVDADremDIALstr|$agent_alert_exten|$channel|insert to vicidial_manager"; &agi_output;} usleep(1 * $agent_alert_delay * 1000); } diff --git a/bin/ADMIN_backup.pl b/bin/ADMIN_backup.pl index 89ca8b55..3d8b8e7d 100644 --- a/bin/ADMIN_backup.pl +++ b/bin/ADMIN_backup.pl @@ -5,7 +5,7 @@ # DESCRIPTION: # Backs-up the asterisk database, conf/agi/sounds/bin files # -# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # @@ -14,6 +14,7 @@ # 80328-0135 - Do not attempt to archive /etc/my.cnf is --without-db flag is set # 80611-0549 - Added DB option to backup all tables except for log tables # 90620-1851 - Moved mysqldump bin lookup to database backup section +# 100211-0910 - Added crontab backup and voicemail bacup option # $secT = time(); @@ -50,6 +51,8 @@ if (length($ARGV[0])>1) print " [--without-conf] = do not backup the conf files\n"; print " [--without-web] = do not backup web files\n"; print " [--without-sounds] = do not backup asterisk sounds\n"; + print " [--without-voicemail] = do not backup asterisk voicemail\n"; + print " [--without-crontab] = do not backup crontab\n"; print " [--ftp-transfer] = Transfer backup to FTP server\n"; print " [--debugX] = super debug\n"; print " [--debug] = debug\n"; @@ -108,6 +111,16 @@ if (length($ARGV[0])>1) $without_web=1; print "\n----- No web files Backup -----\n\n"; } + if ($args =~ /--without-voicemail/i) + { + $without_voicemail=1; + print "\n----- No voicemail files Backup -----\n\n"; + } + if ($args =~ /--without-crontab/i) + { + $without_crontab=1; + print "\n----- No crontab Backup -----\n\n"; + } if ($args =~ /--ftp-transfer/i) { $ftp_transfer=1; @@ -213,6 +226,7 @@ $linux='_LINUX_'; $bin='_BIN_'; $web='_WEB_'; $sounds='_SOUNDS_'; +$voicemail='_VOICEMAIL_'; $all='_ALL_'; $tar='.tar'; $gz='.gz'; @@ -279,6 +293,7 @@ if ( ($without_db < 1) && ($conf_only < 1) ) } else { + if ($DBX) {print "$mysqldumpbin --user=$VARDB_user --password=$VARDB_pass --lock-tables --flush-logs $VARDB_database | $gzipbin > $ARCHIVEpath/temp/$VARserver_ip$VARDB_database$wday.gz\n";} `$mysqldumpbin --user=$VARDB_user --password=$VARDB_pass --lock-tables --flush-logs $VARDB_database | $gzipbin > $ARCHIVEpath/temp/$VARserver_ip$VARDB_database$wday.gz`; } } @@ -286,8 +301,10 @@ if ( ($without_db < 1) && ($conf_only < 1) ) if ( ($without_conf < 1) && ($db_only < 1) ) { ### BACKUP THE ASTERISK CONF FILES ON THE SERVER ### + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$conf$wday$tar /etc/astguiclient.conf /etc/zaptel.conf /etc/asterisk\n";} `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$conf$wday$tar /etc/astguiclient.conf /etc/zaptel.conf /etc/asterisk`; + ### BACKUP THE WANPIPE CONF FILES(if there are any) ### if ( -e ('/etc/wanpipe/wanpipe1.conf')) { @@ -301,60 +318,73 @@ if ( ($without_conf < 1) && ($db_only < 1) ) if ( -e ('/etc/wanpipe/wanpipe8.conf')) {$sgSTRING .= '/etc/wanpipe/wanpipe8.conf ';} if ( -e ('/etc/wanpipe/wanrouter.rc')) {$sgSTRING .= '/etc/wanpipe/wanrouter.rc ';} + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$sangoma$wday$tar $sgSTRING\n";} `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$sangoma$wday$tar $sgSTRING`; } + ### BACKUP OTHER CONF FILES ON THE SERVER ### + $files = ""; + if ($without_db < 1) { - ### BACKUP OTHER CONF FILES ON THE SERVER ### - $files = ""; if ( -e ('/etc/my.cnf')) {$files .= "/etc/my.cnf ";} - if ( -e ('/etc/hosts')) {$files .= "/etc/hosts ";} - if ( -e ('/etc/rc.d/rc.local')) {$files .= "/etc/rc.d/rc.local ";} - if ( -e ('/etc/resolv.conf')) {$files .= "/etc/resolv.conf ";} - - `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$linux$wday$tar $files`; } - else + if ($without_crontab < 1) { - ### BACKUP OTHER CONF FILES ON THE SERVER ### - $files = ""; - if ( -e ('/etc/hosts')) {$files += "/etc/hosts ";} - if ( -e ('/etc/rc.d/rc.local')) {$files += "/etc/rc.d/rc.local ";} - if ( -e ('/etc/resolv.conf')) {$files += "/etc/resolv.conf ";} - - `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$linux$wday$tar $files`; + `crontab -l > /etc/crontab_snapshot`; + if ( -e ('/etc/crontab_snapshot')) {$files .= "/etc/crontab_snapshot ";} } + + if ( -e ('/etc/hosts')) {$files .= "/etc/hosts ";} + if ( -e ('/etc/rc.d/rc.local')) {$files .= "/etc/rc.d/rc.local ";} + if ( -e ('/etc/resolv.conf')) {$files .= "/etc/resolv.conf ";} + + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$linux$wday$tar $files\n";} + `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$linux$wday$tar $files`; } if ( ($conf_only < 1) && ($db_only < 1) && ($without_web < 1) ) { ### BACKUP THE WEB FILES ON THE SERVER ### + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$web$wday$tar $PATHweb\n";} `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$web$wday$tar $PATHweb`; } if ( ($conf_only < 1) && ($db_only < 1) ) { ### BACKUP THE ASTGUICLIENT AND AGI FILES ON THE SERVER ### + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$bin$wday$tar $PATHagi $PATHhome\n";} `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$bin$wday$tar $PATHagi $PATHhome`; } if ( ($conf_only < 1) && ($db_only < 1) && ($without_sounds < 1) ) { ### BACKUP THE ASTERISK SOUNDS ON THE SERVER ### + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$sounds$wday$tar $PATHsounds\n";} `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$sounds$wday$tar $PATHsounds`; } +if ( ($conf_only < 1) && ($db_only < 1) && ($without_voicemail < 1) ) + { + ### BACKUP THE ASTERISK VOICEMAIL ON THE SERVER ### + if ($DBX) {print "$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$voicemail$wday$tar /var/spool/asterisk/voicemail\n";} + `$tarbin cf $ARCHIVEpath/temp/$VARserver_ip$voicemail$wday$tar /var/spool/asterisk/voicemail`; + } + ### PUT EVERYTHING TOGETHER TO BE COMPRESSED ### +if ($DBX) {print "$tarbin cf $ARCHIVEpath/$VARserver_ip$all$wday$tar $ARCHIVEpath/temp\n";} `$tarbin cf $ARCHIVEpath/$VARserver_ip$all$wday$tar $ARCHIVEpath/temp`; ### REMOVE OLD GZ FILE +if ($DBX) {print "rm -f $ARCHIVEpath/$VARserver_ip$all$wday$tar$gz\n";} `rm -f $ARCHIVEpath/$VARserver_ip$all$wday$tar$gz`; ### COMPRESS THE ALL FILE ### +if ($DBX) {print "$gzipbin -9 $ARCHIVEpath/$VARserver_ip$all$wday$tar\n";} `$gzipbin -9 $ARCHIVEpath/$VARserver_ip$all$wday$tar`; ### REMOVE TEMP FILES ### +if ($DBX) {print "rm -fR $ARCHIVEpath/temp\n";} `rm -fR $ARCHIVEpath/temp`; @@ -371,4 +401,6 @@ if ($ftp_transfer > 0) } +if ($DBX) {print "DONE, Exiting...\n";} + exit; diff --git a/bin/ADMIN_update_server_ip.pl b/bin/ADMIN_update_server_ip.pl index b5d0e1a6..1947bff8 100644 --- a/bin/ADMIN_update_server_ip.pl +++ b/bin/ADMIN_update_server_ip.pl @@ -204,14 +204,17 @@ if (-e "$PATHconf") if ($AUTO) { $manual='n'; - @ip = `/sbin/ifconfig`; - $j=0; - while($#ip>=$j) - { - if ($ip[$j] =~ /inet addr/) {$VARserver_ip = $ip[$j]; $j=1000;} - $j++; + if (length($VARserver_ip)<7) + { + @ip = `/sbin/ifconfig`; + $j=0; + while($#ip>=$j) + { + if ($ip[$j] =~ /inet addr/) {$VARserver_ip = $ip[$j]; $j=1000;} + $j++; + } + $VARserver_ip =~ s/.*addr:| Bcast.*|\r|\n|\t| //gi; } - $VARserver_ip =~ s/.*addr:| Bcast.*|\r|\n|\t| //gi; } else { @@ -481,10 +484,10 @@ 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. diff --git a/bin/AST_VDauto_dial_FILL.pl b/bin/AST_VDauto_dial_FILL.pl index be1c3a05..7fb7c218 100644 --- a/bin/AST_VDauto_dial_FILL.pl +++ b/bin/AST_VDauto_dial_FILL.pl @@ -606,9 +606,9 @@ while($one_day_interval > 0) else { $stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id';"; - print "|$stmtA|\n"; + # print "|$stmtA|\n"; $UQaffected_rows = $dbhA->do($stmtA); - print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n"; + # print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n"; $stmtA = "SELECT list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,address3,alt_phone,called_count FROM vicidial_list where lead_id='$lead_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -715,7 +715,14 @@ while($one_day_interval > 0) { $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id';"; } - $affected_rows = $dbhA->do($stmtA); + if ($staggered < 1) + { + $affected_rows = $dbhA->do($stmtA); + } + else + { + $vl_updates[$staggered_ct] = $stmtA; + } $stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; $affected_rows = $dbhA->do($stmtA); @@ -880,6 +887,7 @@ while($one_day_interval > 0) $TEMP_vm_insert = $vm_inserts[$staggered_fill]; $TEMP_vac_insert = $vac_inserts[$staggered_fill]; + $TEMP_vl_update = $vl_updates[$staggered_fill]; $TEMP_st_logged = $st_logged[$staggered_fill]; $TEMP_vm_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi; @@ -887,11 +895,12 @@ while($one_day_interval > 0) if (length($TEMP_vm_insert) > 20) { + $affected_rows_vl = $dbhA->do($TEMP_vl_update); $affected_rows_vm = $dbhA->do($TEMP_vm_insert); $affected_rows_vac = $dbhA->do($TEMP_vac_insert); } - $event_string = "| number call stagger dialed|$TEMP_server_ip|$staggered_fill|$staggered_ct|$affected_rows_vm|$affected_rows_vac $TEMP_st_logged"; + $event_string = "| number call stagger dialed|$TEMP_server_ip|$staggered_fill|$staggered_ct|$affected_rows_vm|$affected_rows_vac|$affected_rows_vl $TEMP_st_logged"; &event_logger; ### sleep for 2.5 hundredths of a second to not flood the server with new calls @@ -912,6 +921,7 @@ while($one_day_interval > 0) $staggered_ct=0; @vm_inserts=@MT; @vac_inserts=@MT; + @vl_updates=@MT; @st_logged=@MT; ############################################################################### ###### END - experimental balanced FILL dialing ($staggered)