本文整理汇总了PHP中unix::DIRSIZE_BYTES方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::DIRSIZE_BYTES方法的具体用法?PHP unix::DIRSIZE_BYTES怎么用?PHP unix::DIRSIZE_BYTES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::DIRSIZE_BYTES方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_status_table
function user_status_table()
{
if (isset($GLOBALS["user_status_table_executed"])) {
if ($GLOBALS["VERBOSE"]) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
echo "user_status_table Already executed {$called}\n";
}
}
return;
}
$GLOBALS["user_status_table_executed"] = true;
$unix = new unix();
$sock = new sockets();
$timefile = "/usr/share/artica-postfix/ressources/databases/ZARAFA_DB_STATUS.db";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$mns = $unix->file_time_min($timefile);
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile} = {$mns}Mn\n";
}
if (!$GLOBALS["FORCE"]) {
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overload system, aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
return;
}
if ($mns < 180) {
return;
}
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$timeProcess = $unix->PROCCESS_TIME_MIN($pid);
system_admin_events("{$pid}, task is already executed (since {$timeProcess}Mn}), aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
if ($timeProcess < 15) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
system_admin_events("{$pid}, killed (since {$timeProcess}Mn}), aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
}
}
@file_put_contents($pidfile, getmypid());
@unlink($timefile);
@file_put_contents($timefile, time());
$ZarafaIndexPath = $sock->GET_INFO("ZarafaIndexPath");
$ZarafaStoreOutsidePath = $sock->GET_INFO("ZarafaStoreOutsidePath");
$ZarafaMySQLServiceType = $sock->GET_INFO("ZarafaMySQLServiceType");
if (!is_numeric($ZarafaMySQLServiceType)) {
$ZarafaMySQLServiceType = 1;
}
// $ZarafaMySQLServiceType =1 ou 2 /var/lib/mysql
// $ZarafaMySQLServiceType =3 --> dedicated instance
if ($ZarafaIndexPath == null) {
$ZarafaIndexPath = "/var/lib/zarafa/index";
}
if ($ZarafaStoreOutsidePath == null) {
$ZarafaStoreOutsidePath = "/var/lib/zarafa";
}
$ARRAY["ZARAFA_INDEX"] = $unix->DIRSIZE_BYTES($ZarafaIndexPath);
if ($ZarafaMySQLServiceType == 1 or $ZarafaMySQLServiceType == 2) {
$ARRAY["ZARAFA_DB"] = $unix->DIRSIZE_BYTES("/var/lib/mysql");
}
if ($ZarafaMySQLServiceType == 3) {
$WORKDIR = $sock->GET_INFO("ZarafaDedicateMySQLWorkDir");
if ($WORKDIR == null) {
$WORKDIR = "/home/zarafa-db";
}
$ARRAY["ZARAFA_DB"] = $unix->DIRSIZE_BYTES($WORKDIR);
}
$ARRAY["ATTACHS"] = $unix->DIRSIZE_BYTES($ZarafaStoreOutsidePath);
@file_put_contents($timefile, serialize($ARRAY));
@chmod($timefile, 0750);
unset($ARRAY);
$zarafaadmin = $unix->find_program("zarafa-admin");
$kill = $unix->find_program("kill");
$pids = $unix->PIDOF_PATTERN_ALL("zarafa-admin -l");
if (count($pids) > 0) {
while (list($pid, $line) = each($pids)) {
$time = $unix->PROCESS_TTL($pid);
if ($time > 15) {
$unix->_syslog("killing zarafa-admin -l pid {$pid} ({$time}mn)", basename(__FILE__));
unix_system_kill_force($pid);
}
}
}
$pid = $unix->PIDOF_PATTERN("zarafa-admin -l");
if ($unix->process_exists($pid)) {
$unix->_syslog("zarafa-admin -l pid {$pid} still running", basename(__FILE__));
}
if ($GLOBALS["VERBOSE"]) {
echo "{$zarafaadmin} -l 2>&1\n--------------------------------------------------------------------\n";
}
exec("{$zarafaadmin} -l 2>&1", $results);
while (list($num, $line) = each($results)) {
$line = trim($line);
if ($GLOBALS["VERBOSE"]) {
echo "\"{$line}\"\n";
}
if (preg_match("#User list for\\s+(.+?)\\(#i", $line, $re)) {
$ou = $re[1];
//.........这里部分代码省略.........
示例2: C_ICAP_TABLES
function C_ICAP_TABLES($nopid = false)
{
$unix = new unix();
$size = $unix->DIRSIZE_BYTES("/home/artica/categories_databases");
if ($size > 2000) {
$rm = $unix->find_program("rm");
shell_exec("{$rm} -rf /home/artica/categories_databases/*");
}
return;
}
示例3: get_status
function get_status()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Restarting....: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
if ($GLOBALS["VERBOSE"]) {
echo "TimeFile: {$TimeFile}\n";
}
if (!$GLOBALS["VERBOSE"]) {
$zTime = $unix->file_time_min($TimeFile);
if ($zTime < 10) {
return;
}
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
$sock = new sockets();
$StreamCacheCache = $sock->GET_INFO("StreamCacheCache");
$StreamCacheMainCache = $sock->GET_INFO("StreamCacheMainCache");
if ($StreamCacheCache == null) {
$StreamCacheCache = "/home/squid/videocache";
}
if ($StreamCacheMainCache == null) {
$StreamCacheMainCache = "/home/squid/streamcache";
}
$dir = $StreamCacheCache;
if (is_link($dir)) {
$dir = readlink($dir);
}
$Partition = $unix->DIRPART_INFO($dir);
$SIZE = $unix->DIRSIZE_BYTES($dir);
$array["VIDEOCACHE"]["SIZE"] = $SIZE;
$array["VIDEOCACHE"]["PART"] = $Partition;
$dir = $StreamCacheMainCache;
if (is_link($dir)) {
$dir = readlink($dir);
}
$Partition = $unix->DIRPART_INFO($dir);
$SIZE = $unix->DIRSIZE_BYTES($dir);
$array["SQUID"]["SIZE"] = $SIZE;
$array["SQUID"]["PART"] = $Partition;
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/videocache.dirs.status.db", @serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/videocache.dirs.status.db", 0755);
}
示例4: status_all_mysql_engines
function status_all_mysql_engines()
{
$unix = new unix();
if (systemMaxOverloaded()) {
return;
}
$cachefile = "/usr/share/artica-postfix/ressources/logs/web/MYSQLDB_STATUS";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
if (!$GLOBALS["VERBOSE"]) {
$time = $unix->file_time_min($cachefile);
if ($time < 60) {
return;
}
}
$sock = new sockets();
$datadir = $unix->MYSQL_DATA_DIR();
$ArticaDBPath = $sock->GET_INFO("ArticaDBPath");
if ($ArticaDBPath == null) {
$ArticaDBPath = "/opt/articatech";
}
$SquidStatsDatabasePath = $sock->GET_INFO("SquidStatsDatabasePath");
if ($SquidStatsDatabasePath == null) {
$SquidStatsDatabasePath = "/opt/squidsql";
}
$array["APP_MYSQL_ARTICA"]["size"] = $unix->DIRSIZE_BYTES($datadir);
$array["APP_MYSQL_ARTICA"]["INFO"] = $unix->DIRPART_INFO($datadir);
if (is_dir("{$ArticaDBPath}/mysql")) {
$array["APP_ARTICADB"]["size"] = $unix->DIRSIZE_BYTES("{$ArticaDBPath}");
$array["APP_ARTICADB"]["INFO"] = $unix->DIRPART_INFO("{$ArticaDBPath}");
}
if (is_dir("{$SquidStatsDatabasePath}/data")) {
$array["APP_SQUID_DB"]["size"] = $unix->DIRSIZE_BYTES("{$SquidStatsDatabasePath}");
$array["APP_SQUID_DB"]["INFO"] = $unix->DIRPART_INFO("{$SquidStatsDatabasePath}");
}
$MySQLSyslogWorkDir = $sock->GET_INFO("MySQLSyslogWorkDir");
if ($MySQLSyslogWorkDir == null) {
$MySQLSyslogWorkDir = "/home/syslogsdb";
}
if (is_dir($MySQLSyslogWorkDir)) {
$array["MYSQL_SYSLOG"]["size"] = $unix->DIRSIZE_BYTES($MySQLSyslogWorkDir);
$array["MYSQL_SYSLOG"]["INFO"] = $unix->DIRPART_INFO($MySQLSyslogWorkDir);
}
if ($GLOBALS["VERBOSE"]) {
print_r($array);
}
@unlink($cachefile);
@file_put_contents($cachefile, base64_encode(serialize($array)));
@chmod($cachefile, 0777);
}
示例5: databasesize
function databasesize($force = false)
{
$sock = new sockets();
$unix = new unix();
$arrayfile = $GLOBALS["DBCACHE_PATH"];
if (!$force) {
$pidfile = $GLOBALS["DATABASE_STATS_PID"];
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
return;
}
@file_put_contents($pidfile, getmypid());
$time = $unix->file_time_min($arrayfile);
if ($time < 20) {
return;
}
}
$WORKDIR = $sock->GET_INFO($GLOBALS["WORK_DIR_TOKEN"]);
if ($WORKDIR == null) {
$WORKDIR = $GLOBALS["WORK_DIR_DEFAULT"];
}
$dir = $WORKDIR;
if (is_link($dir)) {
$dir = readlink($dir);
}
$unix = new unix();
$sizbytes = $unix->DIRSIZE_BYTES($dir);
$dir = $unix->shellEscapeChars($dir);
$df = $unix->find_program("df");
$array["DBSIZE"] = $sizbytes / 1024;
exec("{$df} -B K {$dir} 2>&1", $results);
while (list($num, $ligne) = each($results)) {
if (preg_match("#^.*?\\s+([0-9A-Z\\.]+)K\\s+([0-9A-Z\\.]+)K\\s+([0-9A-Z\\.]+)K\\s+([0-9\\.]+)%\\s+(.+)#", $ligne, $re)) {
$array["SIZE"] = $re[1];
$array["USED"] = $re[2];
$array["AIVA"] = $re[3];
$array["POURC"] = $re[4];
$array["MOUNTED"] = $re[5];
break;
}
}
$results = array();
exec("{$df} -i {$dir} 2>&1", $results);
while (list($num, $ligne) = each($results)) {
if (preg_match("#^.*?\\s+([0-9A-Z\\.]+)\\s+([0-9A-Z\\.]+)\\s+([0-9A-Z\\.]+)\\s+([0-9\\.]+)%\\s+(.+)#", $ligne, $re)) {
$array["ISIZE"] = $re[1];
$array["IUSED"] = $re[2];
$array["IAIVA"] = $re[3];
$array["IPOURC"] = $re[4];
break;
}
}
if ($GLOBALS["VERBOSE"]) {
print_r($array);
}
@unlink($arrayfile);
@file_put_contents($arrayfile, serialize($array));
if ($GLOBALS["VERBOSE"]) {
echo "Saving {$arrayfile}...\n";
}
@chmod($arrayfile, 0755);
}
示例6: squidlogs_status
function squidlogs_status($nopid = false)
{
$sock = new sockets();
$unix = new unix();
$cachefile = "/usr/share/artica-postfix/ressources/logs/web/squidlogs.stats";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$q = new mysql_squid_builder();
if (!$nopid) {
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid)) {
echo "Starting......: " . date("H:i:s") . " cache manager, " . __FUNCTION__ . "() already running PID:{$pid}\n";
return;
}
@file_put_contents($pidfile, getmypid());
}
if ($GLOBALS["FORCE"]) {
@unlink($cachefile);
}
if (is_file($cachefile)) {
$time = $unix->file_time_min($cachefile);
if ($time < 20) {
if ($GLOBALS["VERBOSE"]) {
echo "{$time}mn require 20mn\n";
}
return;
}
}
$df = $unix->find_program("df");
$sock = new sockets();
$MYSQL_DATA_DIR = $q->MYSQL_DATA_DIR;
if (is_dir("/opt/squidsql")) {
$MYSQL_DATA_DIR = "/opt/squidsql";
}
if ($GLOBALS["VERBOSE"]) {
echo "MYSQL_DATA_DIR = {$MYSQL_DATA_DIR}\n";
}
if (!is_link("{$MYSQL_DATA_DIR}/{$q->database}")) {
$realFolder = "{$MYSQL_DATA_DIR}";
} else {
$realFolder = readlink("{$MYSQL_DATA_DIR}");
}
$EXEC_NICE = $unix->EXEC_NICE();
$cmdline = "{$EXEC_NICE}{$df} -h {$realFolder} 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo __LINE__ . " {$cmdline}\n";
}
exec("{$df} -h {$realFolder} 2>&1", $results);
$foldersize = $unix->DIRSIZE_BYTES($realFolder);
while (list($num, $line) = each($results)) {
if (!preg_match("#(.+?)\\s+([0-9A-Z\\.]+)\\s+([0-9A-Z\\.]+)\\s+([0-9A-Z\\.]+)\\s+([0-9\\.]+)%#", $line, $re)) {
if ($GLOBALS["VERBOSE"]) {
echo "{$line}, no match\n";
}
continue;
}
$array["squidlogs"]["DEV"] = $re[1];
$array["squidlogs"]["SIZE"] = $re[2];
$array["squidlogs"]["OC"] = $re[3];
$array["squidlogs"]["DISP"] = $re[4];
$array["squidlogs"]["POURC"] = $re[5];
$array["squidlogs"]["REALPATH"] = $realFolder;
$array["squidlogs"]["PATHSIZE"] = $foldersize;
$array["squidlogs"]["TIME"] = time();
}
$TuningParameters = unserialize(base64_decode($sock->GET_INFO("MySQLSyslogParams")));
$MySQLSyslogWorkDir = $sock->GET_INFO("MySQLSyslogWorkDir");
if ($MySQLSyslogWorkDir == null) {
$MySQLSyslogWorkDir = "/home/syslogsdb";
}
$q = new mysql_storelogs();
$MYSQL_DATA_DIR = $MySQLSyslogWorkDir;
if (!is_link("{$MYSQL_DATA_DIR}")) {
$realFolder = "{$MYSQL_DATA_DIR}";
} else {
$realFolder = readlink("{$MYSQL_DATA_DIR}");
}
exec("{$df} -h {$realFolder} 2>&1", $results);
if ($GLOBALS["VERBOSE"]) {
echo __LINE__ . " {$cmdline}\n";
}
$foldersize = $unix->DIRSIZE_BYTES($realFolder);
while (list($num, $line) = each($results)) {
if (!preg_match("#(.+?)\\s+([0-9A-Z\\.]+)\\s+([0-9A-Z\\.]+)\\s+([0-9A-Z\\.]+)\\s+([0-9\\.]+)%#", $line, $re)) {
continue;
}
$array["syslogstore"]["DEV"] = $re[1];
$array["syslogstore"]["SIZE"] = $re[2];
$array["syslogstore"]["OC"] = $re[3];
$array["syslogstore"]["DISP"] = $re[4];
$array["syslogstore"]["POURC"] = $re[5];
$array["syslogstore"]["REALPATH"] = $realFolder;
$array["syslogstore"]["PATHSIZE"] = $foldersize;
$array["syslogstore"]["TIME"] = time();
}
print_r($array);
@unlink($cachefile);
@file_put_contents($cachefile, serialize($array));
$unix->chmod_func(0777, $cachefile);
if ($GLOBALS["VERBOSE"]) {
echo __LINE__ . " " . __FUNCTION__ . " finish OK\n";
//.........这里部分代码省略.........
示例7: cache_center_status
function cache_center_status($aspid = false)
{
$unix = new unix();
if ($GLOBALS["VERBOSE"]) {
echo "Running cache_center_status()\n";
$aspid = true;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . "Already `task` running PID {$pid} since {$time}mn\n";
}
system_admin_events("stop_squid::Already task running PID {$pid} since {$time}mn", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
@file_put_contents($pidfile, getmypid());
}
$TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($GLOBALS["VERBOSE"]) {
echo "TimeFile={$TimeFile}\n";
}
$Time = $unix->file_time_min($TimeFile);
if (!$GLOBALS["VERBOSE"]) {
if ($Time < 5) {
return;
}
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
$ARRAY = unserialize(base64_decode(squid_get_storage_info()));
$q = new mysql();
while (list($directory, $arrayStore) = each($ARRAY)) {
$arrayStore["USED"] = intval($arrayStore["USED"]);
$arrayStore["PERC"] = intval($arrayStore["PERC"]);
if ($arrayStore["USED"] == 0 && $arrayStore["PERC"] > 0) {
$arrayStore["USED"] = $unix->DIRSIZE_BYTES($directory);
}
if ($GLOBALS["VERBOSE"]) {
echo "{$directory} USED {$arrayStore["USED"]} PERC:{$arrayStore["PERC"]}\n";
}
if ($directory == "MEM") {
continue;
}
if ($arrayStore["USED"] == 0) {
continue;
}
$PERC = $arrayStore["PERC"];
$USED = $arrayStore["USED"];
if (preg_match("#\\/home\\/squid\\/cache\\/MemBooster([0-9]+)#", $directory, $re)) {
$q->QUERY_SQL("UPDATE squid_caches_center SET percentcache='{$PERC}',percenttext='{$PERC}', \n\t\t\t\t\t`usedcache`='{$USED}' WHERE ID={$re[1]}", "artica_backup");
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "{$directory} -> {$USED} / {$PERC}%\n";
}
$q->QUERY_SQL("UPDATE squid_caches_center SET \n\t\t\t\tpercentcache='{$PERC}',percenttext='{$PERC}', `usedcache`='{$USED}' WHERE \n\t\t\t\t`cache_dir`='{$directory}'", "artica_backup");
}
}
示例8: rebuildcaches
function rebuildcaches()
{
$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);
ouputz("Please wait, rebuild caches....", __LINE__);
$t = time();
ouputz("Listing caches....", __LINE__);
$array = ListCaches();
$mv = $unix->find_program("mv");
$rm = $unix->find_program("rm");
$php5 = $unix->LOCATE_PHP5_BIN();
build_progress(count($array) . " Caches to delete...", 15);
ouputz(count($array) . " caches to delete...", __LINE__);
if (count($array) == 0) {
build_progress("Fatal, unable to list available caches.", 110);
ouputz("Fatal, unable to list available caches...", __LINE__);
squid_admin_mysql(0, "Fatal, unable to list available caches", null, __FILE__, __LINE__);
@unlink("/etc/artica-postfix/squid.lock");
die;
}
$t = time();
@unlink("/etc/artica-postfix/squid.lock");
@file_put_contents("/etc/artica-postfix/squid.lock", time());
$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);
//.........这里部分代码省略.........
示例9: BackupLogsMaxStoragePercent_info
function BackupLogsMaxStoragePercent_info()
{
$BackupMaxDaysDir = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/BackupMaxDaysDir"));
if ($BackupMaxDaysDir == null) {
$BackupMaxDaysDir = "/home/logrotate_backup";
}
if (!is_dir("{$BackupMaxDaysDir}")) {
@mkdir("{$BackupMaxDaysDir}", true);
}
$unix = new unix();
$DIRPART_INFO = $unix->DIRPART_INFO($BackupMaxDaysDir);
$DIRSIZE = $unix->DIRSIZE_BYTES($BackupMaxDaysDir);
$DIRPART_INFO["CURSIZE"] = $DIRSIZE;
echo "<articadatascgi>" . base64_encode(serialize($DIRPART_INFO)) . "</articadatascgi>";
}
示例10: CACHES_AVG
function CACHES_AVG()
{
$unix = new unix();
$cache_manager = new cache_manager();
$data = $cache_manager->makeQuery("storedir", true);
$StoreDir = null;
foreach ($data as $ligne) {
if (preg_match("#Current Capacity.*?:\\s+(.+?)% used#", $ligne, $re)) {
@file_put_contents("{$GLOBALS["BASEDIR"]}/CACHES_AVG", $re[1]);
@chmod("{$GLOBALS["BASEDIR"]}/CACHES_AVG", 0777);
}
if (preg_match("#Store Directory.*?:(.+)#", $ligne, $re)) {
$StoreDir = trim($re[1]);
continue;
}
if (preg_match("#Percent Used:\\s+([0-9\\.]+)%#", $ligne, $re)) {
if ($StoreDir == null) {
continue;
}
$dats[$StoreDir]["PERC"] = $re[1];
continue;
}
if (preg_match("#Maximum Size:\\s+([0-9\\.]+)#", $ligne, $re)) {
if ($StoreDir == null) {
continue;
}
$dats[$StoreDir]["SIZE"] = $re[1];
continue;
}
if (preg_match("#Current Size:\\s+([0-9\\.]+)#", $ligne, $re)) {
if (isset($dats[$StoreDir]["USED"])) {
continue;
}
if ($GLOBALS["OUTPUT"]) {
echo "* * * * * * * * *\nDISK \"{$ligne}\"\nDISK {$StoreDir} Current Size: {$re[1]}\n* * * * * * * * *\n";
}
$dats[$StoreDir]["USED"] = $re[1];
continue;
}
if (preg_match("#Current entries:\\s+([0-9\\.]+)\\s+([0-9\\.]+)%#", $ligne, $re)) {
if ($GLOBALS["OUTPUT"]) {
echo "* * * * * * * * *\nDISK \"{$ligne}\"\nDISK {$StoreDir} Current entries:{$re[1]} {$re[2]}%\n* * * * * * * * *\n";
}
if ($StoreDir == null) {
continue;
}
$dats[$StoreDir]["ENTRIES"] = $re[1];
$dats[$StoreDir]["PERC"] = $re[2];
continue;
}
if (preg_match("#Filesystem Space in use:\\s+([0-9]+)\\/#", $ligne, $re)) {
if ($StoreDir == null) {
continue;
}
if (isset($dats[$StoreDir]["USED"])) {
continue;
}
if ($GLOBALS["OUTPUT"]) {
echo "* * * * * * * * *\nDISK \"{$ligne}\"\nDISK (2) {$StoreDir} Current Size: {$re[1]}\n* * * * * * * * *\n";
}
$dats[$StoreDir]["USED"] = $re[1];
}
}
$q = new mysql();
while (list($directory, $arrayStore) = each($dats)) {
$arrayStore["USED"] = intval($arrayStore["USED"]);
$arrayStore["PERC"] = intval($arrayStore["PERC"]);
if ($arrayStore["USED"] == 0 && $arrayStore["PERC"] > 0) {
$arrayStore["USED"] = $unix->DIRSIZE_BYTES($directory);
}
if ($directory == "MEM") {
continue;
}
if ($arrayStore["USED"] == 0) {
continue;
}
$PERC = $arrayStore["PERC"];
$USED = $arrayStore["USED"];
if (preg_match("#\\/home\\/squid\\/cache\\/MemBooster([0-9]+)#", $directory, $re)) {
$sql = "UPDATE squid_caches_center SET percentcache='{$PERC}',percenttext='{$PERC}', `usedcache`='{$USED}' WHERE ID={$re[1]}";
echo $sql . "\n";
$q->QUERY_SQL($sql, "artica_backup");
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "{$directory} -> {$USED} / {$PERC}%\n";
}
$sql = "UPDATE squid_caches_center SET percentcache='{$PERC}',percenttext='{$PERC}', `usedcache`='{$USED}' WHERE `cache_dir`='{$directory}'";
echo $sql . "\n";
$q->QUERY_SQL($sql, "artica_backup");
}
}
示例11: CleanPercent
function CleanPercent($BackupMaxDaysDir, $TOTAL_AVAILABLE)
{
$unix = new unix();
$q = new mysql_storelogs();
$ARRAY = array();
$DIRSIZE = $unix->DIRSIZE_BYTES($BackupMaxDaysDir);
$q->events("Remove files in {$BackupMaxDaysDir} " . FormatBytes($DIRSIZE / 1024) . "/" . FormatBytes($TOTAL_AVAILABLE / 1024), __FUNCTION__, __LINE__);
$q2 = new mysql();
$results = $q2->QUERY_SQL("SELECT * FROM backuped_logs ORDER BY zDate LIMIT 0,50", "artica_backup");
if (!$q2->ok) {
squid_admin_mysql(0, "MySQL error", $q2->mysql_error, __FILE__, __LINE__);
return;
}
while ($ligne = mysql_fetch_assoc($results)) {
if (preg_match("#^\\/mnt\\/", $ligne["path"])) {
continue;
}
$filepath = $ligne["path"];
if (!is_file($filepath)) {
continue;
}
$sizeBytes = @filesize($filepath);
@unlink($filepath);
$DIRSIZE = $DIRSIZE - $sizeBytes;
$q->events("Remove {$filepath} (" . FormatBytes($sizeBytes / 1024) . ") New DIR SIZE=" . FormatBytes($DIRSIZE / 1024) . "/" . FormatBytes($TOTAL_AVAILABLE / 1024), __FUNCTION__, __LINE__);
if ($DIRSIZE < $TOTAL_AVAILABLE) {
break;
}
}
}
示例12: ScanSize
function ScanSize()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/tests." . __FUNCTION__ . ".time";
$pid = @file_get_contents("{$pidfile}");
if ($unix->process_exists($pid, basename(__FILE__))) {
system_admin_events("Already executed PID {$pid}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
die;
}
@file_put_contents($pidfile, getmypid());
$time = $unix->file_time_min($timefile);
if ($time < 15) {
system_admin_events("No less than 15mn or delete {$timefile} file", __FUNCTION__, __FILE__, __LINE__, "freewebs");
die;
}
@unlink($timefile);
@file_put_contents($timefile, time());
$t = time();
$q = new mysql();
$sql = "SELECT servername FROM freeweb";
$results = $q->QUERY_SQL($sql, 'artica_backup');
$GLobalSize = 0;
if (mysql_num_rows($results) == 0) {
return;
}
$sitesNumber = mysql_num_rows($results);
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$free = new freeweb($ligne["servername"]);
if ($free->IsGroupWareFromArtica()) {
$q->QUERY_SQL("UPDATE freeweb SET DirectorySize=0 WHERE servername='{$ligne["servername"]}'", "artica_backup");
continue;
}
$free->CheckWorkingDirectory();
if (is_link($free->WORKING_DIRECTORY)) {
$free->WORKING_DIRECTORY = @readlink($free->WORKING_DIRECTORY);
}
if (!is_dir($free->WORKING_DIRECTORY)) {
$q->QUERY_SQL("UPDATE freeweb SET DirectorySize=0 WHERE servername='{$ligne["servername"]}'", "artica_backup");
if (!$q->ok) {
system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
}
continue;
}
$size = $unix->DIRSIZE_BYTES($free->WORKING_DIRECTORY);
$GLobalSize = $GLobalSize + $size;
if ($GLOBALS["VERBOSE"]) {
echo "{$ligne["servername"]} {$size} Bytes\n";
}
$q->QUERY_SQL("UPDATE freeweb SET DirectorySize={$size} WHERE servername='{$ligne["servername"]}'", "artica_backup");
if (!$q->ok) {
system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
}
}
if ($GLobalSize > 0) {
$took = $unix->distanceOfTimeInWords($t, time(), true);
$GLobalSize = round($GLobalSize / 1024, 2);
$GLobalSize = $GLobalSize / 1000;
system_admin_events("{$sitesNumber} web site(s) scanned {$GLobalSize}M took:{$took}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
}
}
示例13: execute_mysql
//.........这里部分代码省略.........
$php = $unix->LOCATE_PHP5_BIN();
$APACHE_USERNAME = $unix->APACHE_SRC_ACCOUNT();
$APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
$q = new mysql();
$nice = EXEC_NICE();
$sql = "SELECT * FROM httrack_sites WHERE enabled=1";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
apache_admin_mysql(0, "Fatal: {$q->mysql_error}", null, __FILE__, __LINE__, "webcopy");
return;
}
$t1 = time();
$count = 0;
if ($OnlyID > 0) {
$ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT sitename FROM httrack_sites WHERE ID={$OnlyID}", "artica_backup"));
$log_exp = " only for [{$ligne2["sitename"]}] ";
}
apache_admin_mysql(2, "Starting executing WebCopy task {$log_exp} pid:{$getmypid}", null, __FILE__, __LINE__, "webcopy");
$dirsizeG = 0;
while ($ligne = mysql_fetch_assoc($results)) {
if ($OnlyID > 0) {
if ($ligne["ID"] != $OnlyID) {
continue;
}
}
$t = time();
$count++;
$workingdir = $ligne["workingdir"];
$sitename = $ligne["sitename"];
$minrate = $ligne["minrate"];
$maxfilesize = $ligne["maxfilesize"];
$maxsitesize = $ligne["maxsitesize"];
$size = $ligne["size"];
$sizeKB = $size / 1024;
$sizeMB = round($sizeKB / 1024, 2);
$maxworkingdir = intval($ligne["maxworkingdir"]);
if ($maxworkingdir == 0) {
$maxworkingdir = 20;
}
$maxsitesizeMB = $maxsitesize / 1000;
if ($maxsitesizeMB > $maxworkingdir) {
$maxsitesize = $maxworkingdir * 1000;
}
if ($sizeMB > $maxworkingdir) {
apache_admin_mysql(1, "Skip downloading content of {$sitename} Directory: {$sizeMB}MB reach limit of {$maxworkingdir}MB", null, __FILE__, __LINE__, "webcopy");
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "Dir: Current size:{$sizeMB}\n";
echo "Dir: Max size:{$maxworkingdir}\n";
}
$ResteMB = $maxworkingdir - $sizeMB;
$ResteKB = $ResteMB * 1000;
if ($maxsitesize > $ResteKB) {
$maxsitesize = $ResteKB;
}
echo "Dir: Max Downloads:{$maxsitesize} KB\n";
$maxfilesize = $maxfilesize * 1000;
$maxsitesize = $maxsitesize * 1000;
$minrate = $minrate * 1000;
$update = null;
$resultsCMD = array();
echo "Dir: Max Downloads:{$maxsitesize} Bytes\n";
if (!is_dir($workingdir)) {
@mkdir($workingdir, 0755, true);
}
if (is_file("{$workingdir}/hts-cache")) {
$update = " --update";
}
apache_admin_mysql(2, "Starting downloading content of {$sitename}/{$minrate}/" . FormatBytes($maxsitesize / 1000), null, __FILE__, __LINE__, "webcopy");
$cmdline = "{$httrack} \"{$sitename}\" --quiet{$update}{$PPRoxy} --max-files={$maxfilesize} --max-size={$maxsitesize} --max-rate={$minrate} -O \"{$workingdir}\" 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmdline}\n";
}
exec($cmdline, $resultsCMD);
if ($GLOBALS["VERBOSE"]) {
echo @implode("\n", $resultsCMD);
}
$dirsize = $unix->DIRSIZE_BYTES($workingdir);
$dirsizeG = $dirsizeG + $dirsize;
$took = $unix->distanceOfTimeInWords($t, time(), true);
$dirsizeText = round($dirsize / 1024 / 1000, 2);
if ($GLOBALS["VERBOSE"]) {
echo "Dir: Current size:{$sizeMB}\n";
echo "Dir: New size....:{$dirsizeText}MB\n";
}
apache_admin_mysql(2, "{$sitename} scrapped took {$took} size={$dirsizeText} MB", @implode("\n", $resultsCMD), __FILE__, __LINE__, "webcopy");
$q->QUERY_SQL("UPDATE httrack_sites SET size='{$dirsize}' WHERE ID={$ligne["ID"]}", "artica_backup");
}
$took = $unix->distanceOfTimeInWords($t1, time(), true);
@chmod($workingdir, 0755);
@chmod(dirname($workingdir), 0755);
$chown = $unix->find_program("chown");
shell_exec("{$chown} -R {$APACHE_USERNAME}:{$APACHE_SRC_GROUP} {$workingdir}");
@file_put_contents("/etc/artica-postfix/settings/Daemons/HTTRackSize", $dirsizeG);
if ($count > 0) {
apache_admin_mysql(2, "{$count} web sites scrapped took {$took}", null, __FILE__, __LINE__, "webcopy");
}
system("{$php} /usr/share/artica-postfix/exec.syslog-engine.php --apache");
}
示例14: InsertToMysql
function InsertToMysql()
{
$unix = new unix();
$date_start = $GLOBALS["DATE_START"];
$size = $unix->DIRSIZE_BYTES("{$GLOBALS["MOUNTED_PATH_FINAL"]}");
$date_end = time();
$calculate = $unix->distanceOfTimeInWords($date_start, time());
$zDate = date("Y-m-d H:i:s");
$hostname = $unix->hostname_g();
$sql = "CREATE TABLE IF NOT EXISTS `artica_events`.`cyrus_backup` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t`zDate` DATETIME NOT NULL ,\n\t\t\t\t`hostname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t\t`duration` VARCHAR( 256 ) NOT NULL ,\n\t\t\t\t`directory` BIGINT UNSIGNED,\n\t\t\t\t`size` BIGINT UNSIGNED ,\n\t\t\t\tINDEX ( `zDate` , `directory` , `size` ,`hostname`)\n\t\t\t\t);";
$q->QUERY_SQL($sql, 'artica_events');
$q->QUERY_SQL("INSERT IGNORE INTO `cyrus_backup` (`zDate`,`hostname`,`duration`,`directory`,`size`) VALUES('{$zDate}','{$hostname}','{$calculate}','{$GLOBALS["DIRBYTES"]}','{$size}')", "artica_events");
if (!$q->ok) {
cyrus_admin_mysql(0, "{$q->mysql_error}", __FILE__, __LINE__);
}
$size = $size / 1024;
$size = $size / 1024;
cyrus_admin_mysql(2, "Cyrus backup: Success {$calculate} in {$GLOBALS["MOUNTED_PATH_FINAL"]}", null, __FILE__, __LINE__);
}
示例15: GetTotalSize
function GetTotalSize($aspid = false)
{
$filecache = "/etc/artica-postfix/settings/Daemons/SystemTotalSize";
$unix = new unix();
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
}
$time = $unix->file_time_min($filecache);
if (!$GLOBALS["FORCE"]) {
if ($time < 1440) {
return;
}
}
$sync = $unix->find_program("sync");
shell_exec($sync);
$fullsize = 0;
reset($GLOBALS["SYSDIRS"]);
$GLOBALS["SYSDIRS"]["/opt/articatech"] = true;
$GLOBALS["SYSDIRS"]["/opt/squidsql/data"] = true;
while (list($directory, $val) = each($GLOBALS["SYSDIRS"])) {
if (is_link($directory)) {
$directory = readlink($directory);
}
if (!is_dir($directory)) {
continue;
}
$size = $unix->DIRSIZE_BYTES($directory);
$fullsize = $fullsize + $size;
}
@unlink($filecache);
@file_put_contents($filecache, $fullsize);
}