Page 1 of 1

Need Host IP in status.dat file

Posted: Thu Aug 08, 2019 8:11 am
by anjali
Hello Team,
I am reading data from status.dat file by converting it to JSON file and render that data in separate UI. Now I need Host IP but I am not getting that in status.dat file, so can you help me in that?

Re: Need Host IP in status.dat file

Posted: Thu Aug 08, 2019 8:42 am
by scottwilkerson
This isn't in the status.dat

I would recommend using the JSON query API

Code: Select all

/nagios/jsonquery.html
select OBJECT JSON API
select hostlist
select True for "Show Details"

This will give you a URL like this

Code: Select all

http://YOUR_NAGIOS_HOST/nagios/cgi-bin/objectjson.cgi?query=hostlist&details=true
Then the address field for each host has what you are looking for

Re: Need Host IP in status.dat file

Posted: Thu Aug 08, 2019 8:59 am
by anjali
Thanks, it works.
But I need to call that URL from my PHP script. When I am calling it gives an unauthorized error. So pls help me in that

Re: Need Host IP in status.dat file

Posted: Thu Aug 08, 2019 9:50 am
by scottwilkerson
anjali wrote:Thanks, it works.
But I need to call that URL from my PHP script. When I am calling it gives an unauthorized error. So pls help me in that
You would need to add your credentials to the call in your PHP script.

On some systems you may be able to do this by changing the URL to

Code: Select all

http://USERNAME:PASSWORD@YOUR_NAGIOS_HOST/nagios/cgi-bin/objectjson.cgi?query=hostlist&details=true

Re: Need Host IP in status.dat file

Posted: Fri Aug 09, 2019 12:53 am
by anjali
Thanks, it works.

Re: Need Host IP in status.dat file

Posted: Fri Aug 09, 2019 6:53 am
by scottwilkerson
anjali wrote:Thanks, it works.
Great!

Locking thread