ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', null); ini_set('error_append_string', null); } include_once dirname(__FILE__) . '/ressources/class.templates.inc'; include_once dirname(__FILE__) . '/ressources/class.ini.inc'; include_once dirname(__FILE__) . '/framework/class.unix.inc'; include_once dirname(__FILE__) . '/framework/frame.class.inc'; include_once dirname(__FILE__) . '/ressources/class.os.system.inc'; include_once dirname(__FILE__) . '/ressources/class.system.network.inc'; include_once dirname(__FILE__) . "/ressources/class.mysql.syslogs.inc"; if ($GLOBALS["VERBOSE"]) { echo "varlog()\n"; } varlog(); function varlog() { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . "()\n"; } $sock = new sockets(); $unix = new unix(); $Pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $PidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = $unix->get_pid_from_file($Pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Aborting Task already running pid {$pid} " . __FUNCTION__ . "()\n"; } return;
function UrgencyChecks() { $unix = new unix(); $sock = new sockets(); $pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidpath); if ($unix->process_exists($pid)) { $pidtime = $unix->PROCCESS_TIME_MIN($pid); $unix->events("UrgencyChecks():: " . __FUNCTION__ . " Already process {$pid} running since {$pidtime} Mn.. Aborting"); return; } @file_put_contents($pidpath, getmypid()); $echo = $unix->find_program("echo"); $LogsRotateDeleteSize = $sock->GET_INFO("LogsRotateDeleteSize"); if (!is_numeric($LogsRotateDeleteSize)) { $LogsRotateDeleteSize = 5000; } Clean_tmp_path(true); $f = $unix->DirFiles("/var/log"); $f[] = "syslog"; $f[] = "messages"; $f[] = "user.log"; varlog(); while (list($num, $filename) = each($f)) { $filepath = "/var/log/{$filename}"; if (!is_file($filepath)) { continue; } $size = $unix->file_size($filepath); $size = $size / 1024; $size = round($size / 1000, 2); $unix->events("UrgencyChecks():: {$filepath} {$size}M"); $ARRAY[$filepath] = $size; } $restart = false; while (list($filepath, $sizeM) = each($ARRAY)) { if ($sizeM > $LogsRotateDeleteSize) { shell_exec("{$echo} \"\" >{$filepath}"); $restart = true; $unix->send_email_events("{$filepath} was cleaned ({$sizeM}M)", "It exceed maximal size {$LogsRotateDeleteSize}M", "system"); $size = $unix->file_size($filepath); $size = $size / 1024; $size = round($size / 1000, 2); $unix->events("UrgencyChecks():: {$filepath} {$sizeM}M > {$LogsRotateDeleteSize}M `{$echo} \"\" >{$filepath}` = {$size}M"); } } if ($restart) { @chmod("/etc/init.d/syslog", 0755); shell_exec("/etc/init.d/syslog restart"); shell_exec("/etc/init.d/artica-syslog restart"); shell_exec("/etc/init.d/auth-tail restart"); shell_exec("/etc/init.d/postfix-logger restart"); } }
function UrgencyChecks() { $unix = new unix(); $sock = new sockets(); $pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidpath); if ($unix->process_exists($pid)) { $pidtime = $unix->PROCCESS_TIME_MIN($pid); $unix->events("UrgencyChecks():: " . __FUNCTION__ . " Already process {$pid} running since {$pidtime} Mn.. Aborting"); return; } @file_put_contents($pidpath, getmypid()); $echo = $unix->find_program("echo"); Clean_tmp_path(true); $f = $unix->DirFiles("/var/log"); $f[] = "syslog"; $f[] = "messages"; $f[] = "user.log"; varlog(); while (list($num, $filename) = each($f)) { if ($filename == "mail.log") { continue; } $filepath = "/var/log/{$filename}"; if (!is_file($filepath)) { continue; } $size = $unix->file_size($filepath); $size = $size / 1024; $size = round($size / 1000, 2); $unix->events("UrgencyChecks():: {$filepath} {$size}M"); $ARRAY[$filepath] = $size; } $restart = false; if ($restart) { @chmod("/etc/init.d/syslog", 0755); shell_exec("/etc/init.d/syslog restart"); shell_exec("/etc/init.d/artica-syslog restart"); shell_exec("/etc/init.d/auth-tail restart"); shell_exec("/etc/init.d/postfix-logger restart"); } }