Page 1 of 1

Exclude Host from Service Check Fails

Posted: Wed Jul 12, 2023 1:44 pm
by employee45193783
I'm adding and configuring a couple of new systems and have them in the respective groups. The problem I am having is that I am trying to exclude the host from some of the checks. We don't use any of the escalations host, service or otherwise. From my past experience with managing Nagios and forum posts this should work.


Host A config:

Code: Select all

define host {
  use                              host-notify-is
  host_name                        server-a
  address                          xxx.xxx.xxx.xxx
  hostgroups                       windows,server2019
  check_command                    check-host-alive
  max_check_attempts               10
}

RDP Service config:

Code: Select all

define service {
  use                              notify-is
  hostgroup_name                   windows
  host_name                        !server-a
  service_description              RDP
  max_check_attempts               3
  normal_check_interval            3
  retry_check_interval             1
  check_command                    check_tcp!3389
}

Nagios Configuration Check:

Code: Select all

Nagios Core 4.2.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 09-06-2016
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Could not find any host matching '!'server-a'' (config file '/usr/local/nagios/etc/services/windows.cfg', starting on line 24)
Error: Failed to expand host list '!'ln-veeam-backup01.qa'' for service 'RDP' (/usr/local/nagios/etc/services/windows.cfg:24)
   Error processing object config files!


***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data defintions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.

Re: Exclude Host from Service Check Fails

Posted: Wed Jul 12, 2023 11:27 pm
by kg2857
Where exactly in the docs does it say this is a solution?
The error message says it isn't.
Try commenting or deleting the entire line. Then again you know all of this...

Re: Exclude Host from Service Check Fails

Posted: Fri Jul 14, 2023 11:48 am
by employee45193783
Documentation for excluding a host for Nagios XI can be found and it uses a WebUI, but finding Nagios documentation for excluding a host in Nagios Core doesn't seem to exist. However, searching there are many forum posts similar to these for excluding a host in a service check.

https://serverfault.com/questions/56429 ... -hostgroup
viewtopic.php?t=32843
https://forums.meulie.net/t/exclude-hos ... s-cfg/6269

Like I said, for excluding a host in a service check using/adding a host_name line with ! followed by the host_name of the host has worked in Nagios Core. This is the first time I have had this NOT work.

Re: Exclude Host from Service Check Fails

Posted: Fri Jul 14, 2023 1:23 pm
by employee45193783
Finally found Nagios documentation for using ! to exclude hosts.

Nagios 3
https://assets.nagios.com/downloads/nag ... ricks.html

Nagios 4:
https://assets.nagios.com/downloads/nag ... ricks.html

Re: Exclude Host from Service Check Fails

Posted: Sun Jul 16, 2023 2:37 am
by kg2857
Thanks for the links supporting what you're doing. It seems perfectly valid unless having a single host confuses things.
Maybe try adding the host to a group and excluding the group?

Re: Exclude Host from Service Check Fails

Posted: Mon Jul 17, 2023 3:01 pm
by employee45193783
Thanks. I did end up creating a new hostgroup and added the hostgroup to the specific checks.

Re: Exclude Host from Service Check Fails

Posted: Sun Aug 27, 2023 1:03 am
by SaintOtis12
employee45193783 wrote: Mon Jul 17, 2023 3:01 pm Thanks. I did end up creating a new hostgroup and added the hostgroup to the specific checks.
Hi, I want to join the group
Minesweeper