function notify_remote_proxys($COMMANDS = null) { $unix = new unix(); include_once dirname(__FILE__) . "/ressources/class.blackboxes.inc"; $EXEC_PID_FILE = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $EXEC_PID_TIME = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($EXEC_PID_FILE); if ($unix->process_exists($pid, basename(__FILE__))) { $timefile = $unix->file_time_min($EXEC_PID_FILE); if ($timefile < 15) { $unix->events("Skipping, Already executed pid {$pid} {$timefile}Mn", "/var/log/stats-appliance.log"); ufdbguard_admin_events("Skipping, Already executed pid {$pid} {$timefile}Mn...", __FUNCTION__, __FILE__, __LINE__, "communicate"); return; } $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } @file_put_contents($EXEC_PID_FILE, getmypid()); if ($COMMANDS == null) { $COMMANDS = "BUILDCONF"; } if ($COMMANDS == "PING") { $time = $unix->file_time_min($EXEC_PID_TIME); if (!$GLOBALS["VERBOSE"]) { if ($time < 5) { return; } } @unlink($EXEC_PID_TIME); @file_put_contents($EXEC_PID_TIME, time()); $bb = new blackboxes(); $bb->NotifyAll("PING"); return; } $t = time(); $f = new squid_stats_appliance(); $f->export_tables(); $took = $unix->distanceOfTimeInWords($t, time(), true); ufdbguard_admin_events("Exporting MySQL datas done... took:{$took}", __FUNCTION__, __FILE__, __LINE__, "communicate"); $unix->events("Exporting MySQL datas done... took:{$took}", "/var/log/stats-appliance.log"); include_once dirname(__FILE__) . "/ressources/class.blackboxes.inc"; $unix->events("Send order to appliance(s)", "/var/log/stats-appliance.log"); $bb = new blackboxes(); $bb->NotifyAll("BUILDCONF"); }
function export_tables() { $q = new squid_stats_appliance(); echo $q->GET_INDEX(); }