Added the system setting USA-Canada Phone Number Dialcode Fix which will trigger a process that will run at the Timeclock End of Day that will check all phone numbers to populate the dial code, or phone code, field

with a 1 if it is missing as well as remove a leading 1 from the phone
 number field if it is present.


Added --lstn-buffer option to keepalive script to run special enhanced buffer version of the Listen process. Requires newer Net::Telnet perl
 module version.

git-svn-id: svn://192.168.202.10@2405 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-11-02 21:45:54 +00:00
parent 93e0f21195
commit 28f39a42e5
8 changed files with 1663 additions and 17 deletions
+38 -5
View File
@@ -101,9 +101,10 @@
# 150307-1738 - Added custom meetme enter sounds(only works with Asterisk 1.8)
# 150724-0835 - Added purge of vicidial_ajax_log records older than 7 days to end of day process
# 150804-0919 - Added whisper extensions
# 151031-0931 - Added usacan_phone_dialcode_fix feature at timeclock-end-of-day, added -lstn-buffer option
#
$build = '150804-0919';
$build = '151031-0931';
$DB=0; # Debug flag
@@ -190,6 +191,7 @@ if (length($ARGV[0])>1)
print " [-adfill-delay=X] = setting delay milliseconds on auto-dial FILL process\n";
print " [-fill-staggered] = enable experimental staggered auto-dial FILL process\n";
print " [-cu3way] = keepalive for the optional 3way conference checker\n";
print " [-lstn-buffer] = use special enhanced telnet buffer listen process\n";
print " [-cu3way-delay=X] = setting delay seconds on 3way conference checker\n";
print " [-debug] = verbose debug messages\n";
print " [-debugX] = Extra-verbose debug messages\n";
@@ -258,6 +260,11 @@ if (length($ARGV[0])>1)
$cu3way=1;
if ($DB > 0) {print "\n----- cu3way ENABLED -----\n\n";}
}
if ($args =~ /-lstn-buffer/i)
{
$lstn_buffer=1;
if ($DB > 0) {print "\n----- lstn_buffer ENABLED -----\n\n";}
}
if ($args =~ /-cu3way-delay=/i) # CLI defined delay
{
@CLIvarARY = split(/-cu3way-delay=/,$args);
@@ -667,7 +674,10 @@ else
{
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 ($lstn_buffer > 0)
{`/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listenBUFFER.pl`;}
else
{`/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listen.pl`;}
}
if ( ($AST_VDauto_dial > 0) && ($runningAST_VDauto_dial < 1) )
{
@@ -800,7 +810,7 @@ $sthA->finish();
if ($timeclock_end_of_day_NOW > 0)
{
$stmtA = "SELECT agents_calls_reset from system_settings;";
$stmtA = "SELECT agents_calls_reset,usacan_phone_dialcode_fix from system_settings;";
if ($DB) {print "|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -808,7 +818,8 @@ if ($timeclock_end_of_day_NOW > 0)
if ($SSsel_ct > 0)
{
@aryA = $sthA->fetchrow_array;
$agents_calls_reset = $aryA[0];
$agents_calls_reset = $aryA[0];
$usacan_phone_dialcode_fix = $aryA[1];
}
$sthA->finish();
@@ -1270,7 +1281,6 @@ if ($timeclock_end_of_day_NOW > 0)
##### END ra stats end of day process #####
##### BEGIN vicidial_ajax_log end of day process removing records older than 7 days #####
$stmtA = "DELETE from vicidial_ajax_log where db_time < \"$SDSQLdate\";";
if($DBX){print STDERR "\n|$stmtA|\n";}
@@ -1288,6 +1298,29 @@ if ($timeclock_end_of_day_NOW > 0)
##### END vicidial_ajax_log end of day process removing records older than 7 days #####
##### BEGIN usacan_phone_dialcode_fix funciton #####
if ($usacan_phone_dialcode_fix > 0)
{
$stmtA = "UPDATE vicidial_list SET phone_code='1' where phone_code!='1';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$PCaffected_rows = $dbhA->do($stmtA);
if($DB){print STDERR "\n|$PCaffected_rows vicidial_list.phone_code entries set to 1|\n";}
$stmtA = "UPDATE vicidial_list SET phone_number = TRIM(LEADING '1' from phone_number) where char_length(phone_number) > 10 and phone_number LIKE \"1%\";";
if($DBX){print STDERR "\n|$stmtA|\n";}
$PNaffected_rows = $dbhA->do($stmtA);
if($DB){print STDERR "\n|$PNaffected_rows vicidial_list phone_number leading 1 entries trimmed|\n";}
if ( ($PCaffected_rows > 0) or ($PNaffected_rows > 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='MODIFY', record_id='leads', event_code='USACAN PHONE DIALCODE FIX', event_sql='', event_notes='$PCaffected_rows vicidial_list.phone_code entries set to 1|$PNaffected_rows vicidial_list phone_number leading 1 entries trimmed|';";
$Laffected_rows = $dbhA->do($stmtA);
if ($DBX) {print "Admin log of USACAN phone code fix: |$Laffected_rows|$stmtA|\n";}
}
}
##### END usacan_phone_dialcode_fix funciton #####
$dbhC = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_custom_user", "$VARDB_custom_pass")
or die "Couldn't connect to database: " . DBI->errstr;
+35 -6
View File
@@ -46,6 +46,7 @@
# 141219-1137 - Change to keepalive processes to not run at busy times and not drop buffer
# 150610-1200 - Added support for AMI version 1.3
# 150709-1506 - Added DTMF logging for Asterisk 1.8 and higher
# 151031-0918 - Added better capture of errors in telnet connection, other small fixes
#
# constants
@@ -253,6 +254,14 @@ while($one_day_interval > 0)
$read_input_buf = $tn->get(Errmode => Return, Timeout => 1,);
$input_buf_length = length($read_input_buf);
$msg = $tn->errmsg;
if (($msg =~ /read timed-out/i) || ( $msg eq '' ))
{
# This is normal
}
else
{
print "ERRMSG: |$msg|\n";
}
if ($msg =~ /filehandle isn\'t open/i)
{
$endless_loop=0;
@@ -833,7 +842,10 @@ while($one_day_interval > 0)
{
$keepalive_skips=0;
@keepalive_output = $tn->cmd(String => "Action: Command\nCommand: show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1);
if($DB){print "keepalive length: $#keepalive_output|$now_date\n";}
$msg = $tn->errmsg;
$buf_ref = $tn->buffer;
$buf_len = length( $$buf_ref );
if($DB){print "keepalive length: $#keepalive_output|$now_date|$msg|$buf_len|\n";}
if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line: $keepalive_sec seconds $endless_loop|$now_date|$last_update|\n";}
@@ -845,16 +857,19 @@ while($one_day_interval > 0)
}
$manager_string="PROCESS: keepalive length: $#keepalive_output|$k|$now_date";
&manager_output_logger;
$last_keepalive_epoch = time();
}
else
{
$keepalive_skips++;
if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|\n";}
$buf_ref = $tn->buffer;
$buf_len = length( $$buf_ref );
if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|$buf_len|\n";}
$manager_string="PROCESS: keepalive skip: $keepalive_sec seconds($keepalive_skips in a row)|$now_date";
&manager_output_logger;
}
$last_keepalive_epoch = time();
#$last_keepalive_epoch = time();
$keepalive_count_loop=0;
}
}
@@ -873,6 +888,14 @@ while($one_day_interval > 0)
$read_input_buf = $tn->get(Errmode => Return, Timeout => 1,);
$input_buf_length = length($read_input_buf);
$msg = $tn->errmsg;
if (($msg =~ /read timed-out/i) || ( $msg eq '' ))
{
# This is normal
}
else
{
print "ERRMSG: |$msg|\n";
}
if ($msg =~ /filehandle isn\'t open/i)
{
$endless_loop=0;
@@ -1361,7 +1384,10 @@ while($one_day_interval > 0)
{
$keepalive_skips=0;
@keepalive_output = $tn->cmd(String => "Action: Command\nCommand: core show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1);
if($DB){print "keepalive length: $#keepalive_output|$now_date\n";}
$msg = $tn->errmsg;
$buf_ref = $tn->buffer;
$buf_len = length( $$buf_ref );
if($DB){print "keepalive length: $#keepalive_output|$now_date|$msg|$buf_len|\n";}
if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line: $keepalive_sec seconds $endless_loop|$now_date|$last_update|\n";}
@@ -1373,16 +1399,19 @@ while($one_day_interval > 0)
}
$manager_string="PROCESS: keepalive length: $#keepalive_output|$k|$now_date";
&manager_output_logger;
$last_keepalive_epoch = time();
}
else
{
$keepalive_skips++;
if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|\n";}
$buf_ref = $tn->buffer;
$buf_len = length( $$buf_ref );
if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|$buf_len|\n";}
$manager_string="PROCESS: keepalive skip: $keepalive_sec seconds($keepalive_skips in a row)|$now_date";
&manager_output_logger;
}
$last_keepalive_epoch = time();
#$last_keepalive_epoch = time();
$keepalive_count_loop=0;
}
File diff suppressed because it is too large Load Diff