本文整理汇总了PHP中unix::squid_get_cache_infos方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::squid_get_cache_infos方法的具体用法?PHP unix::squid_get_cache_infos怎么用?PHP unix::squid_get_cache_infos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::squid_get_cache_infos方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SendStatus
//.........这里部分代码省略.........
if (!is_file("/etc/artica-postfix/sarg.tgz")) {
shell_exec("cd {$SargOutputDir} && tar -cjf /etc/artica-postfix/sarg.tgz ./*");
$push_sarg = true;
} else {
if ($ArrayFileCache["SQUID_SARG"] != filemtime("{$SargOutputDir}/index.html")) {
@unlink("/etc/artica-postfix/sarg.tgz");
shell_exec("cd {$SargOutputDir} && tar -cjf /etc/artica-postfix/sarg.tgz ./*");
$push_sarg = true;
}
}
if ($push_sarg) {
$http->uploads["SQUID_SARG"] = "/etc/artica-postfix/sarg.tgz";
}
}
}
$users = new usersMenus();
$status = base64_encode(serialize($ini->_params));
$pasmoinsaux = pasmoinsaux();
if ($users->VMWARE_HOST) {
$VMWARE_HOST = 1;
} else {
$VMWARE_HOST = 0;
}
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.dmidecode.php");
$dmidecode = base64_encode(@file_get_contents("/etc/artica-postfix/dmidecode.cache"));
//SQUID
if ($users->SQUID_INSTALLED) {
$sock = new sockets();
$SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
if (!is_numeric($SQUIDEnable)) {
$SQUIDEnable = 1;
}
if ($SQUIDEnable == 1) {
$SQUID_CACHES = base64_encode(serialize($unix->squid_get_cache_infos()));
}
if (is_array($SQUID_CACHES)) {
$squid = new squidbee();
$cacheconf = $squid->cache_list;
$cacheconf[$squid->CACHE_PATH]["cache_type"] = $squid->CACHE_TYPE;
$cacheconf[$squid->CACHE_PATH]["cache_size"] = $squid->CACHE_SIZE;
$cacheconf[$squid->CACHE_PATH]["cache_dir_level1"] = 16;
$cacheconf[$squid->CACHE_PATH]["cache_dir_level2"] = 256;
events("Caches: " . count($cacheconf), __FILE__, __LINE__);
$SQUID_CACHES_CONFIG = base64_encode(serialize($cacheconf));
}
}
if ($users->SAMBA_INSTALLED) {
_CheckSambaConfig();
}
if ($users->ZARAFA_INSTALLED) {
if (is_file("/etc/artica-postfix/settings/Daemons/ZarafaLicenseInfos")) {
$ZARAFA_LICENSE = @file_get_contents("/etc/artica-postfix/settings/Daemons/ZarafaLicenseInfos");
} else {
$ZARAFA_LICENSE = "Free edition";
}
}
if (is_file("/etc/artica-postfix/zarafa-export.db")) {
$ZARAFA_DB = @file_get_contents("/etc/artica-postfix/zarafa-export.db");
}
$body = $http->send("{$meta->ArticaMetaHostname}/lic.status.server.php", "post", array("DATAS" => $datasToSend, "STATUS" => $status, "MEMORIES" => $MEM_CACHE, "VERSION" => $users->ARTICA_VERSION, "DISTRI" => $users->LinuxDistriCode, "UPTIME" => getUptime(), "DISTRINAME" => $users->LinuxDistriFullName, "MAIN_PRODUCTS" => base64_encode(serialize(array("ZARAFA" => $users->ZARAFA_INSTALLED, "POSTFIX" => $users->POSTFIX_INSTALLED, "SQUID" => $users->SQUID_INSTALLED, "SAMBA" => $users->SAMBA_INSTALLED, "CYRUS" => $users->cyrus_imapd_installed, "OPENVPN" => $users->OPENVPN_INSTALLED))), "PROCESSES" => base64_encode($pasmoinsaux), "TOP_PROCESSES" => top10cpumem(), "NETS" => Networks(), "VMWARE_HOST" => $VMWARE_HOST, "SETTINGS_INC" => base64_encode(serialize(settings_inc())), "LOCAL_VERSIONS" => LocalVersions(), "VBOXGUESTS" => VirtualBoxList(), "APTCHECK" => APTCHECK(), "DMIDECODE" => $dmidecode, "SQUID_CACHES" => $SQUID_CACHES, "SQUID_CACHES_CONFIG" => $SQUID_CACHES_CONFIG, "OPENPORTS" => OpenPorts($meta->serial, $meta->uuid), "OPENVPN_CLIENTS_STATUS" => @file_get_contents("/usr/share/artica-postfix/ressources/logs/openvpn-clients.status"), "ZARAFA_DB" => $ZARAFA_DB, "ZARAFA_LICENSE" => $ZARAFA_LICENSE));
$EXEC_NICE = EXEC_NICE();
if (is_file("/usr/bin/nohup")) {
$nohup = "/usr/bin/nohup ";
}
if (preg_match("#NOTIFY_DISCONNECT#is", $body)) {
events("NOTIFY_DISCONNECT detected -> unregister_server()", __FUNCTION__, __FILE__, __LINE__);
示例2: verifycaches
function verifycaches()
{
$logFile = "/usr/share/artica-postfix/ressources/logs/web/rebuild-cache.txt";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
$unix = new unix();
$sock = new sockets();
if ($unix->process_exists($pid, basename(__FILE__))) {
ouputz("Already process exists {$pid}, aborting", __LINE__);
build_progress("Already process exists {$pid}, aborting", 110);
die;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
@unlink($logFile);
build_progress("Listing caches....", 10);
$cache = new SquidCacheCenter();
$mv = $unix->find_program("mv");
$rm = $unix->find_program("rm");
$php5 = $unix->LOCATE_PHP5_BIN();
$caches = $cache->build();
$http_port = rand(55000, 65000);
$f = array();
$f[] = "cache_effective_user squid";
$f[] = "pid_filename\t/var/run/squid-temp.pid";
$f[] = "http_port 127.0.0.1:{$http_port}";
$f[] = "{$caches}";
$f[] = "";
$squidconf = "/etc/squid3/squid.caches.conf";
@file_put_contents($squidconf, @implode("\n", $f));
build_progress("Generating caches {please_wait}", 25);
$squidbin = $unix->LOCATE_SQUID_BIN();
$su = $unix->find_program("su");
$results = array();
$cmd = "{$su} -c \"{$squidbin} -f {$squidconf} -z\" squid";
ouputz("Building new caches {$cmd}", __LINE__);
system($cmd);
@unlink($squidconf);
build_progress("{reconfigure}", 50);
system("{$php5} /usr/share/artica-postfix/exec.squid.php --build --force");
build_progress("{restarting}", 60);
system("/etc/init.d/squid restart");
for ($i = 0; $i < 30; $i++) {
$array = $unix->squid_get_cache_infos();
if (count($array) > 0) {
break;
}
build_progress("{waiting_proxy_status} {$i}/29", 50);
writelogs("Waiting 1s to squid be ready...", __FUNCTION__, __FILE__, __LINE__);
sleep(1);
}
build_progress("{waiting_proxy_status} {$i}/29", 60);
system("{$php5} /usr/share/artica-postfix/exec.squid.php --cache-infos --force");
$q = new mysql();
$sql = "SELECT * FROM squid_caches_center WHERE remove=1";
$results = $q->QUERY_SQL($sql, "artica_backup");
while ($ligne = mysql_fetch_assoc($results)) {
$cache_type = $ligne["cache_type"];
$cache_size = $ligne["cache_size"];
$cachename = $ligne["cachename"];
$ID = $ligne["ID"];
if ($cache_type == "Cachenull") {
continue;
}
if ($cache_type == "tmpfs") {
$ligne["cache_dir"] = "/home/squid/cache/MemBooster{$ID}";
}
$Directory = $ligne["cache_dir"];
build_progress("{remove} {$Directory}", 80);
if (is_dir($Directory)) {
system("{$rm} -rf {$Directory}");
}
$q->QUERY_SQL("DELETE FROM squid_caches_center WHERE ID='{$ID}'", "artica_backup");
}
build_progress("{done}", 100);
}
示例3: rebuildcaches
//.........这里部分代码省略.........
$squidbin = $unix->LOCATE_SQUID_BIN();
if (!is_file($squidbin)) {
ouputz("squid, no such binary file", __LINE__);
@unlink("/etc/artica-postfix/squid.lock");
return;
}
build_progress("{stopping_proxy_service}", 20);
squid_admin_mysql(1, "Stopping Proxy service in order to rebuild caches", null, __FILE__, __LINE__);
ouputz("Stopping squid, please wait...", __LINE__);
if (function_exists("debug_backtrace")) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$sourcefunction = $trace[1]["function"];
$sourceline = $trace[1]["line"];
$executed = "Executed by {$sourcefunction}() line {$sourceline}\nusing argv:{$GLOBALS["ARGVS"]}\n";
}
}
shell_exec("/etc/init.d/squid stop --force --script=" . basename(__FILE__));
if ($GLOBALS["REPORT"]) {
while (list($cache_dir, $ligne) = each($array)) {
$DIRARRAY = $unix->DIR_STATUS($cache_dir);
$size = $array["SIZE"];
$used = $array["USED"];
$pourc = $array["POURC"];
$mounted = $array["MOUNTED"];
$logs[] = "{$cache_dir} size: {$size}, used:{$used} {$pourc}% mounted on {$mounted}";
}
squid_admin_mysql(2, "Report on caches status", @implode("\n", $logs), __FILE__, __LINE__);
}
reset($array);
while (list($cache_dir, $ligne) = each($array)) {
build_progress("Checking {$cache_dir}", 30);
if (preg_match("#MemBooster#", $cache_dir)) {
squid_admin_mysql(1, "Removing cache {$cache_dir}", null, __FILE__, __LINE__);
ouputz("Removing {$cache_dir} content...", __LINE__);
squid_admin_mysql(2, "Removing cache {$cache_dir} done", null, __FILE__, __LINE__);
shell_exec("{$rm} -rf {$cache_dir}/*");
continue;
}
$DISK_STATUS = $unix->DF_SATUS_K($cache_dir);
$DIRECTORY_SIZE = $unix->DIRSIZE_BYTES($cache_dir) / 1024 / 1024;
$AIVA = $DISK_STATUS["AIVA"] * 1024;
ouputz("Removing {$cache_dir} '{$DIRECTORY_SIZE}'M Available {$AIVA}M", __LINE__);
shell_exec("{$rm} -rf {$cache_dir}");
ouputz("re-create {$cache_dir}", __LINE__);
squid_admin_mysql(2, "Re-create {$cache_dir}", null, __FILE__, __LINE__);
@mkdir($cache_dir, 0755, true);
@chown($cache_dir, "squid");
@chgrp($cache_dir, "squid");
}
$su = $unix->find_program("su");
$results = array();
build_progress("Create {$cache_dir}", 30);
ouputz("Building new caches {$su} -c \"{$squidbin} -z\" squid", __LINE__);
exec("{$su} -c \"{$squidbin} -z\" squid 2>&1", $results);
while (list($num, $ligne) = each($results)) {
ouputz("{$ligne}", __LINE__);
}
ouputz("Remove lock file...", __LINE__);
@unlink("/etc/artica-postfix/squid.lock");
ouputz("Starting squid, please wait...", __LINE__);
build_progress("{starting_proxy_service}", 35);
if (function_exists("debug_backtrace")) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$sourcefunction = $trace[1]["function"];
$sourceline = $trace[1]["line"];
$executed = "Executed by {$sourcefunction}() line {$sourceline}\nusing argv:{$GLOBALS["ARGVS"]}\n";
}
}
squid_admin_mysql(2, "Starting Proxy Service after rebuilding caches", null, __FILE__, __LINE__);
shell_exec("{$php5} /usr/share/artica-postfix/exec.squid.watchdog.php --start --script=" . basename(__FILE__));
for ($i = 0; $i < 60; $i++) {
$array = $unix->squid_get_cache_infos();
if (count($array) > 0) {
break;
}
ouputz("Waiting {$i}s/60 cache is not ready...", __LINE__);
sleep(1);
}
ouputz("Done... Squid-cache seems to be ready...", __LINE__);
$NICE = $unix->EXEC_NICE();
$nohup = $unix->find_program("nohup");
build_progress("Refresh caches infos...", 50);
ouputz("Refresh caches information, please wait...", __LINE__);
shell_exec("{$php5} /usr/share/artica-postfix/exec.squid.php --cache-infos --force");
if (is_array($cachesRename)) {
reset($cachesRename);
while (list($index, $cache_dir) = each($cachesRename)) {
build_progress("Removing old {$cache_dir}", 60);
$cmd = "{$NICE} {$rm} -rf {$cache_dir} >/dev/null 2>&1 &";
squid_admin_mysql(2, "Ask to delete old cache dir {$cache_dir} done", "{$called}", __FILE__, __LINE__);
ouputz("Deleting {$cache_dir} {$cmd}", __LINE__);
shell_exec($cmd);
}
}
build_progress("{done}", 100);
$took = $unix->distanceOfTimeInWords($t, time());
squid_admin_mysql(2, "All Proxy caches was rebuilded took: {$took}", "{$called}", __FILE__, __LINE__);
}
示例4: caches_infos
function caches_infos($aspid = false)
{
$cacheFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$cachePID = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if ($GLOBALS["FORCE"]) {
ToSyslog("caches_infos(): Executed in force mode");
}
$unix = new unix();
$sock = new sockets();
if (!$GLOBALS["VERBOSE"]) {
if (system_is_overloaded(basename(__FILE__))) {
EventsWatchdog("Overloaded system, aborting task...");
ToSyslog("caches_infos(): Overloaded system, aborting task");
writelogs("Overloaded system, aborting task...", __FUNCTION__, __FILE__, __LINE__);
return;
}
if ($aspid) {
$pid = @file_get_contents($cachePID);
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($timepid < 15) {
ToSyslog("caches_infos(): Already task PID: {$pid} running since {$timepid}Mn");
}
$kill = $unix->find_program("{$kill}");
unix_system_kill_force($pid);
}
}
}
if ($GLOBALS["VERBOSE"]) {
echo "init...\n";
}
$q = new mysql_squid_builder();
if (!$GLOBALS["FORCE"]) {
$CacheTime = $unix->file_time_min($cacheFile);
if ($CacheTime < 15) {
EventsWatchdog("Max 15Mn, current={$CacheTime} ({$cacheFile})...");
if ($GLOBALS["VERBOSE"]) {
echo "Max 15Mn, current={$CacheTime}\n";
}
return;
}
}
$squid_pid = SQUID_PID();
if (!$unix->process_exists($squid_pid)) {
$nohup = $unix->find_program("nohup");
squid_admin_mysql(0, "Squid-Cache is not running..., start it", null, __FILE__, __LINE__);
ToSyslog("caches_infos(): Squid-Cache is not running..., start it");
shell_exec("{$nohup} /etc/init.d/squid start >/dev/null 2>&1 &");
return;
}
@unlink($cacheFile);
@file_put_contents($cacheFile, time());
$ttl = $unix->PROCCESS_TIME_MIN($squid_pid);
if ($unix->PROCCESS_TIME_MIN($squid_pid) < 5) {
ToSyslog("caches_infos(): squid-cache running only since {$ttl}mn, aborting");
return;
}
ToSyslog("caches_infos(): Starting get Squid-cache informations.");
$array = $unix->squid_get_cache_infos();
for ($i = 0; $i < 10; $i++) {
$check = true;
if (!is_array($array)) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() Not an array...\n";
}
$check = false;
sleep(1);
$array = $unix->squid_get_cache_infos();
continue;
}
if (count($array) == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() O items !!\n";
}
$check = false;
sleep(1);
$array = $unix->squid_get_cache_infos();
continue;
}
if ($check) {
break;
}
}
if (!is_array($array)) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() Not an array...\n";
}
return;
}
if (count($array) == 0) {
if ($GLOBALS["VERBOSE"]) {
echo basename(__FILE__) . "[" . __LINE__ . "] unix->squid_get_cache_infos() O items !!...\n";
}
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
return;
}
@unlink("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db");
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
//.........这里部分代码省略.........
示例5: caches_infos
function caches_infos()
{
$unix = new unix();
$squid_pid = SQUID_PID();
if (!$unix->process_exists($squid_pid)) {
$nohup = $unix->find_program("nohup");
squid_admin_mysql(0, "Squid-Cache is not running...", null, __FILE__, __LINE__);
return;
}
$ttl = $unix->PROCCESS_TIME_MIN($squid_pid);
if ($unix->PROCCESS_TIME_MIN($squid_pid) < 5) {
ToSyslog("caches_infos(): squid-cache running only since {$ttl}mn, aborting");
return;
}
ToSyslog("caches_infos(): Starting get Squid-cache informations.");
$array = $unix->squid_get_cache_infos();
for ($i = 0; $i < 10; $i++) {
$check = true;
if (!is_array($array)) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() Not an array...\n";
}
$check = false;
sleep(1);
$array = $unix->squid_get_cache_infos();
continue;
}
if (count($array) == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() O items !!\n";
}
$check = false;
sleep(1);
$array = $unix->squid_get_cache_infos();
continue;
}
if ($check) {
break;
}
}
if (!is_array($array)) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() Not an array...\n";
}
return;
}
if (count($array) == 0) {
if ($GLOBALS["VERBOSE"]) {
echo basename(__FILE__) . "[" . __LINE__ . "] unix->squid_get_cache_infos() O items !!...\n";
}
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
return;
}
@unlink("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db");
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
$q = new mysql_squid_builder();
$uuid = $unix->GetUniqueID();
$profix = "INSERT IGNORE INTO cachestatus(uuid,cachedir,maxsize,currentsize,pourc) VALUES ";
while (list($directory, $arrayDir) = each($array)) {
$directory = trim($directory);
if ($directory == null) {
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "('{$uuid}','{$directory}','{$arrayDir["MAX"]}','{$arrayDir["CURRENT"]}','{$arrayDir["POURC"]}')\n";
}
$f[] = "('{$uuid}','{$directory}','{$arrayDir["MAX"]}','{$arrayDir["CURRENT"]}','{$arrayDir["POURC"]}')";
}
if (count($f) > 0) {
$q->QUERY_SQL("TRUNCATE TABLE cachestatus");
$q->QUERY_SQL("{$profix}" . @implode(",", $f));
if (!$q->ok) {
echo $q->mysql_error . "\n";
}
}
}