function cache_center_status($aspid = false) { $unix = new unix(); if ($GLOBALS["VERBOSE"]) { echo "Running cache_center_status()\n"; $aspid = true; } if (!$aspid) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . "Already `task` running PID {$pid} since {$time}mn\n"; } system_admin_events("stop_squid::Already task running PID {$pid} since {$time}mn", __FUNCTION__, __FILE__, __LINE__, "proxy"); return; } @file_put_contents($pidfile, getmypid()); } $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { echo "TimeFile={$TimeFile}\n"; } $Time = $unix->file_time_min($TimeFile); if (!$GLOBALS["VERBOSE"]) { if ($Time < 5) { return; } } @unlink($TimeFile); @file_put_contents($TimeFile, time()); $ARRAY = unserialize(base64_decode(squid_get_storage_info())); $q = new mysql(); while (list($directory, $arrayStore) = each($ARRAY)) { $arrayStore["USED"] = intval($arrayStore["USED"]); $arrayStore["PERC"] = intval($arrayStore["PERC"]); if ($arrayStore["USED"] == 0 && $arrayStore["PERC"] > 0) { $arrayStore["USED"] = $unix->DIRSIZE_BYTES($directory); } if ($GLOBALS["VERBOSE"]) { echo "{$directory} USED {$arrayStore["USED"]} PERC:{$arrayStore["PERC"]}\n"; } if ($directory == "MEM") { continue; } if ($arrayStore["USED"] == 0) { continue; } $PERC = $arrayStore["PERC"]; $USED = $arrayStore["USED"]; if (preg_match("#\\/home\\/squid\\/cache\\/MemBooster([0-9]+)#", $directory, $re)) { $q->QUERY_SQL("UPDATE squid_caches_center SET percentcache='{$PERC}',percenttext='{$PERC}', \n\t\t\t\t\t`usedcache`='{$USED}' WHERE ID={$re[1]}", "artica_backup"); continue; } if ($GLOBALS["VERBOSE"]) { echo "{$directory} -> {$USED} / {$PERC}%\n"; } $q->QUERY_SQL("UPDATE squid_caches_center SET \n\t\t\t\tpercentcache='{$PERC}',percenttext='{$PERC}', `usedcache`='{$USED}' WHERE \n\t\t\t\t`cache_dir`='{$directory}'", "artica_backup"); } }
exit; } if (isset($_GET["catzdb-changedir"])) { catzdb_changedir(); exit; } if (isset($_GET["ufdbclient"])) { ufdbclient_tests(); exit; } if (isset($_GET["squid-get-system-info"])) { squid_get_system_info(); exit; } if (isset($_GET["squid-get-storage-info"])) { squid_get_storage_info(); exit; } if (isset($_GET["MacToUidStats"])) { MacToUidStats(); exit; } if (isset($_GET["MacToUid"])) { MacToUid(); exit; } if (isset($_GET["watchdog-log"])) { watchdoglogs(); exit; } if (isset($_GET["artica-db-restart"])) {