Need Host IP in status.dat file

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Need Host IP in status.dat file

Postby anjali » Thu Aug 08, 2019 8:11 am

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?
anjali
 
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Need Host IP in status.dat file

Postby scottwilkerson » Thu Aug 08, 2019 8:42 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Need Host IP in status.dat file

Postby anjali » Thu Aug 08, 2019 8:59 am

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
anjali
 
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Need Host IP in status.dat file

Postby scottwilkerson » Thu Aug 08, 2019 9:50 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Need Host IP in status.dat file

Postby anjali » Fri Aug 09, 2019 12:53 am

Thanks, it works.
anjali
 
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Need Host IP in status.dat file

Postby scottwilkerson » Fri Aug 09, 2019 6:53 am

anjali wrote:Thanks, it works.

Great!

Locking thread
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: Bing [Bot] and 9 guests