function communicate() { $unix = new unix(); $sock = new sockets(); $php = $unix->LOCATE_PHP5_BIN(); $kill = $unix->find_program("kill"); $GLOBALS["CLASS_SOCKET"] = $sock; $GLOBALS["CLASS_UNIX"] = $unix; $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, __FILE__)) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Remote stat appliance, Already running pid {$pid}\n"; } if ($time < 10) { WriteMyLogs("Warning: Already running pid {$pid} since {$time}mn", __FUNCTION__, __FILE__, __LINE__); return; } else { unix_system_kill_force($pid); } } $GLOBALS["MYPID"] = getmypid(); WriteMyLogs("New PID: " . getmypid()); @file_put_contents($pidfile, getmypid()); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); if (!is_numeric($EnableRemoteStatisticsAppliance)) { $EnableRemoteStatisticsAppliance = 0; } if ($EnableRemoteStatisticsAppliance == 0) { if ($GLOBALS["VERBOSE"]) { WriteMyLogs("EnableRemoteStatisticsAppliance: {$EnableRemoteStatisticsAppliance} = 0"); echo "EnableRemoteStatisticsAppliance: {$EnableRemoteStatisticsAppliance} = 0\n"; } return; } if (!$GLOBALS["VERBOSE"]) { $time = $unix->file_time_min($pidTime); if ($time < 3) { writelogs("Accepted only betwee, 3mn each...", __FUNCTION__, __FILE__, __LINE__); return; } } @unlink($pidTime); @file_put_contents($pidTime, time()); if ($GLOBALS["OUTPUT"]) { echo "Ping the remote appliance...\n"; } $net = new netagent(); WriteMyLogs("->ping()..."); $net->ping(); }