Example #1
0
    //$event->set_check_id(null);
    $event->set_check_name($mydata['checkname']);
    $event->set_hostname($mydata['hostname']);
    $event->set_key1($mydata['key1']);
    $event->set_key2($mydata['key2']);
}
// Parse message data, to extract message and performance data
$msg_data = parse_perf_data($mydata['message']);
$event->set_info_msg($msg_data['message']);
$event->set_performance_data($msg_data['perf_data']);
// 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
$status = $event->handle_event();
//print status line
$resp_mesg = "Successfull {$status} for event_id: " . $event->get_event_id();
//header("HTTP/1.0 200 OK $resp_mesg");
print $resp_mesg;
function parse_perf_data($message)
{
    // Now we need to parse the $message and filter out performance data
    // Message can have multiple perf_data fields
    // perf data always comes after a | sign
    // 'label'=value[UOM];[warn];[crit];[min];[max]
    // For now we don't implement [warn];[crit];[min];[max] , just the data
    // UOM (unit of measurement) is one of:
    // no unit specified - assume a number (int or float) of things (eg, users, processes, load averages)
    //  s - seconds (also us, ms)
    //  % - percentage
    //  B - bytes (also KB, MB, TB)
    //  c - a continous counter (such as bytes transmitted on an interface)