Added recent session per-call logging and force_fronter_audio_stop Agent API function

git-svn-id: svn://192.168.202.10@3066 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2019-02-22 18:32:05 +00:00
parent 1dbd40b34e
commit 4b39c8b86a
29 changed files with 506 additions and 49 deletions
+48 -2
View File
@@ -15,7 +15,7 @@
# - Auto reset lists at defined times
# - Auto restarts Asterisk process if enabled in servers settings
#
# Copyright (C) 2018 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2019 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 61011-1348 - First build
@@ -134,9 +134,10 @@
# 180916-1003 - Added vicidial_lists.resets_today resetting at TEOD, timed reset resets_today verification before reset
# 180930-1007 - Added more allowed codecs to conf file generation
# 181028-1451 - Added vicidial_list stuck QUEUE reset at TEoD
# 190220-2258 - Added flushing of vicidial_sessions_recent table
#
$build = '181028-1451';
$build = '190220-2258';
$DB=0; # Debug flag
$teodDB=0; # flag to log Timeclock End of Day processes to log file
@@ -1462,6 +1463,33 @@ if ($timeclock_end_of_day_NOW > 0)
}
# roll of SENT/EXPIRED vicidial_sessions_recent records
if (!$Q) {print "\nProcessing vicidial_sessions_recent table...\n";}
$stmtA = "INSERT IGNORE INTO vicidial_sessions_recent_archive SELECT * from vicidial_sessions_recent where call_date < \"$TDSQLdate\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
$event_string = "$sthArows rows inserted into vicidial_sessions_recent_archive table";
if (!$Q) {print "$event_string \n";}
if ($teodDB) {&teod_logger;}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_sessions_recent WHERE call_date < \"$TDSQLdate\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
$event_string = "$sthArows rows deleted from vicidial_sessions_recent table";
if (!$Q) {print "$event_string \n";}
if ($teodDB) {&teod_logger;}
$stmtA = "optimize table vicidial_sessions_recent;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
# roll of vicidial_ccc_log records, keep only 1 day of records in active table
if (!$Q) {print "\nProcessing vicidial_ccc_log table...\n";}
$stmtA = "INSERT IGNORE INTO vicidial_ccc_log_archive SELECT * from vicidial_ccc_log;";
@@ -1727,6 +1755,24 @@ if ($timeclock_end_of_day_NOW > 0)
##### END vicidial_recent_ascb_calls_archive end of day process removing records older than 7 days #####
##### BEGIN vicidial_sessions_recent_archive end of day process removing records older than 7 days #####
$stmtA = "DELETE from vicidial_sessions_recent_archive where call_date < \"$SDSQLdate\";";
if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA);
if($DB){print STDERR "\n|$affected_rows vicidial_sessions_recent_archive records older than 7 days purged|\n";}
if ($teodDB) {$event_string = "vicidial_sessions_recent_archive records older than 7 days purged: |$stmtA|$affected_rows|"; &teod_logger;}
$stmtA = "optimize table vicidial_sessions_recent_archive;";
if($DBX){print STDERR "\n|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
##### END vicidial_sessions_recent_archive end of day process removing records older than 7 days #####
##### BEGIN usacan_phone_dialcode_fix funciton #####
if ($usacan_phone_dialcode_fix > 0)
{
+30
View File
@@ -27,8 +27,11 @@
# 180519-1431 - Added vicidial_inbound_groups optimization
# 181003-2115 - Added optimize of cid_channels_recent_ tables
# 190214-1758 - Fix for cid_recent_ table optimization issue
# 190222-1321 - Added optional flushing of vicidial_sessions_recent table
#
$session_flush=0;
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
@@ -46,6 +49,7 @@ if (length($ARGV[0])>1)
print " [-t] = test\n";
print " [--debug] = debugging messages\n";
print " [--seconds=XXX] = optional, minimum number of seconds worth of records to keep(default 3600)\n";
print " [--session-flush] = flush the vicidial_sessions_recent table\n";
print "\n";
exit;
@@ -66,6 +70,11 @@ if (length($ARGV[0])>1)
$T=1; $TEST=1;
print "\n-----TESTING -----\n\n";
}
if ($args =~ /--session-flush/i)
{
$session_flush=1;
print "\n----- SESSION FLUSH(vicidial_sessions_recent) ----- $session_flush \n\n";
}
if ($args =~ /--seconds=/i)
{
@data_in = split(/--seconds=/,$args);
@@ -428,6 +437,27 @@ while ($sthArowsSERVERS > $aas)
}
$sthA->finish();
if ($session_flush > 0)
{
$stmtA = "DELETE from vicidial_sessions_recent where call_date < '$SQLdate_NEG_1hour';";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) { $affected_rows = $dbhA->do($stmtA);}
if (!$Q) {print " - vicidial_sessions_recent flush: $affected_rows rows\n";}
$stmtA = "OPTIMIZE table vicidial_sessions_recent;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - OPTIMIZE vicidial_sessions_recent \n";}
}
$dbhA->disconnect();