Is there a way to exclude specific hosts from a Nagios hostgroup?

47

Solution 1

Haven't yet tried it with hosts, but with hostgroups, prefixing with a ! works. I use this for running a different load check on busy servers:

define host {
    use         physical-host
    host_name   busy-host.example.com
    alias       busy-host.example.com
    address     10.43.16.1
    hostgroups  linux,centos,ldap,http,busy
}

define host {
    use           physical-host
    host_name     normal-host.example.com
    alias         narmal-host.example.com
    address       10.43.1.1
    hostgroups    linux,centos,dns,proxy,ldap,hp,http,puppetmaster
}

define service {
    use                   generic-service
    hostgroup_name        linux,!busy
    service_description   Load
    check_command         check_snmp_load
}

define service {
    use                   generic-service
    hostgroup_name        busy
    service_description   Load
    check_command         check_snmp_load_busy
}

Solution 2

Add the specific host with a ! prefix in the service definition. The service check below will apply to all hosts in agroup apart from ahost.

define service {
    hostgroup_name   agroup
    host_name       !ahost   
    service_description Shared NFS mount
    check_command check_nrpe!check_shared_mount
    use generic-service

}

Solution 3

You can create one or more hostgroup(s) for excluding things - add it/them to hosts where you want to exclude one or more checks - naming it something like ~no-ipv6 or ~no-ssl or whatever makes it pretty obvious what it's meant to do.

Apply the exclude hostgroup to the host(s) you want to exclude in addition to the normal one(s) it's a member of.

In the Service description, where the hostgroup name(s) that have that service applied are defined, use an ! (in this context, meaning "not") to exclude them.

So if you have a hostgroup "webservers", where some hosts can't do ssl, you might create another hostgroup "~no-ssl". In the services.cfg file, on the service definition that checks https, under hostgroup name, you would put webservers,!~no-ssl

The effect of this would be that all hosts in the hostgroup webservers are checked against SSL - but those that are also in hostgroup ~no-ssl won't have SSL checked. Handy!

If there are some checks you want ALL hosts to undergo, aside from a few, you can use *,!~exclusion

This abstraction is tremendously useful; even more so is using templates to assign (or exclude) a whole bunch of services to a type of host (which then means you can use the hostgroups definitions on each host simply for "extra" additional checks you want to run, or specific exclusions - i.e. template is the "norm", hostgroups are the exception(s)).

Share:
47

Related videos on Youtube

Zzub
Author by

Zzub

Updated on September 18, 2022

Comments

  • Zzub
    Zzub over 1 year

    [Assuming there is a one to many relationship between an individual and an address, and assuming there is a one to many relationship between an agency and an address.]

    Given the following table structure:

    enter image description here

    Wouldn't you want to merge the two address tables together and instead of using a foreign key within each one use a tie table? Like this: enter image description here

    Are they both valid for normalization or only one?

    • Gordon Linoff
      Gordon Linoff almost 5 years
      . . Business addresses may not be the same as individual addresses, from things like "Suite" to "c/o". If you are storing standardized addresses then there is a stronger argument for keeping them in a single table -- for instance, to run NCOA on them.
    • Andrew
      Andrew almost 5 years
      My standard approach to normalization questions is to ask 1) Which approach is easier for storing the data; 2) Which approach is easier for using the data; 3) Which of those two trumps the other. You can't just look at normalization in a vacuum.
    • philipxy
      philipxy almost 5 years
      Please use text, not images/links, for text--including tables & ERDs. Paraphrase or quote from other text. Use images only for what cannot be expressed as text or to augment text. Images cannot be searched for or cut & pasted. Include a legend/key & explanation with an image.
    • philipxy
      philipxy almost 5 years
      Whether a table is in a NF is independent of other tables. Normalization to higher NFs replaces a table by projections of it that natural join to it. That is based on FDs & JDs. A NF is a condition that a table satisfies or doesn't, and we say it is in that NF or isn't. "break data normalization?" & "valid for normalization" don't make sense. There is no normalization in this post. So: Explain as much as you can without using that word. If possible, ask your question. If you think you have to use that word, give your reference/textbook & connect what it says re normalization to what you wrote.
    • philipxy
      philipxy almost 5 years
      You have fk_address_id columns but Address has no id to be referenced. You are not clear about cardinalities: "one to many relationship between [from?] an individual/agency and [to?] an address" seems like it's trying to say that an individual/agency has multiple addresses but only one individual/agency is at an address. What are you trying to say? Do you mean 1:many for address:individual/agency? Can there be individual/agency without addresses & addresses without individual/agency? (The diagrams contribute no associated cardinalities.)
  • user230910
    user230910 over 6 years
    is it possible to achive this in the host file instead of where the service is defined?