I am looking for a way to discover what hosts do not have a specific service assigned.
I have a new service that checks if Windows has a pending reboot that I want most of my Windows servers to have.
I know I can put all of these servers in a host group to force them to get this service but I thought this would be a good idea to double check that all of my hosts have this service.
Any advice on how I can pull this data?
Find Hosts Missing a Service
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Find Hosts Missing a Service
Hello, @REFan, You could probably make a custom query to mysql:
Or you could look into object.cache file. It has all the configs that are being used at the present moment.
Let me know if that helps.
Code: Select all
echo "select * from tbl_host JOIN (tbl_lnkServiceToHost);" | mysql -uroot -pnagiosxi nagiosqlCode: Select all
/usr/local/nagios/var/objects.cacheAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Find Hosts Missing a Service
Cool I was able to look at objects.cache and pull out the members of the host group.
Is there a way to export the hosts that are associated with a service? Looking at that file there isn't one service with all associated hosts.
Is there a way to export the hosts that are associated with a service? Looking at that file there isn't one service with all associated hosts.
-
kyang
Re: Find Hosts Missing a Service
You should be able to grep that objects.cache file.
This should list all the hosts and services
This is an example of where I'm looking for the Ping service in all hosts. (You can change the string "Ping" to whatever service you are looking for under specific hosts.)
Let us know if this works for you.
Code: Select all
grep -1 service_description /usr/local/nagios/var/objects.cache
This is an example of where I'm looking for the Ping service in all hosts. (You can change the string "Ping" to whatever service you are looking for under specific hosts.)
Code: Select all
grep 'Ping' -B 2 /usr/local/nagios/var/objects.cache | grep 'service_description\|host_name'
Re: Find Hosts Missing a Service
Very cool! That does work. I also was able to pull some data from the Reports tab. I was able to export the list of hosts in the host group and create a service group to export hosts that are assigned directly to the service.
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Find Hosts Missing a Service
It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!