Need Host IP in status.dat file

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
anjali
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Need Host IP in status.dat file

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

Re: Need Host IP in status.dat file

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
anjali
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Need Host IP in status.dat file

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

Re: Need Host IP in status.dat file

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
anjali
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Need Host IP in status.dat file

Post by anjali »

Thanks, it works.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Need Host IP in status.dat file

Post by scottwilkerson »

anjali wrote:Thanks, it works.
Great!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked