Page 1 of 1

API not returning pretty JSON

Posted: Wed Sep 30, 2020 9:39 am
by hbouma
I am attempting to pull in the hoststatus via API and get hostnames of servers where the active_checks_enabled=0.


I used to be able to run the following:
curl -XGET -k -s https://SERVER/nagiosxi/api/v1/objects/hoststatus?apikey=KEY&active_checks_enabled=0&pretty=1 | grep \"host_name\":

Now, I just get an unformed response for the curl command. Did something change in how Nagios responds to a curl?

Running RHEL 7.8 VM's and Nagios XI 5.7.3

Re: API not returning pretty JSON

Posted: Wed Sep 30, 2020 12:43 pm
by mbellerue
I'm getting the pretty output. Just a quick thing I noticed, though, your command posted here doesn't have quotes around it. When I copied and pasted into my environment, replaced the XI IP and API key, I did get big, ugly output. Can you confirm that the command you're running looks more like this?

Code: Select all

curl -XGET -k -s "https://SERVER/nagiosxi/api/v1/objects/hoststatus?apikey=KEY&active_checks_enabled=0&pretty=1" | grep \"host_name\":

Re: API not returning pretty JSON

Posted: Wed Sep 30, 2020 12:58 pm
by hbouma
Thanks, that worked.