Find hosts with multiple parents, track changes

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

Find hosts with multiple parents, track changes

Post by ottow »

Hi,

What would be the recommended way to locate hosts with multiple parents set?
SQL query, or is there perhaps a report?

Also, is there a report (or SQL query) we can run that shows recent configuration changes (last 24h)?
With several admins making changes, it would be very useful to be able to see this.

Thanks,

Otto
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Find hosts with multiple parents, track changes

Post by benjaminsmith »

Hi @ottow,

You can use the API to retrieve this information. For example, the following API command will return the the configuration stored in the database for a host.

Code: Select all

curl -XGET "https://192.168.23.112/nagiosxi/api/v1/config/host?apikey=<theapikey>&host_name=localhost&pretty=1" 
It will return json data. You can view documentation and sample commands by going to Help > API Docs > Config Reference.
{
"host_name": "localhost",
"use": [
"linux-server"
],
"alias": "localhost",
"address": "127.0.0.1",
"parents": [
"192.168.23.140",
"192.168.23.142"
],
"register": "1"
}
The audit log will provide information about changes made in the Core Configuration Manager. Go to Admin > System Information > Audit Log. We have made quite a few improvements to this log, so if you're running an old version it may not be as detailed.

Let me know if you have more questions.
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!
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

Re: Find hosts with multiple parents, track changes

Post by ottow »

Hi,

The API call will return the data for 1 host, which is not what I am looking for.
I want to list all hosts in the system with multiple parents, presumably this needs a SQL query which I would like assistance formulating.

I'll look into the Audit Log, thanks for the info.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Find hosts with multiple parents, track changes

Post by ssax »

What he recommended should work.

You can do this:
- Change YOURXISERVER and YOURAPIKEY

Code: Select all

yum install jq -y
curl -XGET -k -L --silent "http://YOURXISERVER/nagiosxi/api/v1/config/host?apikey=YOURAPIKEY&pretty=1" -k -L | jq -r '.[] | .host_name, .parents'
Or go here and look (or copy paste into excel):

Code: Select all

http://YOURXISERVER/nagios/cgi-bin/config.cgi?type=hosts
Thank you!
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

Re: Find hosts with multiple parents, track changes

Post by ottow »

The above just produces an error:
jq: error: Cannot index string with string
jq: error: Cannot index string with string

Can I please have a SQL query instead
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Find hosts with multiple parents, track changes

Post by ssax »

Please PM the output of this command to make sure it works first:

Code: Select all

curl -XGET -k -L --silent -vvv "http://YOURXISERVER/nagiosxi/api/v1/config/host?apikey=YOURAPIKEY&pretty=1"
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

Re: Find hosts with multiple parents, track changes

Post by ottow »

API access had been disabled for some reason for the user I was testing with.
This works now, but is still less convenient and much less readable than a SQL query output.
Ref https://support.nagios.com/forum/viewto ... 16&t=59669 for what I am looking for.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Find hosts with multiple parents, track changes

Post by scottwilkerson »

ottow wrote:API access had been disabled for some reason for the user I was testing with.
This works now, but is still less convenient and much less readable than a SQL query output.
Ref https://support.nagios.com/forum/viewto ... 16&t=59669 for what I am looking for.
I can understand that is is less convenient, but as the author of the other comment, I want to chime in that not all items can be referenced from a single query like I posted in the other thread.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
ottow
Posts: 44
Joined: Wed Nov 15, 2017 3:45 am

Re: Find hosts with multiple parents, track changes

Post by ottow »

I see. Thank you for this and you may close this thread.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Find hosts with multiple parents, track changes

Post by scottwilkerson »

ottow wrote:I see. Thank you for this and you may close this thread.
Great
Closing thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked