Parents of hostsRequired version: 1.0.36
September 11. 2009
Parents in NagiosWithin a host declaration Nagios allows you to define a list of parent hosts. Nagios assumes then that the host is only reachable if at least one of those parent hosts is reachable. Such a definition could look like this: /etc/nagios/conf.d/hosts.cfg
define host {
use default
host_name dns01
alias DNS Server 1 DMZ
address 10.0.34.18
parents sw01,sw02
}
Parents in check_mkIf you use Check_MK for generating your Nagios host configuration (which is the default and considered by us to be a good idea), then you need Check_MK to create such parent-definitions for you. This can be either done manually in main.mk or - as of version 1.1.7i2 - with an automatic scan. This article describes the manual variant. The definition of parents is done with the configuration list variable parents. As usual, you can use host tags. The list is compatible to datasource_programs. Let's make an example: We assume that you have a DMZ with the hosts www01, dns01 and dns02 and that those host are reached by Nagios via the switch sw01. Without host tags, a valid declaration looks like this: main.mk parents = [ ( "sw01", [ "www01", "dns01", "dns02" ] ) ] If you check the output of check_mk -H then you should see a valid parents definition in your DMZ hosts:
define host {
use check_mk_host
name host_dns01
host_name dns01
alias dns01
parents sw01
host_groups +check_mk
address 10.0.34.18
}
Using host tags can make your life easier. Just define a tag dmz for your DMZ hosts and use that to assign the parents: main.mk all_hosts = [ "sw01", "www01|dmz", "dns01|dmz", "dns02|dmz", ] parents = [ ( "sw01", ["dmz"], ALL_HOSTS ) ] Nagios allows a host to have more than one parent. This can be configured by duplicating the upper line: main.mk parents = [ ( "sw01", ["dmz"], ALL_HOSTS ), ( "sw02", ["dmz"], ALL_HOSTS ), ] Another way would be to simply define sw01,sw02 as the parent. The comma survives the way into the Nagios configuration: main.mk parents = [ ( "sw01,sw02", ["dmz"], ALL_HOSTS ), ] The other way round is also possible: defining multiple rules for the same parent. The following example will assign the host sw01 a parent of both the hosts with the tag dmz and those with the tag san: main.mk parents = [ ( "sw01", ["dmz"], ALL_HOSTS ), ( "sw01", ["san"], ALL_HOSTS ), ] |
| ||||||||||||