Getting Current State from JSON Query
Posted: Thu Mar 08, 2018 7:02 pm
Hi.
This should be an easy and quick one.
I'm using the Core JSON API to get object info.
One of the values that's in status.dat is "current_state" but I don't see that come back in the JSON.
There's a value called "status" but it has a value that does not match the current state.
In the json below, the status = 2 but the current state is "UP" (0).
How do I handle this?
Thanks, Rick
This should be an easy and quick one.
I'm using the Core JSON API to get object info.
One of the values that's in status.dat is "current_state" but I don't see that come back in the JSON.
There's a value called "status" but it has a value that does not match the current state.
In the json below, the status = 2 but the current state is "UP" (0).
How do I handle this?
Code: Select all
{
"format_version": 0,
"result": {
"query_time": 1520553414000,
"cgi": "statusjson.cgi",
"user": "coreapiuser",
"query": "host",
"query_status": "released",
"program_start": 1520355947000,
"last_data_update": 1520553407000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"host": {
"name": "patinfra.sldc.sbc.com",
"plugin_output": "OK - Agent is alive",
"long_plugin_output": "",
"perf_data": "",
"status": 2,
"last_update": 1520553407000,
"has_been_checked": true,
"should_be_scheduled": true,
"current_attempt": 1,
"max_attempts": 1,
"last_check": 1520553406000,
"next_check": 1520553577000,
"check_options": 8,
"check_type": 1,
"last_state_change": 1519545569000,
"last_hard_state_change": 1519545569000,
"last_hard_state": 0,
"last_time_up": 1520553407000,
"last_time_down": 1519545569000,
"last_time_unreachable": 0,
"state_type": 1,
"last_notification": 0,
"next_notification": 0,
"no_more_notifications": false,
"notifications_enabled": true,
"problem_has_been_acknowledged": false,
"acknowledgement_type": 0,
"current_notification_number": 0,
"accept_passive_checks": true,
"event_handler_enabled": true,
"checks_enabled": true,
"flap_detection_enabled": true,
"is_flapping": false,
"percent_state_change": 0,
"latency": 0,
"execution_time": 0,
"scheduled_downtime_depth": 0,
"process_performance_data": true,
"obsess": true
}
}
}