function OnlyPOstfix() { $pid = getmypid(); $pidefile = "/etc/artica-postfix/croned.1/" . basename(__FILE__) . ".onlypostfix.pid"; if (is_file($pidefile)) { $currentpid = trim(file_get_contents($pidefile)); if ($currentpid != $pid) { if (is_dir('/proc/' . $currentpid)) { write_syslog("Already instance executed aborting...", __FILE__); die; } } } file_put_contents($pidefile, $pid); $path = "/var/log/artica-postfix/RTM"; $arrayf = DirListPostfix($path); $q = new mysql(); if (!is_array($arrayf)) { return null; } $max = count($arrayf); if ($max < 500) { return null; } $count = 0; events("Starting analyze {$max} sql files....", __FILE__); while (list($num, $file) = each($arrayf)) { $count = $count + 1; events("OnlyPOstfix(): parsing {$path}/{$file} {$count}/{$max}"); if (!preg_match("#\\.msg\$#", $file)) { continue; } if ($file == "NOQUEUE.msg") { @unlink("{$path}/{$file}"); continue; } if (!is_file("{$path}/{$file}")) { continue; } if (PostfixFullProcess("{$path}/{$file}", $q)) { echo "OnlyPOstfix(): success {$path}/{$file} {$count}/{$max}\n"; @unlink("{$path}/{$file}"); } } }
function OnlyPOstfix() { $pid = getmypid(); $pidefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".onlypostfix.pid"; if (is_file($pidefile)) { $currentpid = trim(file_get_contents($pidefile)); if ($currentpid != $pid) { if (is_dir('/proc/' . $currentpid)) { write_syslog("Already instance executed aborting...", __FILE__); die; } } } $unix = new unix(); $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $timesched = $unix->file_time_min($timefile); if ($timesched <= $GLOBALS["ArticaSMTPStatsTimeFrame"]) { if ($GLOBALS["VERBOSE"]) { echo "{$timesched}/{$GLOBALS["ArticaSMTPStatsTimeFrame"]} aborting\n"; } return; } file_put_contents($pidefile, $pid); $path = "/var/log/artica-postfix/RTM"; $arrayf = DirListPostfix($path, $GLOBALS["ArticaSMTPStatsMaxFiles"]); $q = new mysql(); if (!is_array($arrayf)) { return null; } $max = count($arrayf); if ($max > $GLOBALS["ArticaSMTPStatsMaxFiles"]) { $max = $GLOBALS["ArticaSMTPStatsMaxFiles"]; } $count = 0; events("Starting analyze {$max} sql files....", __FILE__); while (list($num, $file) = each($arrayf)) { $count++; events("OnlyPOstfix(): parsing {$path}/{$file} {$count}/{$max}"); if (!preg_match("#\\.msg\$#", $file)) { continue; } if ($file == "NOQUEUE.msg") { @unlink("{$path}/{$file}"); continue; } if (!is_file("{$path}/{$file}")) { continue; } usleep($GLOBALS["ArticaStatusUsleep"]); if ($count > $GLOBALS["ArticaSMTPStatsMaxFiles"]) { events("OnlyPOstfix():: Analyze Max {$count} sql files break;", __FILE__); return; } if (PostfixFullProcess("{$path}/{$file}", $q)) { echo "OnlyPOstfix(): success {$path}/{$file} {$count}/{$max}\n"; @unlink("{$path}/{$file}"); } } ScanPostFixConnections(); ScanPostFixConnectionsErr(); }