I have found what i was looking for.
For those who needs the same informations:
1 -- just open http://.../nagiosxi/backend/?cmd=getserviceStatus in your browser.
2 -- Under each <servicestatus> entry, you will find someting like:
Code: Select all
<instance_id>1</instance_id>
<service_id>5959</service_id>
<host_id>4768</host_id>
<host_name>X-Prod-TFS</host_name>
<name>SQL DISK F</name>
<current_notification_number>0</current_notification_number>
....
3 -- All value can be used with $backendargs["value"]
Example:
if you want to apply filter on "current_notification_number" = 1
you have to use :
$backendargs["current_notification_number"] = 1;
That's all.
You can use ALL xml entries, that's pretty easy.
here my full code for those who need it:
file
/usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-status.inc.php
Code: Select all
....
function xicore_ajax_get_service_status_summary_html($args = null)
{
global $lstr;
//BENCHMARKING
//$start = timer_start();
$output = '';
$host = grab_array_var($args, "host", "");
$hostgroup = grab_array_var($args, "hostgroup", "");
$servicegroup = grab_array_var($args, "servicegroup", "");
$hoststatustypes = grab_array_var($args, "hoststatustypes", HOSTSTATE_ANY);
// special "all" stuff
if ($hostgroup == "all")
$hostgroup = "";
if ($servicegroup == "all")
$servicegroup = "";
if ($host == "all")
$host = "";
// limit hosts by hostgroup or host
$host_ids = array();
$host_ids_str = "";
// limit by hostgroup
if ($hostgroup != "") {
$host_ids = get_hostgroup_member_ids($hostgroup);
} // limit by host
else if ($host != "") {
$host_ids[] = get_host_id($host);
}
$y = 0;
foreach ($host_ids as $hid) {
if ($y > 0)
$host_ids_str .= ",";
$host_ids_str .= $hid;
$y++;
}
// limit service by servicegroup
$service_ids = array();
$service_ids_str = "";
if ($servicegroup != "") {
$service_ids = get_servicegroup_member_ids($servicegroup);
}
$y = 0;
foreach ($service_ids as $sid) {
if ($y > 0)
$service_ids_str .= ",";
$service_ids_str .= $sid;
$y++;
}
// PREP TO GET TOTAL RECORD COUNTS FROM BACKEND...
$backendargs = array();
$backendargs["cmd"] = "getservicestatus";
$backendargs["limitrecords"] = false; // don't limit records
$backendargs["totals"] = 1; // only get recordcount
$backendargs["combinedhost"] = true; // get host status too
// host id limiters
if ($host_ids_str != "")
$backendargs["host_id"] = "in:" . $host_ids_str;
// service id limiters
if ($service_ids_str != "")
$backendargs["service_id"] = "in:" . $service_ids_str;
// get total services
//$timerinfo[]=get_timer();
//$xml=get_backend_xml_data($backendargs);
$xml = get_xml_service_status($backendargs);
$total_records = 0;
if ($xml)
$total_records = intval($xml->recordcount);
// get state totals (ok/pending checked later)
$state_totals = array();
for ($x = 1; $x <= 3; $x++) {
$backendargs["current_state"] = $x;
//$timerinfo[]=get_timer();
//$xml=get_backend_xml_data($backendargs);
$xml = get_xml_service_status($backendargs);
$state_totals[$x] = 0;
if ($xml)
$state_totals[$x] = intval($xml->recordcount);
}
// get ok (non-pending)
$backendargs["current_state"] = 0;
$backendargs["has_been_checked"] = 1;
//$timerinfo[]=get_timer();
//$xml=get_backend_xml_data($backendargs);
$xml = get_xml_service_status($backendargs);
$state_totals[0] = 0;
if ($xml)
$state_totals[0] = intval($xml->recordcount);
// get pending
$backendargs["current_state"] = 0;
$backendargs["has_been_checked"] = 0;
//$timerinfo[]=get_timer();
//$xml=get_backend_xml_data($backendargs);
$xml = get_xml_service_status($backendargs);
$state_totals[4] = 0;
if ($xml)
$state_totals[4] = intval($xml->recordcount);
// MOD BY S.MOULIN
// get critical wihtout acknowledged or downtime
unset($backendargs["brevity"]);
$backendargs["cmd"] = "getservicestatus";
$backendargs["has_been_checked"] = 1;
$backendargs["problem_acknowledged"] = 0;
$backendargs["is_flapping"] = 0;
$backendargs["acknowledgement_type"] = 0;
$backendargs["scheduled_downtime_depth"] = 0;
$backendargs["current_state"] = 2;
$backendargs["totals"] = 1; // only get recordcount
$backendargs["limitrecords"] = false; // don't limit records
$xml = get_xml_service_status($backendargs);
$state_totals[5] = 0;
if ($xml)
$state_totals[5] = intval($xml->recordcount);
// END MOD
// total problems
$total_problems = $state_totals[1] + $state_totals[2] + $state_totals[3];
// unhandled problems
$backendargs["current_state"] = "in:1,2,3";
unset($backendargs["has_been_checked"]);
//$backendargs["has_been_checked"]=1;
$backendargs["problem_acknowledged"] = 0;
$backendargs["scheduled_downtime_depth"] = 0;
//$backendargs["notifications_enabled"]=1;
// Commenting below so the unhandled services number actually reflects what is displayed in the table when clicking the link -SW
//$backendargs["host_current_state"]=0; // up state
//$timerinfo[]=get_timer();
//$xml=get_backend_xml_data($backendargs);
$xml = get_xml_service_status($backendargs);
$unhandled_problems = 0;
if ($xml)
$unhandled_problems = intval($xml->recordcount);
//$output.='ARGS: '.serialize($args);
//$timerinfo[]=get_timer();
/*
$last_ti=0;
$x=0;
foreach($timerinfo as $ti){
if($x==0){
$last_ti=$ti;
$x++;
continue;
}
echo "T".$x."-T".($x-1).": ".get_timer_diff($last_ti,$ti)."<BR>";
$last_ti=$ti;
$x++;
}
//print_r($timerinfo);
*/
$output .= '<div class="infotable_title">' . _('Service Status Summary') . '</div>';
$show = "services";
// urls
$baseurl = get_base_url() . "includes/components/xicore/status.php?";
if ($hostgroup != "")
$baseurl .= "&hostgroup=" . urlencode($hostgroup);
if ($servicegroup != "")
$baseurl .= "&servicegroup=" . urlencode($servicegroup);
if ($host != "")
$baseurl .= "&host=" . urlencode($host);
$state_text = array();
$state_text[0] = "<div class='serviceok";
if ($state_totals[0] > 0)
$state_text[0] .= " haveserviceok";
$state_text[0] .= "'>";
$state_text[0] .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . SERVICESTATE_OK . "'>" . $state_totals[0] . "</a>";
$state_text[0] .= "</div>";
$state_text[1] = "<div class='servicewarning";
if ($state_totals[1] > 0)
$state_text[1] .= " haveservicewarning";
$state_text[1] .= "'>";
$state_text[1] .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . SERVICESTATE_WARNING . "'>" . $state_totals[1] . "</a>";
$state_text[1] .= "</div>";
$state_text[3] = "<div class='serviceunknown";
if ($state_totals[3] > 0)
$state_text[3] .= " haveserviceunknown";
$state_text[3] .= "'>";
$state_text[3] .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . SERVICESTATE_UNKNOWN . "'>" . $state_totals[3] . "</a>";
$state_text[3] .= "</div>";
$state_text[2] = "<div class='servicecritical";
if ($state_totals[2] > 0)
$state_text[2] .= " haveservicecritical";
$state_text[2] .= "'>";
$state_text[2] .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . SERVICESTATE_CRITICAL . "'>" . $state_totals[2] . "</a>";
$state_text[2] .= "</div>";
$state_text[4] = "<div class='servicepending";
if ($state_totals[4] > 0)
$state_text[4] .= " haveservicepending";
$state_text[4] .= "'>";
$state_text[4] .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . SERVICESTATE_PENDING . "'>" . $state_totals[4] . "</a>";
$state_text[4] .= "</div>";
// MOD BY S.MOULIN
$state_text[5] = "<div class='servicecritical";
if ($state_totals[5] > 0)
$state_text[5] .= " haveservicecritical";
$state_text[5] .= "'>";
$state_text[5] .= "<a href='" . $baseurl . "&show=services&servicestatustypes=16&serviceattr=2058&hostattr=2058'>" . $state_totals[5] . "</a>";
$state_text[5] .= "</div>";
// END
$unhandled_problems_text = "<div class='unhandledserviceproblems";
if ($unhandled_problems > 0)
$unhandled_problems_text .= " haveunhandledserviceproblems";
$unhandled_problems_text .= "'>";
$unhandled_problems_text .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . (SERVICESTATE_WARNING | SERVICESTATE_UNKNOWN | SERVICESTATE_CRITICAL) . "&serviceattr=" . (SERVICESTATUSATTR_NOTACKNOWLEDGED | SERVICESTATUSATTR_NOTINDOWNTIME) . "'>" . $unhandled_problems . "</a>";
$unhandled_problems_text .= "</div>";
$total_problems_text = "<div class='serviceproblems";
if ($total_problems > 0)
$total_problems_text .= " haveserviceproblems";
$total_problems_text .= "'>";
$total_problems_text .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "&servicestatustypes=" . (SERVICESTATE_WARNING | SERVICESTATE_UNKNOWN | SERVICESTATE_CRITICAL) . "'>" . $total_problems . "</a>";
$total_problems_text .= "</div>";
$total_records_text = "<div class='allservices";
if ($total_records > 0)
$total_records_text .= " haveallservices";
$total_records_text .= "'>";
$total_records_text .= "<a href='" . $baseurl . "&show=" . $show . "&hoststatustypes=" . $hoststatustypes . "'>" . $total_records . "</a>";
$total_records_text .= "</div>";
if (1) {
$output .= '
<table class="infotable table table-condensed table-striped table-bordered">
<thead>
<tr><th colspan="2" bgcolor="#ffcccc">Action needed' . $state_text[5] . '</th><th colspan="2">Critical' . $state_text[2] . '</th></tr>
</thead>
';
$output .= '
<thead>
<tr><th>' . $lstr['ServiceStateOkText'] . '</th><th>' . $lstr['ServiceStateWarningText'] . '</th><th>' . $lstr['ServiceStateUnknownText'] . '</th><th>' . $lstr['ServiceStatePendingText'] . '</th></tr>
</thead>
';
$output .= '
<tbody>
<tr><td>' . $state_text[0] . '</td><td>' . $state_text[1] . '</td><td>' . $state_text[3] . '</td><td>' . $state_text[4] . '</td></tr>
</tbody>
';
$output .= '
<thead>
<tr><th colspan="2">' . _('Unhandled') . '</th><th>' . _('Problems') . '</th><th>All</th></tr>
</thead>
';
$output .= '
<tbody>
<tr><td colspan="2">' . $unhandled_problems_text . '</td><td>' . $total_problems_text . '</td><td>' . $total_records_text . '</td></tr>
</tbody>
';
$output .= '
</table>';
}
$output .= '
<div class="ajax_date">' . _('Last Updated') . ': ' . get_datetime_string(time()) . '</div>
';
//echo "TOTAL: ".timer_stop($start)."<br />";
return $output;
}
....
Remember that this is NOT supported by NAGIOS and an update should break your modifications.