private function raw_file_parse($objects_are_cached = false, $perms_are_cached = false, $apc_exists = false) { //echo "RAW PARSE<br />"; if (!$objects_are_cached) { //objects.cache data list($this->properties['hosts_objs'], $this->properties['services_objs'], $this->properties['hostgroups_objs'], $this->properties['servicegroups_objs'], $this->properties['timeperiods'], $this->properties['commands'], $this->properties['contacts'], $this->properties['contactgroups'], $this->properties['serviceescalations'], $this->properties['hostescalations'], $this->properties['hostdependencys'], $this->properties['servicedependencys']) = parse_objects_file(); if ($apc_exists) { $this->set_data_to_apc('objects'); } } //status.dat data always gets parsed if this function is called list($this->properties['hosts'], $this->properties['services'], $this->properties['hostcomments'], $this->properties['servicecomments'], $this->properties['program'], $this->properties['info']) = parse_status_file(); if ($apc_exists) { //echo "SAVING STATUS TO CACHE...<BR />"; $this->set_data_to_apc('status'); } //grab perms if they need to be updated if (!$perms_are_cached) { $this->properties['permissions'] = parse_perms_file(); if ($apc_exists) { $this->set_data_to_apc('permissions'); } } }
$STATUS_FILE = getenv("TN_STATUS_FILE") ? getenv("TN_STATUS_FILE") : "/var/log/nagios/status.dat"; $COMMAND_FILE = getenv("TN_COMMAND_FILE") ? getenv("TN_COMMAND_FILE") : "/var/log/nagios/rw/nagios.cmd"; ini_set("track_errors", TRUE); ini_set("date.timezone", "Asia/Tokyo"); define("TN_VERSION", "1.0"); define("HOST_UP", 0); define("HOST_DOWN", 1); define("HOST_UNREACHABLE", 2); define("STATE_OK", 0); define("STATE_WARNING", 1); define("STATE_CRITICAL", 2); define("STATE_UNKNOWN", 3); $HOST_STATUS_BY = array(HOST_UP => "Up", HOST_DOWN => "Down", HOST_UNREACHABLE => "Unreachable"); $SERVICE_STATUS_BY = array(STATE_OK => "OK", STATE_WARNING => "Warning", STATE_CRITICAL => "Critical", STATE_UNKNOWN => "Unknown"); $BASE_URL = $_SERVER["SCRIPT_NAME"]; $status = parse_status_file($STATUS_FILE); $global_stats = calc_global_stats($status); switch ($_REQUEST["page"]) { case NULL: view_main($global_stats, $status); break; case "downtime": view_downtime($global_stats, $status); break; case "schedule_downtime": command_schedule_downtime($global_stats, $status); break; default: trigger_error("unknown page: " . htmlspecialchars($_GET["page"], ENT_QUOTES), E_USER_NOTICE); } function begin_html()