$event->set_info_msg($check_result['message']); $event->set_performance_data($check_result['perf_data']); $event->set_check_id($check->get_check_id()); $event->set_script($script); $event->set_check_name($check->get_name()); $event->set_hostname($check->get_hostname()); $event->set_key1($check->get_key1()); $event->set_key2($check->get_key2()); // Now we can use handle_event() to figure out if this is a new // or exitsing event. It will do all the updating for us // and call notify() in the event class $event->handle_event(); $time_end = microtime(true); $time = $time_end - $time_start; //print status line print "{$script} => status: " . $event->get_status() . " " . trim($event->get_info_msg()); if ($check_result['perf_data'] != "") { print " | " . $check_result['perf_data']; } print " -- ({$time} sec)\n"; // This function does the actual execution function exec_check($script) { $return_var = 3; $error = false; // first check if script exist list($filename) = split(" ", $script); if (file_exists($filename)) { if (!is_executable($filename)) { $error = true; $return_var = 3;
function displayAll() { //global the tool and make a tool bar for adding a device and display all the archived device, and displaying the IP Report global $tool, $form, $status_array, $status_collors; $toolNames = array("Configure Checks", "Check Templates", "Reports"); $toolIcons = array("device", "icons/checklist.png", "stat"); $toolHandlers = array("handleEvent('" . $_SERVER['PHP_SELF'] . "?action=list_checks')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=list_templates')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=list_ReportProfiles')"); echo "<h2>Events Dashboard</h2>"; echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); $keyHandlers = array(); $keyData = array(); $keyTitle = array(); foreach (Event::get_events() as $id => $name) { $event = new Event($id); $check_id = $event->get_check_id(); $check = new Check($check_id); if (is_null($check_id)) { array_push($keyHandlers, ""); } else { array_push($keyHandlers, "handleEvent('monitor.php?action=showCheck&checkid={$check_id}')"); } $status = 3; $status = $event->get_status(); $status_name = $status_array[$status]; array_push($keyData, "<font color={$status_collors[$status]}> {$status_name} </font>"); array_push($keyData, $event->get_hostname()); array_push($keyData, $event->get_check_name() . ".tip." . $check->get_desc() . "<br> " . $event->get_key1() . "<br>" . $event->get_key2()); array_push($keyData, $event->get_insert_date()); array_push($keyData, $event->get_last_updated()); $insert_time = strtotime($event->get_insert_date()); $last_time = strtotime($event->get_last_updated()); $diff = strTime($last_time - $insert_time); array_push($keyData, $diff); array_push($keyData, $event->get_info_msg()); } $headings = array("Status", "Host", "Service", "Insert Time", "Last Check", "Duration", "Service Information"); $form->setCols(7); $form->setTableWidth("90%"); $form->setData($keyData); $form->setEventHandler($keyHandlers); $form->setHeadings($headings); $form->setSortable(true); echo $form->showForm(); echo "<meta http-equiv=\"REFRESH\" content=\"300;url=" . $_SERVER['PHP_SELF'] . "\">"; }