本文整理汇总了PHP中system_is_overloaded函数的典型用法代码示例。如果您正苦于以下问题:PHP system_is_overloaded函数的具体用法?PHP system_is_overloaded怎么用?PHP system_is_overloaded使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了system_is_overloaded函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckCMDLine
function CheckCMDLine()
{
$unix = new unix();
$PID_FILE = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = $unix->get_pid_from_file($PID_FILE);
if ($unix->process_exists($pid)) {
return;
}
@file_put_contents($PID_FILE, getmypid());
if (system_is_overloaded()) {
die;
}
$sock = new sockets();
$ips = unserialize(base64_decode($sock->GET_INFO("RBLCheckIPList")));
if (count($ips) > 0) {
if ($GLOBALS["VERBOSE"]) {
echo count($ips) . " elements to check\n";
}
if (is_array($ips)) {
while (list($num, $ip) = each($ips)) {
if ($GLOBALS["VERBOSE"]) {
echo "{$ip} element...\n";
}
ChecksDNSBL($ip, false, true);
}
ChecksDNSBL();
return;
}
}
ChecksDNSBL();
}
示例2: check
function check()
{
$EnablePhileSight = GET_INFO_DAEMON("EnablePhileSight");
if ($EnablePhileSight == null) {
$EnablePhileSight = 0;
}
if ($EnablePhileSight == 0) {
writelogs("feature disabled, aborting...", __FUNCTION__, __FILE__, __LINE__);
die;
}
if (system_is_overloaded()) {
writelogs("System overloaded, aborting this feature for the moment", __FUNCTION__, __FILE__, __LINE__);
die;
}
@mkdir("/opt/artica/philesight");
$unix = new unix();
$min = $unix->file_time_min("/opt/artica/philesight/database.db");
$sock = new sockets();
$rr = $sock->GET_INFO("PhileSizeRefreshEach");
if ($rr == null) {
$rr = 120;
}
if ($rr == "disable") {
die;
}
writelogs("/opt/artica/philesight/database.db = {$min} minutes, {$rr} minutes to run", __FUNCTION__, __FILE__, __LINE__);
if ($min >= $rr) {
run();
}
}
示例3: purge
function purge()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidtime = "/etc/artica-postfix/pids/exec.suricata.hourly.purge.time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
return;
}
@file_put_contents($pidfile, getmypid());
if (system_is_overloaded()) {
return;
}
$timeExec = $unix->file_time_min($pidtime);
if ($timeExec < 1440) {
return;
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
$q = new postgres_sql();
$sock = new sockets();
$SuricataPurge = intval($sock->GET_INFO("SuricataPurge"));
if ($SuricataPurge == 0) {
$SuricataPurge = 15;
}
$q->QUERY_SQL("DELETE FROM suricata_events WHERE zdate < NOW() - INTERVAL '{$SuricataPurge} days'");
}
示例4: detect_kernels
function detect_kernels()
{
$unix = new unix();
if (!$GLOBALS["VERBOSE"]) {
if (is_file("/usr/share/artica-postfix/ressources/logs/kernel.lst")) {
if ($unix->file_time_min("/usr/share/artica-postfix/ressources/logs/kernel.lst") < 360) {
die;
}
}
}
$users = new usersMenus();
if ($users->LinuxDistriCode != "DEBIAN" && $users->LinuxDistriCode != "UBUNTU") {
die;
}
$unix = new unix();
$apt_cache = $unix->find_program("apt-cache");
if ($apt_cache == null) {
echo "Could not find apt-cache\n";
die;
}
if (system_is_overloaded(basename(__FILE__))) {
$unix->send_email_events("apt-cache aborted, system is overloaded..", "will restart analyzis in next cycle", "system");
die;
}
echo "{$apt_cache} search linux-image\n";
exec("{$apt_cache} search linux-image", $results);
while (list($num, $val) = each($results)) {
if (preg_match("#linux-image-([0-9\\.]+)-([0-9]+)-(.+?)\\s+-\\s+(.+?)\$#", $val, $re)) {
$array["DPKG"][] = array("VERSION" => $re[1], "BUILD" => $re[2], "ARCH" => $re[3], "INFOS" => $re[4], "PACKAGE" => "linux-image-{$re[1]}-{$re[2]}-{$re[3]}", "FULL_VERSION" => "{$re[1]}-{$re[2]}-{$re[3]}");
}
}
$array["INFOS"] = CpuFamilyInfos();
@file_put_contents("/usr/share/artica-postfix/ressources/logs/kernel.lst", base64_encode(serialize($array)));
}
示例5: importActivedirectoryusers
function importActivedirectoryusers()
{
$sock = new sockets();
$EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
if (!is_numeric($EnableKerbAuth)) {
$EnableKerbAuth = 0;
}
if ($EnableKerbAuth == 0) {
return;
}
$unix = new unix();
$user = new settings_inc();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
WriteMyLogs("Process {$pid} already exists", __FUNCTION__, __FILE__, __LINE__);
return;
}
if (system_is_overloaded(basename(__FILE__))) {
WriteMyLogs("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
@file_put_contents($pidfile, getmypid());
$TImeStamp = $unix->file_time_min($pidTime);
if (!$GLOBALS["FORCE"]) {
if ($TImeStamp < 20) {
WriteMyLogs("Need 20mn, current={$TImeStamp}Mn executed by:{$GLOBALS["EXECUTOR"]} Params:{$GLOBALS["PARAMS"]}", __FUNCTION__, __FILE__, __LINE__);
return;
}
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$netbin = $unix->LOCATE_NET_BIN_PATH();
$usermod = $unix->find_program("usermod");
$chmod = $unix->find_program("chmod");
if (!is_file($netbin)) {
WriteMyLogs("net no such binary, aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
if (is_dir("/var/run/samba/winbindd_privileged")) {
shell_exec("{$usermod} -G winbindd_priv squid >/dev/null 2>&1");
shell_exec("{$chmod} 0750 /var/run/samba/winbindd_privileged/ >/dev/null 2>&1");
}
$array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
$domainUp = strtoupper($array["WINDOWS_DNS_SUFFIX"]);
$domain_lower = strtolower($array["WINDOWS_DNS_SUFFIX"]);
$adminpassword = $array["WINDOWS_SERVER_PASS"];
$adminpassword = $unix->shellEscapeChars($adminpassword);
$adminname = $array["WINDOWS_SERVER_ADMIN"];
$ad_server = $array["WINDOWS_SERVER_NETBIOSNAME"];
$GLOBALS["AUTHCMD"] = " -U {$adminname}%{$adminpassword}";
getNetInfos();
if (!isset($GLOBALS["LDAP_HOST"])) {
WriteMyLogs("Unable to get ldap infos, aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
GetUsersArray();
}
示例6: start_hour
function start_hour()
{
$TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$unix = new unix();
$sock = new sockets();
if (system_is_overloaded(basename(__FILE__))) {
return;
}
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "{$pid} already executed since {$timepid}Mn\n";
}
if (!$GLOBALS["FORCE"]) {
if ($timepid < 14) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
}
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
$hostname = $unix->hostname_g();
$today = date("Y-m-d") . " 00:00:00";
$postgres = new postgres_sql();
$results = $postgres->QUERY_SQL("select date_trunc('H',zdate) + (round(extract('minute' from zdate)/15)*15) * '1 minute'::interval as time, sum(rx) as rx, sum(tx) as tx,eth from access_log WHERE proxyname='{$hostname}' AND zdate >'{$today}' group by time,eth");
$c = 0;
$f = array();
while ($ligne = @pg_fetch_assoc($results)) {
$time = $ligne["time"];
$ETH = $ligne["eth"];
if ($ETH == "lo") {
continue;
}
$RX = $ligne["rx"];
$TX = $ligne["tx"];
$f[] = "('{$time}','{$ETH}','{$RX}','{$TX}')";
}
if (count($f) == 0) {
return;
}
$q = new mysql();
if ($q->TABLE_EXISTS("RXTX_HOUR", "artica_events")) {
$q->QUERY_SQL("TRUNCATE TABLE `RXTX_HOUR`", "artica_events");
}
$sql = "CREATE TABLE IF NOT EXISTS `RXTX_HOUR`\n\t(`ZDATE` DATETIME,\n\t`RX` INT UNSIGNED NOT NULL DEFAULT 1,\n\t`TX` INT UNSIGNED NOT NULL DEFAULT 1,\n\t`ETH` VARCHAR(60),\n\tKEY `ZDATE`(`ZDATE`),\n\tKEY `RX`(`RX`),\n\tKEY `TX`(`TX`),\n\tKEY `ETH`(`ETH`) ) ENGINE = MYISAM;";
$q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
return;
}
$q->QUERY_SQL("INSERT IGNORE INTO RXTX_HOUR (ZDATE,ETH,RX,TX) VALUES " . @implode(",", $f), "artica_events");
start_week();
}
示例7: parse_logs
function parse_logs()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if (!$GLOBALS["VERBOSE"]) {
if ($unix->file_time_min($pidTime) < 45) {
return;
}
}
$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());
@unlink($pidTime);
@file_put_contents($pidTime, time());
$sock = new sockets();
$EnableNginxStats = $sock->GET_INFO("EnableNginxStats");
if (!is_numeric($EnableNginxStats)) {
$EnableNginxStats = 0;
}
if ($EnableNginxStats == 0) {
return;
}
if (system_is_overloaded(basename(__FILE__))) {
events("Overloaded system: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} aborting", __FUNCTION__, __LINE__);
return;
}
$nice = EXEC_NICE();
$sock = new sockets();
$kill = $unix->find_program("kill");
$NginxWorkLogsDir = $sock->GET_INFO("NginxWorkLogsDir");
if ($NginxWorkLogsDir == null) {
$NginxWorkLogsDir = "/home/nginx/logsWork";
}
$sys = new mysql_storelogs();
$files = $unix->DirFiles($NginxWorkLogsDir, "-([0-9\\-]+)\\.log");
while (list($filename, $line) = each($files)) {
if (!preg_match("#^(.+?)-[0-9]+-[0-9]+-[0-9]+-[0-9]+\\.log\$#", $filename, $re)) {
if ($GLOBALS["VERBOSE"]) {
echo "{$filename}, skip\n";
}
continue;
}
$servername = $re[1];
$fullpath = "{$NginxWorkLogsDir}/{$filename}";
ParseFile($servername, $fullpath);
}
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
shell_exec("{$nohup} {$php} " . __FILE__ . " --hosts >/dev/null 2>&1 &");
shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.nginx-stats-day.php >/dev/null 2>&1 &");
}
示例8: ScanFoldders
function ScanFoldders()
{
$sock = new sockets();
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = file_get_contents("{$pidfile}");
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile}\n";
}
if (system_is_overloaded(basename(__FILE__))) {
die;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timeMin = $unix->PROCCESS_TIME_MIN($pid);
if ($timeMin > 240) {
system_admin_events("Too many TTL, {$pid} will be killed", __FUNCTION__, __FILE__, __LINE__, "logrotate");
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
} else {
die;
}
}
if (!$GLOBALS["FORCE"]) {
$TimeExec = $unix->file_time_min($timefile);
if ($TimeExec < 240) {
return;
}
}
@unlink($timefile);
@file_put_contents($timefile, time());
$LogRotatePath = $sock->GET_INFO("LogRotatePath");
$SystemLogsPath = $sock->GET_INFO("SystemLogsPath");
$BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
$maillogStoragePath = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/maillogStoragePath"));
if ($GLOBALS["VERBOSE"]) {
echo "Starting Main\n";
}
$q = new mysql();
$q->QUERY_SQL("DROP TABLE `sysstorestatus`", "artica_events");
$sql = "CREATE TABLE IF NOT EXISTS `sysstorestatus` (\n\t\t\t `filepath` VARCHAR(255) NOT NULL,\n\t\t\t `filesize` BIGINT UNSIGNED NOT NULL,\n\t\t\t `zDate` DATETIME,\n\t\t\t PRIMARY KEY (`filepath`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `filesize` (`filesize`)\n\t\t\n\t\t\t)";
$q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
echo $q->mysql_error;
return;
}
ScanThis("/home/postfix/maillog");
ScanThis("/home/logrotate");
ScanThis("/home/logrotate_backup");
ScanThis("/home/logs-backup");
ScanThis("/home/backup/postfix");
ScanThis($LogRotatePath);
ScanThis($SystemLogsPath);
ScanThis($maillogStoragePath);
}
示例9: update
function update()
{
if (system_is_overloaded()) {
return;
}
$unix = new unix();
$sock = new sockets();
$pidfile = "/etc/artica-postfix/pids/exec.ipblock.php.update.pid";
$pidtime = "/etc/artica-postfix/pids/exec.ipblock.php.update.time";
$pid = @file_get_contents($pidfile);
if (!$GLOBALS["FORCE"]) {
if ($unix->process_exists($pid)) {
echo "Already running pid {$pid}\n";
return;
}
}
include_once dirname(__FILE__) . '/ressources/class.ccurl.inc';
if (!is_file($pidtime)) {
@file_put_contents($pidtime, time());
}
if (!$GLOBALS["FORCE"]) {
if ($unix->file_time_min($pidtime) > 720) {
@unlink($pidtime);
@file_put_contents($pidtime, time());
return;
}
}
@file_put_contents($pidfile, getmypid());
$EnableIpBlocks = intval($sock->GET_INFO("EnableIpBlocks"));
if ($EnableIpBlocks == 0) {
return;
}
$DIR_TEMP = $unix->TEMP_DIR();
$curl = new ccurl("http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz");
if (!$curl->GetFile("{$DIR_TEMP}/all-zones.tar.gz")) {
system_admin_events(0, "Fatal, Unable to download all-zones.tar.gz from ipdeny.com", __FILE__, __LINE__);
return;
}
$OldMd5 = $sock->GET_INFO("IpBlocksMD5");
$md5File = md5_file("{$DIR_TEMP}/all-zones.tar.gz");
if ($md5File == $OldMd5) {
ipblocks();
return;
}
$tar = $unix->find_program("tar");
@mkdir("/home/artica/ipblocks", 0755, true);
shell_exec("{$tar} xf {$DIR_TEMP}/all-zones.tar.gz -C /home/artica/ipblocks/");
if (ipblocks()) {
$sock->SET_INFO("IpBlocksMD5", "{$md5File}");
system_admin_events(0, "Restarting Firewall in order to refresh countries blocking");
}
}
示例10: scan
function scan()
{
if (system_is_overloaded(basename(__FILE__))) {
apache_admin_mysql(0, "Overloaded system, retry next time....", null, __FILE__, __LINE__);
return;
}
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$unix = new unix();
$pid = $unix->get_pid_from_file($pidFile);
if ($unix->process_exists($pid)) {
events("A process, {$pid} Already exists...");
return;
}
$GLOBALS["MYHOSTNAME_PROXY"] = $unix->hostname_g();
@file_put_contents($pidFile, getmypid());
$time = $unix->file_time_min($pidtime);
if (!$GLOBALS["VERBOSE"]) {
if ($time < 5) {
events("{$time}mn, require minimal 5mn");
return;
}
}
$q = new mysql_squid_builder();
$q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `dashboard_apache_sizes` ( `TIME` DATETIME,\n\t\t\t`zmd5` VARCHAR(90) NOT NULL PRIMARY KEY,\n\t\t\t`SITENAME` VARCHAR(128),\n\t\t\t`SIZE` BIGINT UNSIGNED, `RQS` BIGINT UNSIGNED,\n\t\t\tKEY `TIME` (`TIME`),\n\t\t\tKEY `SIZE` (`SIZE`),\n\t\t\tKEY `RQS` (`RQS`)\n\t\t\t) ENGINE=MYISAM;");
if (!$q->ok) {
apache_admin_mysql(0, "Fatal MySQL error", $q->mysql_error, __FILE__, __LINE__);
return;
}
if (!is_file("/home/apache/artica-stats/requests.log")) {
echo "/home/apache/artica-stats/requests.log no such file...\n";
return;
}
@mkdir("/home/apache/artica-stats/works", 0755, true);
if (is_file("/home/apache/artica-stats/works/apache.log")) {
echo "Parse /home/apache/artica-stats/works/apache.log\n";
Parse("/home/apache/artica-stats/works/apache.log");
return;
}
if (!@copy("/home/apache/artica-stats/requests.log", "/home/apache/artica-stats/works/apache.log")) {
echo "Copy failed\n";
return;
}
if (!is_file("/home/apache/artica-stats/works/apache.log")) {
echo "/home/apache/artica-stats/works/apache.log no such file...\n";
return;
}
@unlink("/home/apache/artica-stats/requests.log");
echo "Parse /home/apache/artica-stats/works/apache.log\n";
Parse("/home/apache/artica-stats/works/apache.log");
CLEAN_MYSQL();
}
示例11: launch_tests
function launch_tests()
{
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
return;
}
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overloaded, aborting task...", __FUNCTION__, __FILE__, __LINE__, "system");
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__);
return;
}
@file_put_contents($pidfile, getmypid());
$datafile = "/etc/artica-postfix/settings/Daemons/HdparmInfos";
writelogs("Testing hard drives ({$datafile})", __FUNCTION__, __FILE__, __LINE__);
$timenum = file_time_min($datafile);
if (is_file($datafile)) {
if (file_time_min($datafile) < 61) {
writelogs("{$timenum}Mn executed, waiting 60Mn", __FUNCTION__, __FILE__, __LINE__);
die;
}
}
if ($GLOBALS["FIND_HDPARM"] == null) {
writelogs("Unable to stat 'hdparm'", __FUNCTION__, __FILE__, __LINE__);
die;
}
$disks = GetDisks();
if (!is_array($disks)) {
return null;
}
while (list($index, $line) = each($disks)) {
unset($results);
exec("{$GLOBALS["FIND_HDPARM"]} -t {$index}", $results);
while (list($num, $line_result) = each($results)) {
if (preg_match("#=\\s+([0-9\\.]+)\\s+MB\\/sec\$#", $line_result, $re)) {
if (preg_match("#.+?\\/(.+)\$#", $index, $ri)) {
system_admin_events("{$ri[1]}:{$re[1]}MB/sec", __FUNCTION__, __FILE__, __LINE__, "system");
writelogs("testing disk {$ri[1]}:{$re[1]}MB/sec...", __FUNCTION__, __FILE__, __LINE__);
$array[$ri[1]] = $re[1];
}
}
}
}
@unlink($datafile);
@file_put_contents($datafile, base64_encode(serialize($array)));
if (!is_file($datafile)) {
writelogs("{$datafile} no such file or directory", __FUNCTION__, __FILE__, __LINE__);
}
}
示例12: parseQueue
function parseQueue()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
$sock = new sockets();
if ($unix->process_exists($pid, basename(__FILE__))) {
$pidTime = $unix->PROCCESS_TIME_MIN($pid);
events("Already process PID: {$pid} running since {$pidTime} minutes", __FUNCTION__, __FILE__, __LINE__, "postfix-stats");
return;
}
@file_put_contents($pidfile, getmypid());
if (system_is_overloaded(basename(__FILE__))) {
events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats");
return;
}
$EnableArticaSMTPStatistics = $sock->GET_INFO("EnableArticaSMTPStatistics");
if (!is_numeric($EnableArticaSMTPStatistics)) {
$EnableArticaSMTPStatistics = 0;
}
$directory = "/var/log/artica-mail";
if (!is_dir($directory)) {
return;
}
if (!($handle = @opendir($directory))) {
return;
}
$q = new mysql_postfix_builder();
$q->CheckTables();
events("open {$directory}");
while (false !== ($filename = readdir($handle))) {
if ($EnableArticaSMTPStatistics == 0) {
@unlink("{$directory}/{$filename}");
continue;
}
if (!preg_match("#(.+?)\\.[0-9]+\\.aws#", $filename, $re)) {
continue;
}
$instancename = $re[1];
ParseFile("{$directory}/{$filename}");
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats");
return;
}
}
}
示例13: parse_hours
function parse_hours()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if (!$GLOBALS["VERBOSE"]) {
if ($unix->file_time_min($pidTime) < 60) {
return;
}
}
$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());
@unlink($pidTime);
@file_put_contents($pidTime, time());
$sock = new sockets();
$EnableNginxStats = $sock->GET_INFO("EnableNginxStats");
if (!is_numeric($EnableNginxStats)) {
$EnableNginxStats = 0;
}
if ($EnableNginxStats == 0) {
return;
}
if (system_is_overloaded(basename(__FILE__))) {
events("Overloaded system: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} aborting", __FUNCTION__, __LINE__);
return;
}
$FALSES["information_schema"] = true;
$FALSES["mysql"] = true;
$q = new nginx_stats();
$DATABASE_LIST_SIMPLE = $q->DATABASE_LIST_SIMPLE();
while (list($db, $b) = each($DATABASE_LIST_SIMPLE)) {
if (isset($FALSES[$db])) {
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "Parsing database {$db}\n";
}
parse_database($db);
}
}
示例14: start
function start()
{
// /etc/artica-postfix/pids/exec.loadavg.php.start.time
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidfileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($GLOBALS["VERBOSE"]) {
echo "{$pidfileTime}\n";
}
if (!$GLOBALS["VERBOSE"]) {
if ($unix->file_time_min($pidfileTime) < 59) {
return;
}
}
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "{$pid} already executed since {$timepid}Mn\n";
}
if ($timepid < 15) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
if (system_is_overloaded()) {
if ($GLOBALS["VERBOSE"]) {
echo "Overloaded\n";
}
die;
}
@unlink($pidfileTime);
@file_put_contents($pidfileTime, time());
if ($GLOBALS["VERBOSE"]) {
echo "cpustats\n";
}
cpustats();
}
示例15: tables_hours
function tables_hours()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($GLOBALS["VERBOSE"]) {
echo "timefile={$timefile}\n";
}
$pid = @file_get_contents($pidfile);
if (!$GLOBALS["FORCE"]) {
if ($pid < 100) {
$pid = null;
}
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < 60) {
if ($GLOBALS["VERBOSE"]) {
echo "Only each 60mn - current {$timeexec}mn, use --force to bypass\n";
}
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
@unlink($timefile);
@file_put_contents($timefile, time());
$sock = new sockets();
$GLOBALS["Q"] = new mysql_squid_builder();
$prefix = date("YmdH");
$currenttable = "ngixattck_{$prefix}";
if ($GLOBALS["VERBOSE"]) {
echo "Current Table: {$currenttable}\n";
}
$tablesBrutes = $GLOBALS["Q"]->LIST_TABLES_NGINX_BLOCKED_RT();
while (list($tablename, $none) = each($tablesBrutes)) {
if ($tablename == $currenttable) {
if ($GLOBALS["VERBOSE"]) {
echo "Skip table: {$tablename}\n";
}
continue;
}
$t = time();
if ($GLOBALS["VERBOSE"]) {
echo "_table_hours_perform({$tablename})\n";
}
if (_table_hours_perform($tablename)) {
$took = $unix->distanceOfTimeInWords($t, time());
if ($GLOBALS["VERBOSE"]) {
echo "Remove table: {$tablename}\n";
}
$GLOBALS["Q"]->QUERY_SQL("DROP TABLE `{$tablename}`");
if (system_is_overloaded()) {
ufdbguard_admin_events("Fatal: Overloaded system: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} sleeping stopping function", __FUNCTION__, __FILE__, __LINE__, "stats");
return true;
}
}
}
}