Changed to use server-specific cid_channels_recent table

git-svn-id: svn://192.168.202.10@2977 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2018-05-11 20:55:35 +00:00
parent b22e0bb335
commit b76bf2b3fc
3 changed files with 109 additions and 6 deletions
+39
View File
@@ -23,6 +23,7 @@
# 160101-1124 - Added flush of routing_initiated_recordings table
# 161214-1039 - Added flush of parked_channels_recent table
# 180112-0915 - Added flush for cid_channels_recent table
# 180511-1223 - Added flush for server-specific cid_channels_recent_ tables
#
### begin parsing run-time options ###
@@ -358,6 +359,44 @@ if (!$T)
if (!$Q) {print " - OPTIMIZE vicidial_lists \n";}
### Gather active servers from the database
$stmtA = "SELECT server_ip,server_id FROM servers where active='Y' and active_asterisk_server='Y';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$aas=0;
while ($sthArows > $aas)
{
@aryA = $sthA->fetchrow_array;
$dialer_ip[$aas] = $aryA[0];
$dialer_id[$aas] = $aryA[1];
$PADserver_ip[$aas] = $aryA[0];
$PADserver_ip[$aas] =~ s/(\d+)(\.|$)/sprintf "%3.3d$2",$1/eg;
$PADserver_ip[$aas] =~ s/\.//eg;
$aas++;
}
$sthA->finish();
$aas=0;
while ($sthArows > $aas)
{
$CCRrec=0;
$stmtA = "SHOW TABLES LIKE \"cid_channels_recent_$PADserver_ip[$aas]\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$CCRrec=$sthA->rows;
if($DB){print STDERR "\n|$CCRrec|$stmtA|\n";}
if ($CCRrec > 0)
{
$stmtA = "DELETE from cid_channels_recent_$PADserver_ip[$aas] where call_date < '$SQLdate_NEG_2min';";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) { $affected_rows = $dbhA->do($stmtA);}
if (!$Q) {print " - cid_channels_recent_$PADserver_ip[$aas] flush: $affected_rows rows\n";}
}
$aas++;
}
$sthA->finish();
$dbhA->disconnect();