Exemplo n.º 1
0
 protected function get_event_info($event_id)
 {
     $query = "SELECT \n\t\t\t\tevents.event_id,\n\t\t\t\tevents.status,\n\t\t\t\tevents.info_msg,\n\t\t\t\tevents.insert_date,\n\t\t\t\tevents.last_updated,\n\t\t\t\tevents.active,\n\t\t\t\tevents.check_id,\n\t\t\t\tevents.host_name,\n\t\t\t\tevents.check_name,\n\t\t\t\tevents.key1,\n\t\t\t\tevents.key2,\n\t\t\t\tevents.script,\n\t\t\t\tevents.notify_state\n\t\t\tFROM \n\t\t\t\tevents\n\t\t\tWHERE\n\t\t\t\tevents.event_id = '{$event_id}' \n\t\t ";
     // execute the query
     $result = mysql_query($query);
     if (!$result) {
         $this->error = mysql_error() . "   -- query: {$query} ";
         print "ANDREE {$this->error} <br>";
         return false;
     }
     if (mysql_numrows($result) < 1) {
         $this->error = "No data found for this event";
         return false;
     }
     while ($obj = mysql_fetch_object($result)) {
         $this->event_id = $obj->event_id;
         $this->status = $obj->status;
         $this->info_msg = $obj->info_msg;
         $this->insert_date = $obj->insert_date;
         $this->last_updated = $obj->last_updated;
         $this->active = $obj->active;
         $this->check_id = $obj->check_id;
         if (is_null($obj->check_id)) {
             $this->hostname = $obj->host_name;
             $this->check_name = $obj->check_name;
         } else {
             $check = new Check($obj->check_id);
             $this->hostname = $check->get_hostname();
             $this->check_name = $check->get_name();
         }
         $this->key1 = $obj->key1;
         $this->key2 = $obj->key2;
         $this->script = $obj->script;
         $this->notify_state = $obj->notify_state;
     }
     return true;
 }
Exemplo n.º 2
0
$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'];
}
print " -- ({$time} sec)\n";
// This function does the actual execution
Exemplo n.º 3
0
function addCheckToProfileForm()
{
    global $tool, $form;
    $keyHandlers = array();
    $keyData = array();
    $keyTitle = array();
    if (is_numeric($_GET[profileid])) {
        $profile = new CheckReportProfile($_GET[profileid]);
    } else {
        $form->warning("Invalid Profile id id");
        return;
    }
    echo "<h2>Add check to profile " . $profile->get_name() . "</h2>";
    $filter .= "<p>";
    $tool = new EdittingTools();
    $filter .= $tool->createNewFilters();
    $filter .= "<div style=\"clear:both;\"></div> </p>";
    echo $filter;
    foreach (Check::get_checks() as $id => $name) {
        $check = new Check($id);
        array_push($keyData, "<input type=checkbox name=checks[] value='{$id}'");
        array_push($keyData, $check->get_name());
        array_push($keyData, $check->get_hostname());
        array_push($keyData, $check->get_desc());
        array_push($keyData, $check->get_template_name());
    }
    $headings = array("Select", "Name", "Host", "Description", "Template");
    $form->setCols(5);
    $form->setTableWidth("1024px");
    $form->setData($keyData);
    $form->setEventHandler($keyHandlers);
    $form->setHeadings($headings);
    $form->setSortable(true);
    // manually create form
    echo "<p><b>Select the checks you'd like to add to this profile.</b></p>";
    echo "<br><form action='' id='dataForm' method='POST' name='dataForm'>";
    echo $form->showForm();
    echo "<br><div style='clear:both;'><br></div>";
    echo "<INPUT TYPE='SUBMIT' VALUE='Add Selected Checks' name='addChecksToProfile'>";
    echo "</form>";
}