API not returning pretty JSON

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

API not returning pretty JSON

Post 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
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: API not returning pretty JSON

Post 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\":
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: API not returning pretty JSON

Post by hbouma »

Thanks, that worked.
Locked