Page 1 of 1
Current service status API
Posted: Tue Dec 03, 2019 6:46 am
by grayloglearn
Hi Team,
Could you please explain me the below API call meaning
https://nagihprod/nagiosxi/api/v1/objec ... e=NSClient Version
Does this API will check the current status of nsclient version for the hyd01.com ??
or
Does this API will show us the last check status of the nsclient version for the hyd01.com??
or
Does this API will poll and get the nsclient version for the hyd01.com ??
Re: Current service status API
Posted: Tue Dec 03, 2019 7:58 am
by scottwilkerson
It will return the data that nagios has already in memory for that service, it will not trigger the service to be checked
The data would be similar to the following
Code: Select all
{
"recordcount": "1",
"servicestatus": [
{
"@attributes": {
"id": "3081"
},
"instance_id": "1",
"service_id": "195",
"host_id": "187",
"host_name": "hyd01.com",
"name": "NSClient Version",
"host_display_name": "",
"host_address": "127.0.0.1",
"display_name": "NSClient Version",
"status_update_time": "2015-09-24 02:33:54",
"status_text": "NSClient++ 0.5.2.35 2018-01-28",
"status_text_long": "",
"current_state": "0",
"performance_data": "",
"should_be_scheduled": "1",
"check_type": "0",
"last_state_change": "2015-09-22 05:44:33",
"last_hard_state_change": "2015-09-22 05:48:27",
"last_hard_state": "2",
"last_time_ok": "2015-09-19 19:27:11",
"last_time_warning": "1969-12-31 18:00:00",
"last_time_critical": "2015-09-21 02:24:18",
"last_time_unknown": "1969-12-31 18:00:00",
"last_notification": "2015-09-23 05:48:25",
"next_notification": "2015-09-23 06:48:25",
"no_more_notifications": "0",
"acknowledgement_type": "0",
"current_notification_number": "2",
"process_performance_data": "1",
"obsess_over_service": "1",
"event_handler_enabled": "1",
"modified_service_attributes": "0",
"event_handler": "",
"check_command": "check_xi_domain_v2!test123!-w 4!-c 6",
"normal_check_interval": "1440",
"retry_check_interval": "1",
"check_timeperiod_id": "128",
"icon_image": "",
"icon_image_alt": "",
"has_been_checked": "1",
"current_check_attempt": "5",
"max_check_attempts": "5",
"last_check": "2015-09-23 05:48:25",
"next_check": "2015-09-24 05:48:25",
"state_type": "1",
"notifications_enabled": "1",
"problem_acknowledged": "0",
"flap_detection_enabled": "1",
"is_flapping": "0",
"percent_state_change": "6.12",
"latency": "0",
"execution_time": "0.51",
"scheduled_downtime_depth": "0",
"passive_checks_enabled": "1",
"active_checks_enabled": "1"
}
]
}
Re: Current service status API
Posted: Tue Dec 03, 2019 8:55 am
by grayloglearn
Do we have any such API to be check the status of the remote service?
Re: Current service status API
Posted: Tue Dec 03, 2019 9:07 am
by scottwilkerson
grayloglearn wrote:Do we have any such API to be check the status of the remote service?
No, this does not exist at this time
Re: Current service status API
Posted: Tue Dec 03, 2019 10:40 am
by grayloglearn
Which state it will consider when we use this API, Is it hard or Soft?? As you said it will take nagios which is already in memory.
Re: Current service status API
Posted: Tue Dec 03, 2019 10:45 am
by scottwilkerson
grayloglearn wrote:Which state it will consider when we use this API, Is it hard or Soft?? As you said it will take nagios which is already in memory.
It depends on the value of
state_type in the output.
0 = SOFT
1 = HARD
Re: Current service status API
Posted: Tue Dec 03, 2019 11:48 pm
by grayloglearn
When we call API to get the hyd01.com.au
{"recordcount":"1","servicestatus":{"@attributes":{"id":"84661653"},"instance_id":"1","service_id":"59633","host_id":"59258","host_name":"hyd01.com.au","host_alias":"hyd01","name":"NSClient Version","host_display_name":{},"host_address":"172.16.130.23","display_name":"Agent Version","status_update_time":"2019-12-04 15:44:08","status_text":"NSClient++ 0.5.2.35 2018-01-28","status_text_long":{},"current_state":"0","performance_data":{},"should_be_scheduled":"1","check_type":"0","last_state_change":"2019-11-22 19:21:48","last_hard_state_change":"2019-11-22 19:21:48","last_hard_state":"0","last_time_ok":"2019-12-04 15:39:17","last_time_warning":"2019-11-22 19:21:48","last_time_critical":"2019-11-22 19:17:27","last_time_unknown":"1970-01-01 10:00:00","last_notification":"1970-01-01 10:00:00","next_notification":"1970-01-01 10:00:00","no_more_notifications":"0","acknowledgement_type":"0","current_notification_number":"0","process_performance_data":"1","obsess_over_service":"1","event_handler_enabled":"1","modified_service_attributes":"0","event_handler":"NagiosToSNow-Service_General_Version2","check_command":"check-nsclient_version!!!!!!!!","normal_check_interval":"5","retry_check_interval":"1","check_timeperiod_id":"125","icon_image":{},"icon_image_alt":{},"has_been_checked":"1","current_check_attempt":"1","max_check_attempts":"5","last_check":"2019-12-04 15:39:17","next_check":"2019-12-04 15:44:15","state_type":"1","notifications_enabled":"1","problem_acknowledged":"0","flap_detection_enabled":"1","is_flapping":"0","percent_state_change":"0","latency":"0","execution_time":"0.00371","scheduled_downtime_depth":"0","passive_checks_enabled":"1","active_checks_enabled":"1","notes":{},"notes_url":{},"action_url":{}}}
In our nagios console the nsclient status is showing is OK.
In The above red colored where we can see the nsclient status. whether this soft or hard.
Re: Current service status API
Posted: Wed Dec 04, 2019 8:02 am
by scottwilkerson
The current state is here
0 = OK
State Type
0 = SOFT
1 = HARD