$script_dir = "check-scripts"; // Get check info // Create check object $check = new Check($check_id); // Start timer and exec check script $time_start = microtime(true); $script = "{$script_dir}/" . $check->get_parsed_check_script(); $check_result = exec_check($script); // Now create a new Event object // Store the info we know from Check object // and check results $event = new Event(); $event->set_status($check_result['status']); $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'];
function displayAllChecks() { //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("Add Check"); $toolIcons = array("add"); $toolHandlers = array("handleEvent('" . $_SERVER['PHP_SELF'] . "?action=addCheck')"); echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); $keyHandlers = array(); $keyData = array(); $keyTitle = array(); foreach (Check::get_checks() as $id => $name) { $check = new Check($id); array_push($keyHandlers, "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=showCheck&checkid=" . $check->get_check_id() . "')"); array_push($keyData, $check->get_name()); array_push($keyData, $check->get_hostname()); array_push($keyData, $check->get_desc()); array_push($keyData, $check->get_interval()); array_push($keyData, $check->get_template_name()); } $headings = array("Name", "Host", "Description", "Interval", "Template"); $form->setCols(5); $form->setTableWidth("1024px"); $form->setData($keyData); $form->setEventHandler($keyHandlers); $form->setHeadings($headings); $form->setSortable(true); echo $form->showForm(); }