function redirectors_array($aspid = false)
{
    $cache_file = "/usr/share/artica-postfix/ressources/logs/web/squid_redirectors_status.db";
    $NotifyTime = "/etc/artica-postfix/pids/squid.redirectors.notify";
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    if ($aspid) {
        $pid = $unix->get_pid_from_file($pidFile);
        if ($unix->process_exists($pid)) {
            $pptime = $unix->PROCCESS_TIME_MIN($pid, 10);
            if ($GLOBALS["VERBOSE"]) {
                echo "Process already running PID {$pid} since {$pptime}Mn\n";
            }
            return;
        }
        @file_put_contents($pidFile, getmypid());
    }
    $sock = new sockets();
    $datas = explode("\n", $unix->squidclient("redirector"));
    $redirector = array();
    $RedirectorsArray = unserialize(base64_decode($sock->GET_INFO("SquidRedirectorsOptions")));
    if (!is_numeric($RedirectorsArray["url_rewrite_children"])) {
        $RedirectorsArray["url_rewrite_children"] = 20;
    }
    while (list($index, $line) = each($datas)) {
        if (!preg_match("#([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)(.*?)\\s+([0-9\\.]+)\\s+([0-9\\.]+)\\s+(.*)#", $line, $re)) {
            continue;
        }
        $redirector[$re[1]] = array("FD" => $re[2], "PID" => $re[3], "REQ" => $re[4], "REP" => $re[5], "STATE" => $re[6], "TIME" => $re[7], "OFFSET" => $re[8], "URI" => $re[9]);
    }
    @unlink($cache_file);
    if (count($redirector) == 0) {
        return;
    }
    @file_put_contents($cache_file, serialize($redirector));
    @chmod($cache_file, 0755);
    $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
    $MonitConfig = watchdog_config_default($MonitConfig);
    if ($MonitConfig["watchdog"] == 0) {
        return;
    }
    $percent = count($redirector) / intval($RedirectorsArray["url_rewrite_children"]);
    $percent = $percent * 100;
    if ($GLOBALS["VERBOSE"]) {
        echo count($redirector) . "/{$RedirectorsArray["url_rewrite_children"]} = {$percent}%\n";
    }
    if ($percent > 90) {
        $severity = 1;
        $action = "notify";
        $NotifyTimeEx = $unix->file_time_min($NotifyTime);
        if ($NotifyTimeEx < 10) {
            return;
        }
        @unlink($NotifyTime);
        @file_put_contents($NotifyTime, time());
        if ($percent > 95) {
            $severity = 0;
            $action = "reload";
        }
        squid_admin_mysql($severity, "Warning! redirectors reach {$percent}% [action={$action}]", @implode("\n", $datas));
        if ($severity == 0) {
            shell_exec($unix->LOCATE_SQUID_BIN() . " -f /etc/squid3/squid.conf -k reconfigure");
        }
    }
}
function dev_shm()
{
    $NotifyTime = "/etc/artica-postfix/pids/squid.dev.shm";
    if (!is_dir("/run/shm")) {
        return;
    }
    $sock = new sockets();
    $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
    $MonitConfig = watchdog_config_default($MonitConfig);
    $unix = new unix();
    $percent = $unix->TMPFS_USEPERCENT("/run/shm");
    @file_put_contents("/etc/artica-postfix/settings/Daemons/StatusDevSHMPerc", $percent);
    @chmod("/etc/artica-postfix/settings/Daemons/StatusDevSHMPerc", 0755);
    if ($percent > 90) {
        if ($percent < 98) {
            $NotifyTimeEx = $unix->file_time_min($NotifyTime);
            if ($NotifyTimeEx > 10) {
                squid_admin_mysql(2, "Warning Shared memory exceed 90%!", "The /dev/shm memory partition exceed 90%, at 100% the proxy will crash!");
                return;
            }
        }
    }
    if ($percent > 98) {
        if ($MonitConfig["watchdog"] == 1) {
            squid_admin_mysql(0, "Warning Shared memory exceed 98% ({$percent}%)[action=restart]", "The /dev/shm memory partition exceed 98%, at 100% the proxy will crash!, in this case, the proxy will be restarted.");
            $GLOBALS["BY_OTHER_SCRIPT"] = "function SHM";
            $GLOBALS["FORCE"] = true;
            restart_squid(true);
        } else {
            squid_admin_mysql(0, "Warning Shared memory exceed 98% ({$percent}%) [action=notify]", "The /dev/shm memory partition exceed 98%, at 100% the proxy will crash!");
        }
    }
}