Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We're using nagios to check our ssh server is running. We have the check_ssh group defined for all members of a certain group. We have other services defined for that group as well. Everything is fine. However for 2 of the members of this group, they listen for ssh on a different port. Hence I have to make a new service for them. Which is fine, but then nagios complains that I'm defining the SSH service twice for the same host.

Can I change the original ssh service to include all the members of group A, but exclude hosts X and Y?

share|improve this question
up vote 9 down vote accepted

Use the host_name directive in the service definition with an exclamation before the name of the host. For example:

define service{
        service_description     CPU Stats
        servicegroups   sysres
        use             generic
        hostgroup_name  linux
        host_name       !server1
        check_command   check_iostat
share|improve this answer
define service{
    service_name myservice
    hostgroup_name mygroup
    host_name !dontmonitorthis,!orthis
share|improve this answer

Sorry if this thread is old, but I had resolved this exact problem as @arun had implementing the solution.

I haven't found why exactly yet, nor how to re-enable them, but having regular expressions enabled in my nagios.cfg stopped "!" (host/group negation) working for me.

Once I disabled it (set use_regexp_matching=0 in nagios.cfg), I was able to use them fine.

(nagios 3.3.1, x86_64)

share|improve this answer
Have you ever found out how to use both regexps and host exclusion simultaneously? – Adrian Frühwirth Jul 3 '13 at 9:49
No, sorry Adrian, I got pulled onto another project, but I'd be interested to know if anyone has, or it has been fixed etc – herdingofthecats Jul 4 '13 at 23:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.