Page 1 of 1
Find hosts with multiple parents, track changes
Posted: Wed Aug 19, 2020 5:39 am
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
Re: Find hosts with multiple parents, track changes
Posted: Wed Aug 19, 2020 4:15 pm
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.
Re: Find hosts with multiple parents, track changes
Posted: Thu Aug 20, 2020 2:53 am
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.
Re: Find hosts with multiple parents, track changes
Posted: Thu Aug 20, 2020 5:13 pm
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!
Re: Find hosts with multiple parents, track changes
Posted: Fri Aug 21, 2020 6:01 am
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
Re: Find hosts with multiple parents, track changes
Posted: Fri Aug 21, 2020 5:04 pm
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"
Re: Find hosts with multiple parents, track changes
Posted: Mon Aug 24, 2020 3:14 am
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.
Re: Find hosts with multiple parents, track changes
Posted: Mon Aug 24, 2020 8:03 am
by scottwilkerson
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.
Re: Find hosts with multiple parents, track changes
Posted: Mon Aug 24, 2020 8:24 am
by ottow
I see. Thank you for this and you may close this thread.
Re: Find hosts with multiple parents, track changes
Posted: Mon Aug 24, 2020 8:31 am
by scottwilkerson
ottow wrote:I see. Thank you for this and you may close this thread.
Great
Closing thread