Hi ,
I am using the json query generator to export some nagios data to an external reporting system. Inserted is the output from a query, I am just wondering how to translate the state field? its not in the 0,1,2,3 or 4 that I was expecting. I'm assuming object_type of 2 is for service and state_type of 1 is for hard
{
"format_version": 0,
"result": {
"query_time": 1490384843000,
"cgi": "archivejson.cgi",
"user": "nagiosadmin",
"query": "statechangelist",
"query_status": "released",
"program_start": 1490375704000,
"last_data_update": 1488783193000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"starttime": 1488672000000,
"endtime": 1488758400000,
"hostname": "Service Availability",
"servicedescription": "ITSM",
"statetypes": 1
},
"statechangelist": [
{
"timestamp": 1488672000000,
"object_type": 2,
"host_name": "Service Availability",
"description": "ITSM",
"state_type": 1,
"state": 8,
"plugin_output": "Initial Service Pseudo-State"
},
{
"timestamp": 1488697200000,
"object_type": 2,
"host_name": "Service Availability",
"description": "ITSM",
"state_type": 1,
"state": 8,
"plugin_output": "OK - 2 plugins checked, 2 ok"
},
{
"timestamp": 1488740269000,
"object_type": 2,
"host_name": "Service Availability",
"description": "ITSM",
"state_type": 1,
"state": 32,
"plugin_output": "CRITICAL - 2 plugins checked, 1 critical (login_www_itsmprd_Service_Availability_-_itsm_selenium_login), 1 ok"
},
{
"timestamp": 1488740564000,
"object_type": 2,
"host_name": "Service Availability",
"description": "ITSM",
"state_type": 1,
"state": 8,
"plugin_output": "OK - 2 plugins checked, 2 ok"
}
]
}
}
question about about output from jsonquery.html
-
bheden
- Product Development Manager
- Posts: 179
- Joined: Thu Feb 13, 2014 9:50 am
- Location: Nagios Enterprises
Re: question about about output from jsonquery.html
You're asking about Core stuff on an XI forum
But I was perusing and thought I'd share:
In the core source, in include/archiveutils.h, you have the following:
Where here, 8 would be service ok (1<<3).
Following all those bit shift operations: host up is 1, host down is 2, host unreachable is 4, service ok is 8, service warning is 16, service critical is 32, service unknown is 64.
The 0,1,2,3 you're expecting would likely be better coming from the XI API.
Hope this helps.
In the core source, in include/archiveutils.h, you have the following:
Code: Select all
#define AU_STATE_NO_DATA 0
#define AU_STATE_HOST_UP (1<<0)
#define AU_STATE_HOST_DOWN (1<<1)
#define AU_STATE_HOST_UNREACHABLE (1<<2)
#define AU_STATE_SERVICE_OK (1<<3)
#define AU_STATE_SERVICE_WARNING (1<<4)
#define AU_STATE_SERVICE_CRITICAL (1<<5)
#define AU_STATE_SERVICE_UNKNOWN (1<<6)Following all those bit shift operations: host up is 1, host down is 2, host unreachable is 4, service ok is 8, service warning is 16, service critical is 32, service unknown is 64.
The 0,1,2,3 you're expecting would likely be better coming from the XI API.
Hope this helps.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Nagios Enterprises
Senior Developer
Nagios Enterprises
Senior Developer
Re: question about about output from jsonquery.html
excellent thankyou for your help.
I will know for next time to post in core.
I will know for next time to post in core.
Re: question about about output from jsonquery.html
Hi Paul, were there any further questions or are we okay closing this thread?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: question about about output from jsonquery.html
That answered it thanks, yes please close