当前位置: 首页>>代码示例>>PHP>>正文


PHP squidbee::auth_param_ntlm_children方法代码示例

本文整理汇总了PHP中squidbee::auth_param_ntlm_children方法的典型用法代码示例。如果您正苦于以下问题:PHP squidbee::auth_param_ntlm_children方法的具体用法?PHP squidbee::auth_param_ntlm_children怎么用?PHP squidbee::auth_param_ntlm_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在squidbee的用法示例。


在下文中一共展示了squidbee::auth_param_ntlm_children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ntlmauthenticator

function ntlmauthenticator()
{
    $sock = new sockets();
    $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
    $MonitConfig = watchdog_config_default($MonitConfig);
    $unix = new unix();
    $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/ntlmauthenticator.cache";
    if (!$unix->isSquidNTLM()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "NOT an NTLM proxy\n";
        }
        @unlink($cacheFile);
        return;
    }
    $ADDNNEW = false;
    $datas = explode("\n", $unix->squidclient("ntlmauthenticator"));
    $CPU_NUMBER = 1;
    $ARRAY = array();
    if ($GLOBALS["VERBOSE"]) {
        echo "Watchdog enabled: {$MonitConfig["watchdog"]}\n";
    }
    while (list($num, $ligne) = each($datas)) {
        if (preg_match("#by kid([0-9]+)#", $ligne, $re)) {
            $CPU_NUMBER = $re[1];
            continue;
        }
        if (preg_match("#number active: ([0-9]+) of ([0-9]+)#", $ligne, $re)) {
            $Active = intval($re[1]);
            $Max = intval($re[2]);
            $prc = round($Active / $Max * 100);
            $ARRAY[$CPU_NUMBER] = $prc;
        }
    }
    if (count($ARRAY) == 0) {
        return;
    }
    if ($MonitConfig["watchdog"] == 1) {
        while (list($CPU, $PRC) = each($ARRAY)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "CPU.{$CPU} = {$PRC}%\n";
            }
            Events("ntlmauthenticator: CPU.{$CPU} = {$PRC}%");
            $LOG[] = "Instance on CPU {$CPU} is {$PRC}% used.";
            if ($PRC > 94) {
                if ($Max + 5 < 151) {
                    $NewMax = $Max + 5;
                    $ADDNNEW = true;
                    squid_admin_mysql(2, "NTLM Authenticator on CPU {$CPU} reach 95%", "Artica will increase your ntlm authenticator processes to {$NewMax} instances \n\t\t\t\t\tper CPU and reload the Proxy service\r\nCurrent status:\r\n" . @implode("\r\n", $LOG));
                }
            }
        }
    }
    if ($ADDNNEW) {
        if ($NewMax > 0) {
            $squid = new squidbee();
            $SquidClientParams = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidClientParams")));
            $Old = $squid->auth_param_ntlm_children();
            $SquidClientParams["auth_param_ntlm_children"] = $NewMax;
            $SquidClientParams["auth_param_ntlm_startup"] = round($NewMax * 0.2);
            @file_put_contents("/etc/artica-postfix/settings/Daemons/SquidClientParams", base64_encode(serialize($SquidClientParams)));
            if (ntlmauthenticator_edit($NewMax)) {
                $squid = $unix->LOCATE_SQUID_BIN();
                $php = $unix->LOCATE_PHP5_BIN();
                if (function_exists("debug_backtrace")) {
                    $trace = debug_backtrace();
                    if (isset($trace[1])) {
                        $file = basename($trace[1]["file"]);
                        $function = $trace[1]["function"];
                        $line = $trace[1]["line"];
                        $called = "Called by {$function}() from line {$line}";
                    }
                }
                squid_admin_mysql(1, "Reconfiguring squid-cache Increase NTLM From {$Old} to {$NewMax}", "{$called}");
                shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
            }
        }
    }
    @file_put_contents($cacheFile, serialize($ARRAY));
    @chmod($cacheFile, 0755);
}
开发者ID:articatech,项目名称:artica,代码行数:80,代码来源:exec.squid.watchdog.php


注:本文中的squidbee::auth_param_ntlm_children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。