// 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']; } print " -- ({$time} sec)\n"; // This function does the actual execution function exec_check($script)
function displayCheckDetails() { //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("Edit Check", "Delete Check", "Create Report"); $toolIcons = array("edit", "delete", "report"); $toolHandlers = array("handleEvent('" . $_SERVER['PHP_SELF'] . "?action=editCheck&checkid=" . $_GET[checkid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=deleteCheck&checkid=" . $_GET[checkid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=renderCheckReportForm&checkid=" . $_GET[checkid] . "')"); echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); $keyHandlers = array(); $keyData = array(); $keyTitle = array(); if (is_numeric($_GET[checkid])) { $check = new Check($_GET[checkid]); } else { $form->warning("Invalid check id"); return; } $keyData = array($check->get_name(), $check->get_hostname(), $check->get_desc(), $check->get_interval() . " Minutes", $check->get_template_name(), $check->get_arguments(), $check->get_key1(), $check->get_key2(), nl2br($check->get_notes())); $headings = array("Check Details"); $key1 = "Key1<br><small>" . $check->get_key1_name() . "</small>"; $key2 = "Key2<br><i><small>" . $check->get_key2_name() . "</small></i>"; $keyTitle = array("Name.tip.descriptive name for this chesk", "Hostname", "Description.tip.A usefull description", "Interval.tip.Check interval in Minutes", "Template", "Arguments", "{$key1}", "{$key2}", "Notes"); $form->setCols(2); $form->setTableWidth("450px"); $form->setData($keyData); $form->setTitles($keyTitle); $form->setEventHandler($keyHandlers); $form->setHeadings($headings); $form->setSortable(false); return $form->showForm(); }