ServiceStatus API call to get metric data fails

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nagiosxi-admins
Posts: 17
Joined: Wed Mar 10, 2021 7:09 am

ServiceStatus API call to get metric data fails

Post by nagiosxi-admins »

Hi,

We are trying to fetch a specific metric data of all hosts in a certain host group.
Is there a way to get a certain metric data, say cpu or memory, for all hosts in a host group?

I can see that host group data is not returned in a servicestatus API call.

Thanks & Regards,
Ashok
User avatar
vtrac
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: ServiceStatus API call to get metric data fails

Post by vtrac »

Hi,
Yes, I tested the API call and do not see hostgroup in servicestatus.
Since hostgroup is not part of any services, I don't think you can get all servicestatus for that.

I tested the below command to display all services that has "display_name=PING"

Code: Select all

curl -XGET 'http://x.x.x.x/nagiosxi/api/v1/objects/servicestatus?apikey=QdCMT8vDhTvTNONiGcOSeRXA8WHsmgBds9YlANY7WNhKB4iev6mMXjilvg8VPIoh&pretty=1&display_name=PING'
Outputs:

Code: Select all

{
    "recordcount": 2,
    "servicestatus": [
        {
            "host_name": "localhost",
            "service_description": "PING",
            "display_name": "PING",
            "host_object_id": "146",
            "host_address": "127.0.0.1",
            "host_alias": "localhost",
            "icon_image": "",
            "icon_image_alt": "",
            "notes": "",
            "notes_url": "",
            "action_url": "",
            "servicestatus_id": "77",
            "instance_id": "1",
            "service_object_id": "152",
            "status_update_time": "2021-04-28 14:39:15",
            "output": "PING OK - Packet loss = 0%, RTA = 0.05 ms",
            "long_output": "",
            "perfdata": "rta=0.051000ms;100.000000;500.000000;0.000000 pl=0%;20;60;0",
            "current_state": "0",
            "has_been_checked": "1",
            "should_be_scheduled": "1",
            "current_check_attempt": "1",
            "max_check_attempts": "4",
            "last_check": "2021-04-28 14:39:11",
            "next_check": "2021-04-28 14:44:11",
            "check_type": "0",
            "check_options": "0",
            "last_state_change": "2021-04-27 11:49:13",
            "last_hard_state_change": "2021-04-27 11:49:13",
            "last_hard_state": "0",
            "last_time_ok": "2021-04-28 14:39:11",
            "last_time_warning": "1969-12-31 18:00:00",
            "last_time_unknown": "1969-12-31 18:00:00",
            "last_time_critical": "1969-12-31 18:00:00",
            "state_type": "1",
            "last_notification": "1969-12-31 18:00:00",
            "next_notification": "1969-12-31 18:00:00",
            "no_more_notifications": "0",
            "notifications_enabled": "1",
            "problem_has_been_acknowledged": "0",
            "acknowledgement_type": "0",
            "current_notification_number": "0",
            "passive_checks_enabled": "1",
            "active_checks_enabled": "1",
            "event_handler_enabled": "1",
            "flap_detection_enabled": "1",
            "is_flapping": "0",
            "percent_state_change": "0",
            "latency": "0",
            "execution_time": "4.06919",
            "scheduled_downtime_depth": "0",
            "failure_prediction_enabled": "0",
            "process_performance_data": "1",
            "obsess_over_service": "1",
            "modified_service_attributes": "0",
            "event_handler": "",
            "check_command": "check_ping!100.0,20%!500.0,60%!!!!!!",
            "normal_check_interval": "5",
            "retry_check_interval": "1",
            "check_timeperiod_object_id": "135"
        },
        {
            "host_name": "192.168.23.63-ncpa",
            "service_description": "PING",
            "display_name": "PING",
            "host_object_id": "164",
            "host_address": "192.168.23.63",
            "host_alias": "T1",
            "icon_image": "",
            "icon_image_alt": "",
            "notes": "",
            "notes_url": "",
            "action_url": "",
            "servicestatus_id": "76",
            "instance_id": "1",
            "service_object_id": "207",
            "status_update_time": "2021-04-28 14:36:23",
            "output": "PING OK - Packet loss = 0%, RTA = 0.93 ms",
            "long_output": "",
            "perfdata": "rta=0.934000ms;100.000000;500.000000;0.000000 pl=0%;20;60;0",
            "current_state": "0",
            "has_been_checked": "1",
            "should_be_scheduled": "1",
            "current_check_attempt": "1",
            "max_check_attempts": "4",
            "last_check": "2021-04-28 14:36:19",
            "next_check": "2021-04-28 14:41:19",
            "check_type": "0",
            "check_options": "0",
            "last_state_change": "2021-04-27 12:26:12",
            "last_hard_state_change": "2021-04-27 12:26:12",
            "last_hard_state": "0",
            "last_time_ok": "2021-04-28 14:36:19",
            "last_time_warning": "2021-04-27 11:54:34",
            "last_time_unknown": "1969-12-31 18:00:00",
            "last_time_critical": "2021-04-27 12:26:12",
            "state_type": "1",
            "last_notification": "1969-12-31 18:00:00",
            "next_notification": "1969-12-31 18:00:00",
            "no_more_notifications": "0",
            "notifications_enabled": "1",
            "problem_has_been_acknowledged": "0",
            "acknowledgement_type": "0",
            "current_notification_number": "0",
            "passive_checks_enabled": "1",
            "active_checks_enabled": "1",
            "event_handler_enabled": "1",
            "flap_detection_enabled": "1",
            "is_flapping": "0",
            "percent_state_change": "0",
            "latency": "0.0014319999609142542",
            "execution_time": "4.006499",
            "scheduled_downtime_depth": "0",
            "failure_prediction_enabled": "0",
            "process_performance_data": "1",
            "obsess_over_service": "1",
            "modified_service_attributes": "0",
            "event_handler": "",
            "check_command": "check_ping!100.0,20%!500.0,60%!!!!!!",
            "normal_check_interval": "5",
            "retry_check_interval": "1",
            "check_timeperiod_object_id": "135"
        }
    ]
}

Best Regards,
Vinh
Locked