Page 1 of 2

Remove host from hostgroup for one service

Posted: Tue Jul 05, 2016 6:49 pm
by Naveed
Hello,

I have multiple hostsgroup in my nagios xi server.

I have not defined a service for particular server but due to same hostgroup and servicegroup that service is also showing in my server list of services.

If I would removed servicegroup from this service it would be removed for rest of all servers as well which is not required.

Is there any way to remove a single host from servicegroup to avoid such services in my nagios.

Thank you!

Re: Remove host from hostgroup for one service

Posted: Tue Jul 05, 2016 7:13 pm
by Box293
I believe it can be done using a free variable.

There is actually a way to do this in the CCM but it is a hack and does have one caveat I will explain...

You can negate hosts using the free variables settings on the Misc Settings tab.

Add a free variable

Variable Name = host_name
Variable value = !YOUR-HOST.COM,!YOUR-OTHER-HOST.COM


Now for the caveat....

This works perfectly fine if you have a service definition where you are adding hostgroups and want to just exclude a couple hosts. This will fail miserably if you also are adding individual hosts (in addition to hostgroups) because the free variable you set will in fact overwrite the individual hosts you have.


Does this work for you?

Re: Remove host from hostgroup for one service

Posted: Tue Jul 05, 2016 7:29 pm
by Naveed
Can you please explain in more details.

I could not get the idea what you want to suggest.

Thank you!

Re: Remove host from hostgroup for one service

Posted: Tue Jul 05, 2016 7:51 pm
by Box293
The concept is explained on this page under "Excluding Hosts"
https://assets.nagios.com/downloads/nag ... ricks.html

However in XI you need to do it a little differently.
In your service you go to the Misc Settings tab.

Add a free variable
Variable Name = host_name
Variable value = !YOUR-HOST.COM,!YOUR-OTHER-HOST.COM

These are the hosts that you don't want to get the service.

Re: Remove host from hostgroup for one service

Posted: Tue Jul 05, 2016 7:59 pm
by Naveed
Great feature!

I got it now...

My services are defined separated for each host.

define service {
host_name PRODSQL02
service_description Drive E: Disk Usage
use xiwizard_windowsserver_nsclient_service
check_command check_xi_service_nsclient!unOkWqKfxHxf9stX!USEDDISKSPACE!-l E -w 80 -c 95!!!!!
max_check_attempts 5
check_interval 3
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 60
notification_period xi_timeperiod_24x7
notification_options c,s,
notifications_enabled 1
contacts ddax,dutchit,nagiosadmin
_xiwizard windowsserver
register 1
}


Do I need to add attribute in services?

Re: Remove host from hostgroup for one service

Posted: Tue Jul 05, 2016 8:08 pm
by Box293
If you have a separate service for each host then you can simply delete this service, it will not affect other hosts.

I might not be understanding your issue correctly, if that is the case please confirm exactly what is the problem.

Re: Remove host from hostgroup for one service

Posted: Wed Jul 06, 2016 3:11 pm
by Naveed
Alright!

I have checked by all possible means as per my knowledge before raising this issue.

I gona describe my problem in details as below.

I have checked from CLI in config file a service is not defined for a host which is a part of hostgroup.

There is a service which need to monitored for all hosts except of one host, but as it is a part of hostgroup thats why a service is showing in its services

I tried to remove it from CCM, that service does not show in list of services which need to removed.

I tried to remove it from home==>service details but it shows a message you cant remove this service as you do not find any unique id against it.

I rechecked it from CLI in config file but does not defined in file as well...

I just want to remove all unknown services for my host.

Hope so you got the idea what I wanted to say now.

let me know your thoughts please.

Thank you

Re: Remove host from hostgroup for one service

Posted: Wed Jul 06, 2016 3:45 pm
by gormank
You might try going to /usr/local/nagios/etc/services and searching for the hostname:

cd /usr/local/nagios/etc/services
grep -i hostname <service.cfg>

Same for the host /usr/local/nagios/etc/hosts:

cd /usr/local/nagios/etc/hosts
grep -i servicename <hostname.cfg>

You might even look in the hostgroups.cfg for the host and service...

Once you find where the object you want to get rid of is, go back to CCM and remove it.

BTW: by defining separate services for each host, as time goes on your life will get harder and harder. You may want to look into creating one service, one or more hostgroups, and adding the hostgroups to the service. Hosts go in the hostgroups. For hosts and services, I try to remove all info not related to the host or service and put that info in host and service templates.

Re: Remove host from hostgroup for one service

Posted: Wed Jul 06, 2016 4:39 pm
by lmiltchev
@Naveed let us know if gormank's suggestion helped.

Re: Remove host from hostgroup for one service

Posted: Wed Jul 06, 2016 5:21 pm
by Naveed
The given suggestion looks quite solid. I have already solved my issue by checking services for all hosts and added for those, which was missing.
That is why those services in unknown state, they were not defined in my .cfg files and cant find in CCM as well.

Those services were referenced on the basis of hostgroup. I have defined for missing hosts, which solves my problem for now.

Thank you very much everyone for suggestions and help.

Much appreciated.

Thank you