Hi,
I'm looking for a way to list hosts and their services, much like home, service detail, except I want all hosts even if they have no services (service detail excludes host w/o services).
The reason is I use a lot of hostgroups and if a host happens to not be in the correct hostgroups, it may not have any services, which is bad. Something like host detail with services would be ideal. Then I could quickly page through and see hosts, w/ fewer than normal, or no services.
I don't need this to be in the GUI, and I'm happy to grab it by almost any means, SQL, grep, whatever. My system is 2014R2.6 so the new API is out. I grepped on objects.cache but that's going to take a lot of post-processing.
grep -e host_name -e service_description /var/nagiosramdisk/objects.cache
Any suggestions?
Thanks!
List host and their services
Re: List host and their services
Your version is still current enough - the JSON API's are included in Nagios XI 2014R1.2.
You can also use the 'old' Backend API. https://assets.nagios.com/downloads/nag ... nd_API.pdf
If you have the time, here's a good tutorial on the topic from the 2013 conf:
https://www.youtube.com/watch?v=kFJrEdeCqfg
You can also use the 'old' Backend API. https://assets.nagios.com/downloads/nag ... nd_API.pdf
If you have the time, here's a good tutorial on the topic from the 2013 conf:
https://www.youtube.com/watch?v=kFJrEdeCqfg
Be sure to check out the Knowledgebase for helpful articles and solutions!
Re: List host and their services
Personally I think this should be added as a feature...
The list of backend API calls in the admin tab don't address the issue, but from watching Andy's presentation it looks like the ones in the API component are just examples.
My cheesy quick list was made from the below grep, then manually removing the single column lines, leaving host service pairs, and then pulling out the hostnames and counting the services.
grep -e host_name -e service_description /var/nagiosramdisk/objects.cache | sed -e ':a;N;$!ba;s/\n.service_description//g' -e "s/\thost_name\t//g" > /tmp/objects.cache
vi /tmp/objects.cache
awk '{print $1}' /tmp/objects.cache | uniq -c
I could have done that more easily by just grabbing the host_name lines and locating lines w/ " 1 " to list hosts w/ no services.
grep -e host_name /var/nagiosramdisk/objects.cache | sort | uniq -c | grep " 1 " | awk '{print $3}'
The list of backend API calls in the admin tab don't address the issue, but from watching Andy's presentation it looks like the ones in the API component are just examples.
My cheesy quick list was made from the below grep, then manually removing the single column lines, leaving host service pairs, and then pulling out the hostnames and counting the services.
grep -e host_name -e service_description /var/nagiosramdisk/objects.cache | sed -e ':a;N;$!ba;s/\n.service_description//g' -e "s/\thost_name\t//g" > /tmp/objects.cache
vi /tmp/objects.cache
awk '{print $1}' /tmp/objects.cache | uniq -c
I could have done that more easily by just grabbing the host_name lines and locating lines w/ " 1 " to list hosts w/ no services.
grep -e host_name /var/nagiosramdisk/objects.cache | sort | uniq -c | grep " 1 " | awk '{print $3}'
Re: List host and their services
I agree with you, I've created a feature request:
Code: Select all
NEW TASK ID 9230 created - Nagios XI Feature Request: API - Add ability to list hosts and their services (even if they don't have any services)Re: List host and their services
Thanks!
I also find that changing an IP to an invalid value helps to find custom scripts that fail silently--that is even if the host is unreachable, the service stays green. Since I only recently have a lab system, many scripts were created on a live system, where things couldn't be broken to verify good behavior during a failure...
Feel free to close...
I also find that changing an IP to an invalid value helps to find custom scripts that fail silently--that is even if the host is unreachable, the service stays green. Since I only recently have a lab system, many scripts were created on a live system, where things couldn't be broken to verify good behavior during a failure...
Feel free to close...
-
bheden
- Product Development Manager
- Posts: 179
- Joined: Thu Feb 13, 2014 9:50 am
- Location: Nagios Enterprises
Re: List host and their services
In your NDO Utils database (should be db 'nagios'), the following query should give you what you want if I understand correctly (and probably much faster than parsing the objects file):
Code: Select all
SELECT h.display_name as host_name, s.display_name as service_desc FROM nagios_hosts h LEFT JOIN nagios_services s ON h.host_object_id = s.host_object_id;
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Nagios Enterprises
Senior Developer
Nagios Enterprises
Senior Developer