Exclude Host from Service Check Fails

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Post Reply
employee45193783
Posts: 4
Joined: Wed Nov 17, 2021 2:55 pm

Exclude Host from Service Check Fails

Post 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.
kg2857
Posts: 235
Joined: Wed Apr 12, 2023 5:48 pm

Re: Exclude Host from Service Check Fails

Post 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...
employee45193783
Posts: 4
Joined: Wed Nov 17, 2021 2:55 pm

Re: Exclude Host from Service Check Fails

Post 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.
employee45193783
Posts: 4
Joined: Wed Nov 17, 2021 2:55 pm

Re: Exclude Host from Service Check Fails

Post 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
kg2857
Posts: 235
Joined: Wed Apr 12, 2023 5:48 pm

Re: Exclude Host from Service Check Fails

Post 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?
employee45193783
Posts: 4
Joined: Wed Nov 17, 2021 2:55 pm

Re: Exclude Host from Service Check Fails

Post by employee45193783 »

Thanks. I did end up creating a new hostgroup and added the hostgroup to the specific checks.
SaintOtis12
Posts: 1
Joined: Sun Aug 27, 2023 12:53 am

Re: Exclude Host from Service Check Fails

Post 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
Post Reply