That is just some stuff to clean up the output.
The issue exists even without |tr -d '"' |paste - -
SQL/API query to find disabled hosts and services?
-
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?
How about if you just look at the json by loading the URL in a browser?ottow wrote:That is just some stuff to clean up the output.
The issue exists even without |tr -d '"' |paste - -
Code: Select all
http://nagiosserver.corp.com/nagiosxi/api/v1/objects/servicestatus?apikey=kQMVOcBoienqejrLrO4klEHPoWrn8ARMmUHq6eRnLv8fRChDGkd0YUPGQAjf6b0M&pretty=1¬ifications_enabled=0Re: SQL/API query to find disabled hosts and services?
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'
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?
Great, glad to hear you got it workingottow 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'
Locking thread