query("SELECT DISTINCT(`pid`) AS `pid` FROM `streams_sys` WHERE `pid` > 0 AND `pid` IS NOT NULL AND `server_id` = ".intval($_INFO["server_id"]).";"); if (($result) && ($result->num_rows > 0)) { while ($row = $result->fetch_assoc()) { $rPIDs[] = $row["pid"]; } } $result = $db->query("SELECT DISTINCT(`monitor_pid`) AS `pid` FROM `streams_sys` WHERE `monitor_pid` > 0 AND `monitor_pid` IS NOT NULL AND `server_id` = ".intval($_INFO["server_id"]).";"); if (($result) && ($result->num_rows > 0)) { while ($row = $result->fetch_assoc()) { $rPIDs[] = $row["pid"]; } } $result = $db->query("SELECT DISTINCT(`delay_pid`) AS `pid` FROM `streams_sys` WHERE `delay_pid` > 0 AND `delay_pid` IS NOT NULL AND `server_id` = ".intval($_INFO["server_id"]).";"); if (($result) && ($result->num_rows > 0)) { while ($row = $result->fetch_assoc()) { $rPIDs[] = $row["pid"]; } } $result = $db->query("SELECT DISTINCT(`tv_archive_pid`) AS `pid` FROM `streams` WHERE `tv_archive_pid` > 0 AND `tv_archive_pid` IS NOT NULL AND `tv_archive_server_id` = ".intval($_INFO["server_id"]).";"); if (($result) && ($result->num_rows > 0)) { while ($row = $result->fetch_assoc()) { $rPIDs[] = $row["pid"]; } } $result = $db->query("SELECT DISTINCT(`pid`) AS `pid` FROM `user_activity_now` WHERE `pid` > 0 AND `pid` IS NOT NULL AND `server_id` = ".intval($_INFO["server_id"]).";"); if (($result) && ($result->num_rows > 0)) { while ($row = $result->fetch_assoc()) { $rPIDs[] = $row["pid"]; } } echo count($rPIDs)." required processes found\n"; // Kill redundant PID's. foreach ($rLive as $rPID) { if (!in_array($rPID, $rPIDs)) { echo "Killed redundant process ".$rPID."\n"; shell_exec("kill -9 ".$rPID); } } ?>