SQL/API query to find disabled hosts and services?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

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

Post by ottow »

That is just some stuff to clean up the output.
The issue exists even without |tr -d '"' |paste - -
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

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

Post 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'
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked