Page 2 of 2

Re: SQL/API query to find disabled hosts and services?

Posted: Tue Dec 08, 2020 3:18 am
by ottow
That is just some stuff to clean up the output.
The issue exists even without |tr -d '"' |paste - -

Re: SQL/API query to find disabled hosts and services?

Posted: Tue Dec 08, 2020 8:30 am
by scottwilkerson
ottow wrote:That is just some stuff to clean up the output.
The issue exists even without |tr -d '"' |paste - -
How about if you just look at the json by loading the URL in a browser?

Code: Select all

http://nagiosserver.corp.com/nagiosxi/api/v1/objects/servicestatus?apikey=kQMVOcBoienqejrLrO4klEHPoWrn8ARMmUHq6eRnLv8fRChDGkd0YUPGQAjf6b0M&pretty=1&notifications_enabled=0

Re: SQL/API query to find disabled hosts and services?

Posted: Thu Dec 10, 2020 4:54 am
by ottow
No, that's not going to work for our purposes. However, some more work with jq produced what we need.
Anyone else looking to generate lists of GUI-disabled Host and Service notifications may probably find the below two API queries useful:

curl -XGET -k -L --silent "http://nagiosserver.corp.com/nagiosxi/a ... _enabled=0" | jq -r 'if .recordcount > "1" then .hoststatus[] | .name elif .recordcount == "0" then "" else .hoststatus.name end'

curl -XGET -k -L --silent "http://nagiosserver.corp.com/nagiosxi/a ... _enabled=0" | jq -r 'if .recordcount > "1" then .servicestatus[] | .host_name + " " + .name else .servicestatus.host_name + " " + .servicestatus.name end'

Re: SQL/API query to find disabled hosts and services?

Posted: Thu Dec 10, 2020 8:14 am
by scottwilkerson
ottow wrote:No, that's not going to work for our purposes. However, some more work with jq produced what we need.
Anyone else looking to generate lists of GUI-disabled Host and Service notifications may probably find the below two API queries useful:

curl -XGET -k -L --silent "http://nagiosserver.corp.com/nagiosxi/a ... _enabled=0" | jq -r 'if .recordcount > "1" then .hoststatus[] | .name elif .recordcount == "0" then "" else .hoststatus.name end'

curl -XGET -k -L --silent "http://nagiosserver.corp.com/nagiosxi/a ... _enabled=0" | jq -r 'if .recordcount > "1" then .servicestatus[] | .host_name + " " + .name else .servicestatus.host_name + " " + .servicestatus.name end'
Great, glad to hear you got it working

Locking thread