Esempio n. 1
0
     if (strpos($buffer, "RELEASE -1") > 0) {
         $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
         continue;
     }
     if (strpos($buffer, "RELEASE 00") > 0) {
         $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
         continue;
     }
     if (strpos($buffer, "SWAPOUT 00") > 0) {
         $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
         continue;
     }
     if ($GLOBALS["VERBOSE"]) {
         $time_start = microtime(true);
     }
     ParseSizeBuffer($buffer);
     if ($GLOBALS["VERBOSE"]) {
         $time_end = microtime(true);
         $time_calc = $time_end - $time_start;
     }
     if ($GLOBALS["VERBOSE"]) {
         events("ParseSizeBuffer = {$time_calc}ms");
     }
     $buffer = null;
     Wakeup();
     continue;
 }
 if (is_file("/var/run/squid/exec.logfilefile_daemon.{$GLOBALS["MYPID"]}.shutdown")) {
     events("Stopping loop PID:" . getmypid());
     @unlink("/var/run/squid/exec.logfilefile_daemon.{$GLOBALS["MYPID"]}.shutdown");
     break;
Esempio n. 2
0
function Parseline($buffer)
{
    if (!isset($GLOBALS["CACHE_TAIL_TIME"])) {
        $GLOBALS["CACHE_TAIL_TIME"] = time();
    }
    $cacheTailTime = tool_time_sec($GLOBALS["CACHE_TAIL_TIME"]);
    if ($cacheTailTime > 6) {
        @unlink("/etc/artica-postfix/cache-tail.time");
        @file_put_contents("/etc/artica-postfix/cache-tail.time", time());
        $GLOBALS["CACHE_TAIL_TIME"] = time();
    }
    if ($GLOBALS["COUNT_RQS"] == 0) {
        $GLOBALS["COUNT_RQS"] = 1;
    }
    $ctrqs = intval($GLOBALS["COUNT_RQS"]);
    $ctrqs++;
    $GLOBALS["COUNT_RQS"] = $ctrqs;
    if ($GLOBALS["COUNT_RQS_TIME"] == 0) {
        $GLOBALS["COUNT_RQS_TIME"] = time();
    }
    if ($GLOBALS["COUNT_RQS_TIME"] > 0) {
        if (tool_time_sec($GLOBALS["COUNT_RQS_TIME"]) > 15) {
            CleanReQsMin();
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        events(__LINE__ . " {$GLOBALS["COUNT_RQS"]} connexions");
    }
    if (strpos($buffer, "TCP_DENIED/403") > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (isset($GLOBALS["LOGACCESS_TIME"])) {
        CachedUserMemDump();
    }
    if (strpos($buffer, ":::HEAD:::") > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return;
    }
    if (strpos($buffer, "NONE:HIER_NONE") > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return;
    }
    if (strpos($buffer, "error:invalid-request") > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return;
    }
    if (strpos("NONE error:", $buffer) > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return;
    }
    if (strpos($buffer, "GET cache_object") > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (strpos($buffer, "cache_object://") > 0) {
        if ($GLOBALS["VERBOSE"]) {
            events("SKIP {$buffer}");
        }
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    $GLOBALS["WAKEUP_LOGS"] = $GLOBALS["WAKEUP_LOGS"] + 1;
    $currentMin = date("Y-m-d H:i:00");
    if (!isset($GLOBALS["REQS"][date("YmdHi")])) {
        $GLOBALS["REQS"][$currentMin] = 1;
    } else {
        $GLOBALS["REQS"][$currentMin] = $GLOBALS["REQS"][$currentMin] + 1;
    }
    if (count($GLOBALS["REQS"][$currentMin]) > 15) {
        CleanReQsMin();
    }
    if ($GLOBALS["WAKEUP_LOGS"] > 50) {
        if (!isset($GLOBALS["BEREKLEY_MEMORY_STATS"])) {
            $GLOBALS["BEREKLEY_MEMORY_STATS"] = 0;
        }
        events("{$GLOBALS["REFUSED_REQUESTS"]} refused requests " . "- {$GLOBALS["ACCEPTED_REQUESTS"]} accepted requests " . "- {$GLOBALS["COUNT_RQS"]}" . "- " . round($GLOBALS["BYTES_WRITE"] / 1024, 2) . " Ko written in logs");
        $GLOBALS["WAKEUP_LOGS"] = 0;
    }
    if (strpos($buffer, "TAG_NONE:HIER_NONE") > 0) {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (strpos($buffer, "TCP_MISS/000") > 0) {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (strpos($buffer, "TCP_DENIED:") > 0) {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (strpos($buffer, "RELEASE -1") > 0) {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (strpos($buffer, "RELEASE 00") > 0) {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if (strpos($buffer, "SWAPOUT 00") > 0) {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        return true;
    }
    if ($GLOBALS["VERBOSE"]) {
        $time_start = microtime(true);
    }
    ParseSizeBuffer($buffer);
    if ($GLOBALS["VERBOSE"]) {
        $time_end = microtime(true);
        $time_calc = $time_end - $time_start;
    }
    if ($GLOBALS["VERBOSE"]) {
        events("ParseSizeBuffer = {$time_calc}ms");
    }
    $buffer = null;
}