function parseQueue() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); $sock = new sockets(); if ($unix->process_exists($pid, basename(__FILE__))) { $pidTime = $unix->PROCCESS_TIME_MIN($pid); events("Already process PID: {$pid} running since {$pidTime} minutes", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } @file_put_contents($pidfile, getmypid()); if (system_is_overloaded(basename(__FILE__))) { events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } $EnableArticaSMTPStatistics = $sock->GET_INFO("EnableArticaSMTPStatistics"); if (!is_numeric($EnableArticaSMTPStatistics)) { $EnableArticaSMTPStatistics = 0; } $directory = "/var/log/artica-mail"; if (!is_dir($directory)) { return; } if (!($handle = @opendir($directory))) { return; } $q = new mysql_postfix_builder(); $q->CheckTables(); events("open {$directory}"); while (false !== ($filename = readdir($handle))) { if ($EnableArticaSMTPStatistics == 0) { @unlink("{$directory}/{$filename}"); continue; } if (!preg_match("#(.+?)\\.[0-9]+\\.aws#", $filename, $re)) { continue; } $instancename = $re[1]; ParseFile("{$directory}/{$filename}"); if (system_is_overloaded(basename(__FILE__))) { system_admin_events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } } }