本文整理汇总了PHP中unix::squidclient方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::squidclient方法的具体用法?PHP unix::squidclient怎么用?PHP unix::squidclient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::squidclient方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: squidclient_mgr_storedir
function squidclient_mgr_storedir()
{
$unix = new unix();
$data = $unix->squidclient("storedir", true);
@unlink("/usr/share/artica-postfix/ressources/logs/web/storedir.cache");
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/storedir.cache", $data);
}
示例2: unix
}
$unix = new unix();
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".MAIN.time";
$time = $unix->file_time_min($pidtime);
if (!$GLOBALS["FORCE"]) {
if ($GLOBALS["VERBOSE"]) {
echo "Current {$time}Mn, need 5mn\n";
}
if ($time < 5) {
return;
}
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
$MAIN = array();
$data = $unix->squidclient("client_list");
if ($data == null) {
return;
}
$f = explode("\n", $data);
while (list($index, $line) = each($f)) {
$line = trim($line);
if ($line == null) {
continue;
}
if (preg_match("#ICP Requests#", $line, $re)) {
continue;
}
if (preg_match("#Address:\\s+([0-9\\.]+)#", $line, $re)) {
$IPADDR = $re[1];
continue;
示例3: redirectors_array
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");
}
}
}
示例4: die
#!/usr/bin/php -q
<?php
if (posix_getuid() != 0) {
die("Cannot be used in web server mode\n\n");
}
$GLOBALS["AS_ROOT"] = true;
$GLOBALS["MYPID"] = getmypid();
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . '/framework/frame.class.inc';
include_once dirname(__FILE__) . '/framework/class.settings.inc';
$unix = new unix();
echo $unix->squidclient("info");
示例5: ipcache
function ipcache()
{
$unix = new unix();
echo "<articadatascgi>" . base64_encode($unix->squidclient("ipcache")) . "</articadatascgi>";
}
示例6: purge_dns
function purge_dns()
{
$unix = new unix();
$pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if (!$GLOBALS["VERBOSE"]) {
$pid = $unix->get_pid_from_file($pidFile);
if ($unix->process_exists($pid, __FILE__)) {
return false;
}
}
@file_put_contents($pidFile, getmypid());
$PP = $unix->squid_internal_port();
$squidclient = $unix->find_program("squidclient");
$cmdrix = "{$squidclient} -l 127.0.0.1 -T 5 -h 127.0.0.1 -p {$PP} -m PURGE ";
$data = $unix->squidclient("ipcache");
$f = explode("\n", $data);
while (list($index, $line) = each($f)) {
if (!preg_match("#^(.+?)\\s+.*?\\(#", $line, $re)) {
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "Matches {$re[1]}\n";
}
$re[1] = trim($re[1]);
$cmd = "{$cmdrix} http://{$re[1]}";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
shell_exec($cmd);
$cmd = "{$cmdrix} https://{$re[1]}";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
shell_exec($cmd);
}
}
示例7: redirectors_array
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"));
$MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
$MonitConfig = watchdog_config_default($MonitConfig);
if ($MonitConfig["watchdog"] == 0) {
return;
}
$redirector = array();
$RedirectorsArray = unserialize(base64_decode($sock->GET_INFO("SquidRedirectorsOptions")));
if (!is_numeric($RedirectorsArray["url_rewrite_children"])) {
$RedirectorsArray["url_rewrite_children"] = 20;
}
$PERCENTS = array();
while (list($index, $line) = each($datas)) {
if (preg_match("#by kid([0-9]+)#", $line, $re)) {
$KID = "Processor #{$re[1]}";
}
if (preg_match("#number active:\\s+([0-9]+)\\s+of\\s+([0-9]+)#i", $line, $re)) {
$max = $re[2];
$Current = $re[1];
$percent = $Current / $max;
$percent = $percent * 100;
$LOGs[] = "{$KID}: {$Current}/{$max} = {$percent}%";
Events("{$line} {$Current}/{$max} = {$percent}%");
$PERCENTS[] = round($percent);
}
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;
}
$re[6] = trim($re[6]);
$re[3] = trim($re[3]);
$re[6] = str_replace(" ", "", $re[6]);
$fflosg[] = $re[3];
if ($GLOBALS["VERBOSE"]) {
echo "STATE \"{$re[6]}\"\n";
}
if ($re[6] == "BS") {
$unix->KILL_PROCESS($re[3], 9);
if ($GLOBALS["VERBOSE"]) {
echo "KILLING \"{$re[3]}\"\n";
}
}
if ($re[6] == "S") {
$unix->KILL_PROCESS($re[3], 9);
if ($GLOBALS["VERBOSE"]) {
echo "KILLING \"{$re[3]}\"\n";
}
}
$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]);
}
$FFperc = 0;
$FINAL_PERC = 0;
$CountOFPercent = count($PERCENTS);
if (count($PERCENTS > 0)) {
while (list($index, $pp) = each($PERCENTS)) {
$FFperc = $FFperc + $pp;
}
$FINAL_PERC = round($FFperc / $CountOFPercent, 2);
$LOGs[] = "************************************************";
$LOGs[] = "ALL CPUS: {$FINAL_PERC}%";
$LOGs[] = "";
}
if ($FINAL_PERC > 90) {
$severity = 1;
$action = "notify";
$NotifyTimeEx = $unix->file_time_min($NotifyTime);
if ($NotifyTimeEx < 10) {
return;
}
@unlink($NotifyTime);
@file_put_contents($NotifyTime, time());
if ($FINAL_PERC > 95) {
$severity = 1;
$action = "reload";
}
Events("{$line} {$Current}/{$max} severity = {$severity}");
squid_admin_mysql($severity, "Warning! redirectors reach {$FINAL_PERC}% [action={$action}]", @implode("\n", $LOGs) . "\n\n---------------------------------\n\n" . @implode("\n", $datas));
if ($severity == 0) {
shell_exec("/etc/init.d/squid reload --script=" . basename(__FILE__));
return;
}
}
@unlink($cache_file);
//.........这里部分代码省略.........