1. I set up a hostgroup, named "centos" with 4 members. All of the hosts have dashes in the name.
2. I disabled active checks on two of the hosts, and sent a passive "DOWN" check result, to bring them down.
3. I grabbed the names of the hostgroup members via a REST API call:
4. I checked which of the members are in DOWN state:
Code: Select all
[root@main-nagios-xi libexec]# curl -s -XGET "http://x.x.x.x/nagiosxi/api/v1/objects/hoststatus?apikey=xxx&pretty=1¤t_state=nin:0&name=in:CentOS-NCPA,CentOS-SSH,CentOS-NRPE,CentOS-SNMP"
{
"recordcount": "2",
"hoststatus": [
{
"@attributes": {
"id": "726157"
},
"instance_id": "1",
"host_id": "286",
"name": "CentOS-NRPE",
"display_name": "CentOS-NRPE",
"address": "192.168.x.x",
"alias": "CentOS-NRPE",
"status_update_time": "2019-10-29 08:58:00",
"status_text": "test",
"status_text_long": {
},
"current_state": "1",
"icon_image": "centos.png",
"icon_image_alt": {
},
"performance_data": {
},
"should_be_scheduled": "0",
"check_type": "1",
"last_state_change": "2019-10-29 08:57:27",
"last_hard_state_change": "2019-10-29 08:57:27",
"last_hard_state": "1",
"last_time_up": "2019-10-29 08:57:27",
"last_time_down": "2019-10-17 09:17:15",
"last_time_unreachable": "2019-08-16 11:55:17",
"last_notification": "1969-12-31 18:00:00",
"next_notification": "1969-12-31 18:00:00",
"no_more_notifications": "0",
"acknowledgement_type": "0",
"current_notification_number": "0",
"event_handler_enabled": "1",
"process_performance_data": "1",
"obsess_over_host": "1",
"modified_host_attributes": "2",
"event_handler": {
},
"check_command": "check_xi_host_ping!3000.0!80%!5000.0!100%!!!!",
"normal_check_interval": "1",
"retry_check_interval": "1",
"check_timeperiod_id": "132",
"has_been_checked": "1",
"current_check_attempt": "1",
"max_check_attempts": "5",
"last_check": "2019-10-29 08:57:27",
"next_check": "2019-10-29 08:58:00",
"state_type": "1",
"notifications_enabled": "1",
"problem_acknowledged": "0",
"passive_checks_enabled": "1",
"active_checks_enabled": "0",
"flap_detection_enabled": "1",
"is_flapping": "0",
"percent_state_change": "6.11842",
"latency": "0.90374",
"execution_time": "0",
"scheduled_downtime_depth": "0",
"notes": "44.8277446,-92.9438218",
"notes_url": {
},
"action_url": {
}
},
{
"@attributes": {
"id": "726156"
},
"instance_id": "1",
"host_id": "284",
"name": "CentOS-NCPA",
"display_name": "CentOS-NCPA",
"address": "192.168.x.x",
"alias": "CentOS-NCPA",
"status_update_time": "2019-10-29 09:00:42",
"status_text": "test",
"status_text_long": {
},
"current_state": "1",
"icon_image": "ncpa.png",
"icon_image_alt": {
},
"performance_data": {
},
"should_be_scheduled": "0",
"check_type": "1",
"last_state_change": "2019-10-29 08:56:58",
"last_hard_state_change": "2019-10-29 08:56:58",
"last_hard_state": "1",
"last_time_up": "2019-10-29 08:56:58",
"last_time_down": "2019-06-20 16:43:45",
"last_time_unreachable": "2019-08-16 11:55:21",
"last_notification": "1969-12-31 18:00:00",
"next_notification": "1969-12-31 18:00:00",
"no_more_notifications": "0",
"acknowledgement_type": "0",
"current_notification_number": "0",
"event_handler_enabled": "1",
"process_performance_data": "1",
"obsess_over_host": "1",
"modified_host_attributes": "2",
"event_handler": {
},
"check_command": "check_xi_host_ping!3000.0!80%!5000.0!100%",
"normal_check_interval": "5",
"retry_check_interval": "1",
"check_timeperiod_id": "132",
"has_been_checked": "1",
"current_check_attempt": "1",
"max_check_attempts": "5",
"last_check": "2019-10-29 08:56:58",
"next_check": "2019-10-29 09:00:42",
"state_type": "1",
"notifications_enabled": "1",
"problem_acknowledged": "0",
"passive_checks_enabled": "1",
"active_checks_enabled": "0",
"flap_detection_enabled": "1",
"is_flapping": "0",
"percent_state_change": "0",
"latency": "0.33262",
"execution_time": "0",
"scheduled_downtime_depth": "0",
"notes": "44.8479039,-93.0428119",
"notes_url": {
},
"action_url": {
}
}
]
}