Find Hosts Missing a Service

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
REFan
Posts: 31
Joined: Tue Aug 15, 2017 10:18 am

Find Hosts Missing a Service

Post by REFan »

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?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Find Hosts Missing a Service

Post by npolovenko »

Hello, @REFan, You could probably make a custom query to mysql:

Code: Select all

echo "select * from tbl_host JOIN (tbl_lnkServiceToHost);" | mysql -uroot -pnagiosxi nagiosql
Or you could look into object.cache file. It has all the configs that are being used at the present moment.

Code: Select all

/usr/local/nagios/var/objects.cache
Let me know if that helps.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
REFan
Posts: 31
Joined: Tue Aug 15, 2017 10:18 am

Re: Find Hosts Missing a Service

Post by REFan »

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.
kyang

Re: Find Hosts Missing a Service

Post by kyang »

You should be able to grep that objects.cache file.

Code: Select all

grep -1 service_description /usr/local/nagios/var/objects.cache
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.)

Code: Select all

grep 'Ping' -B 2 /usr/local/nagios/var/objects.cache | grep 'service_description\|host_name'
Let us know if this works for you.
REFan
Posts: 31
Joined: Tue Aug 15, 2017 10:18 am

Re: Find Hosts Missing a Service

Post by REFan »

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

Post by dwhitfield »

It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
Locked