function monit() { $monit = new monit_unix(); $monit->WAKEUP(); $unix = new unix(); $unix->chmod_func(0755, "/etc/artica-postfix/settings/Daemons/*"); }
function monit() { if (!$GLOBALS["CLASS_USERS"]->MONIT_INSTALLED) { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . " MEMCACHED_INSTALLED = FALSE\n"; } $l[] = "[APP_MONIT]"; $l[] = "service_name=APP_MONIT"; $l[] = "installed=0"; $l[] = "service_disabled=0"; return implode("\n", $l); } $bin = $GLOBALS["CLASS_UNIX"]->find_program("monit"); $EnableDaemon = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableMonit"); $SquidPerformance = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("SquidPerformance")); if ($SquidPerformance > 2) { $EnableDaemon = 0; } if (!is_numeric($EnableDaemon)) { $EnableDaemon = 1; } $unix = new unix(); $master_pid = $unix->get_pid_from_file("/var/run/monit/monit.pid"); $cache_file = "/usr/share/artica-postfix/ressources/logs/web/monit.status.all"; if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($bin, true); } if ($EnableDaemon == 0) { if ($GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { shell_exec2("/etc/init.d/monit stop"); } } $l[] = "[APP_MONIT]"; $l[] = "service_name=APP_MONIT"; $l[] = "master_version=" . monit_daemon_version(); $l[] = "service_disabled={$EnableDaemon}"; $l[] = "watchdog_features=1"; $l[] = "service_cmd=/etc/init.d/monit"; $l[] = "family=system"; $l[] = "installed=1"; if ($EnableDaemon == 0) { $l[] = ""; return implode("\n", $l); return; } if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { if ($GLOBALS["VERBOSE"]) { echo " **** NO RUNNING ****\n"; } if (!$GLOBALS["DISABLE_WATCHDOG"]) { shell_exec2("/etc/init.d/monit start"); } $l[] = "running=0"; $l[] = ""; return implode("\n", $l); } $AS_CGROUP = false; if ($GLOBALS["CLASS_SOCKETS"]->EnableIntelCeleron == 1) { $AS_CGROUP = true; } if ($AS_CGROUP) { events("mysqld cgroup must be enabled ....", __FUNCTION__, __LINE__); $cgroups = new status_cgroups(); $limit = $cgroups->GetLimit($master_pid); if ($cgroups->GetLimit($master_pid) == "unlimited") { $cgroups->set_limit("php", $master_pid); } } $l[] = GetMemoriesOf($master_pid); $l[] = "running=1"; $monit = new monit_unix(); $monit->WAKEUP(); $time = $GLOBALS["CLASS_UNIX"]->file_time_min($cache_file); if ($GLOBALS["VERBOSE"]) { echo "{$cache_file} = {$time}mn DISABLE_WATCHDOG = {$GLOBALS["DISABLE_WATCHDOG"]}\n"; } if ($time > 2) { if (!$GLOBALS["DISABLE_WATCHDOG"]) { shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.monit.php --status >/dev/null 2>&1 &"); } } return implode("\n", $l); }