function Sections() { if (!isset($_GET["tab"])) { $_GET["tab"] = 0; } switch ($_GET["tab"]) { case 0: ListRules(); break; case 1: DaemonSettings(); break; case 2: events_start(); break; default: ListRules(); break; } }
function launch_all_status($force = false) { xLoadAvg(); if (!is_file("/usr/share/artica-postfix/ressources/settings.inc")) { shell_exec("/usr/share/artica-postfix/bin/process1 --force"); } $trace = debug_backtrace(); if (isset($trace[1])) { $called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}"; events("{$called}", __FUNCTION__, __LINE__); } CheckCallable(); if (!is_file("/usr/share/artica-postfix/ressources/logs/global.versions.conf")) { events("-> artica-install --write-version", __FUNCTION__, __LINE__); $GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --write-versions"); } else { $filetime = file_time_min("/usr/share/artica-postfix/ressources/logs/global.versions.conf"); events("global.versions.conf={$filetime}mn ", __FUNCTION__, __LINE__); if ($filetime > 60) { events("global.versions.conf \"{$filetime}\"mn", __FUNCTION__, __LINE__); @unlink("/usr/share/artica-postfix/ressources/logs/global.versions.conf"); $GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --write-versions"); } } @unlink($GLOBALS["MY-POINTER"]); @file_put_contents($GLOBALS["MY-POINTER"], time()); $authtailftime = "/etc/artica-postfix/pids/auth-tail.time"; $unix = new unix(); $timefile = $unix->file_time_min($authtailftime); events("/etc/artica-postfix/pids/auth-tail.time -> {$timefile}Mn", __FUNCTION__, __LINE__); if ($timefile > 15) { @unlink($timefile); @file_put_contents($authtailftime, time()); $cmd = trim("{$GLOBALS["nohup"]} /etc/init.d/artica-postfix restart auth-logger >/dev/null 2>&1 &"); events($cmd); shell_exec($cmd); } $globalStatusIniTime = $unix->file_time_min("/usr/share/artica-postfix/ressources/logs/global.status.ini"); if ($GLOBALS["RUN_AS_DAEMON"]) { if ($globalStatusIniTime < 2) { return; } } events("**************** START ALL STATUS ****************"); events_start("start processing"); $t1 = time(); $functions = array("squid_master_status", "c_icap_master_status", "kav4Proxy_status", "dansguardian_master_status", "wpa_supplicant", "fetchmail", "milter_greylist", "framework", "pdns_server", "pdns_recursor", "cyrus_imap", "mysql_server", "mysql_mgmt", "mysql_replica", "openldap", "saslauthd", "syslogger", "squid_tail", "amavis", "amavis_milter", "boa", "lighttpd", "fcron1", "fcron2", "clamd", "clamscan", "clammilter", "freshclam", "retranslator_httpd", "spamassassin_milter", "spamassassin", "postfix", "postfix_logger", "mailman", "kas3_milter", "kas3_ap", "smbd", "nmbd", "winbindd", "scanned_only", "roundcube", "cups", "apache-groupware", "apache_groupware", "gdm", "console-kit", "xfce", "vmtools", "hamachi", "artica_notifier", "dhcpd_server", "pure_ftpd", "mldonkey", "policyd_weight", "backuppc", "kav4fs", "kav4fsavs", "apache_ocsweb", "web_download", "ocs_agent", "openssh", "gluster", "auditd", "squidguardweb", "opendkim", "ufdbguardd", "squidguard_logger", "milter_dkim", "dropbox", "artica_policy", "virtualbox_webserv", "tftpd", "dhcpd_server", "crossroads", "artica_status", "artica_executor", "artica_background", "bandwith", "pptpd", "pptp_clients", "apt_mirror", "squid_clamav_tail", "ddclient", "cluebringer", "apachesrc", "zarafa_web", "zarafa_ical", "zarafa_dagent", "zarafa_indexer", "zarafa_monitor", "zarafa_gateway", "zarafa_spooler", "zarafa_server", "assp", "openvpn", "vboxguest", "sabnzbdplus", "SwapWatchdog", "artica_meta_scheduler", "OpenVPNClientsStatus", "stunnel", "meta_checks", "zarafa_licensed", "CheckCurl", "ufdbguardd_tail", "vnstat", "NetAdsWatchdog", "munin", "autofs", "greyhole", "dnsmasq", "iscsi", "watchdog_yorel", "postfwd2", "vps_servers", "smartd", "crossroads_multiple", "auth_tail", "greyhole_watchdog", "greensql", "nscd", "tomcat", "openemm", "openemm_sendmail", "cgroups", "ntpd_server", "arpd", "ps_mem"); $data1 = $GLOBALS["TIME_CLASS"]; $data2 = time(); $difference = $data2 - $data1; $min = round($difference / 60); if ($min > 9) { events("reloading classes...", __FUNCTION__, __LINE__); $GLOBALS["TIME_CLASS"] = time(); $GLOBALS["CLASS_SOCKETS"] = new sockets(); $GLOBALS["CLASS_USERS"] = new settings_inc(); $GLOBALS["CLASS_UNIX"] = new unix(); } $took = $unix->distanceOfTimeInWords($t1, time()); events_start("end processing {$took}"); events("running " . count($functions) . " functions {$mem}MB in memory", __FUNCTION__, __LINE__); while (list($num, $func) = each($functions)) { if (function_exists($func)) { $mem = round(memory_get_usage() / 1024 / 1000, 2); if (!$force) { if (system_is_overloaded()) { events("running function \"{$func}\" {$mem}MB in memory", __FUNCTION__, __LINE__); events("System is overloaded: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]}, pause 10 seconds", __FUNCTION__, __LINE__); AmavisWatchdog(); greyhole_watchdog(); sleep(10); return; } else { if (systemMaxOverloaded()) { events("running function \"{$func}\" {$mem}MB in memory", __FUNCTION__, __LINE__); events("System is very overloaded {$GLOBALS["SYSTEM_INTERNAL_LOAD"]}, stop", __FUNCTION__, __LINE__); AmavisWatchdog(); greyhole_watchdog(); return; } } } try { $results = call_user_func($func); } catch (Exception $e) { writelogs("Fatal while running function {$func} ({$e})", __FUNCTION__, __FILE__, __LINE__); } if (trim($results) != null) { $conf[] = $results; usleep(5000); } } } events("running " . count($functions) . " functions DONE {$mem}MB in memory", __FUNCTION__, __LINE__); @unlink("/usr/share/artica-postfix/ressources/logs/global.status.ini"); file_put_contents("/usr/share/artica-postfix/ressources/logs/global.status.ini", @implode("\n", $conf)); @chmod(770, "/usr/share/artica-postfix/ressources/logs/global.status.ini"); @file_put_contents("/etc/artica-postfix/cache.global.status", @implode("\n", $conf)); events("creating status done " . count($conf) . " lines....", __FUNCTION__, __LINE__); $cmd = trim("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.parse-orders.php --manual >/dev/null 2>&1 &"); events($cmd); shell_exec($cmd); }