The usual IT babble
Posts tagged Nagios 3
Custom macros in host definitions
Aug 16th
Well, I was playing with the hostgroup inheritance earlier. One problem with that is, if you define a duplicate service Nagios is really unpredictable or rather inconsistent. Now, as Thomas Guyot-Sionnest told me, I should try custom macros for the check definition. So what I did was the following:
templates/host-windows.cfg
1 2 3 4 5 | define host {
name generic-windows
register 0
_RDPPORT 3389
} |
hostgroups/windows.cfg
1 2 3 4 5 6 7 8 9 10 11 12 | define hostgroup {
hostgroup_name windows
alias Windows Servers
hostgroup_members windows-terminal
}
define service {
use generic-service
check_command check_tcp!$_HOSTRDPPORT$
service_description RDP
hostgroup_name windows
} |
hosts/terminal1.cfg
1 2 3 4 5 6 7 8 9 | define host {
use generic-windows
host_name terminal1
alias terminal1.barfoo.org
address 10.0.0.250
parents barfoo-home
hostgroups windows-terminal
_RDPPORT 3390
} |
As you can see, the default RDP port is 3389 (as defined in the host template), but for some systems you might want to “change” the port (for example, if you’re having a citrix farm and you changed the RDP port to something else and still want to be able to check whether or not the RDP service is active), thus the check using the macro, and a single host redefining the macro, thus having a bit more flexibility.
Nagios 3 and hostgroup inheritance
Aug 8th
As I wrote some time ago, I was trying to utilize Nagios 3.x’s neat feature of “nested” hostgroups. Well, as it turned out I thought it worked differently; basically like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | define hostgroup {
hostgroup_name a-parent-hostgroup
alias Our toplevel parent hostgroup
}
define service {
use generic-service
check_command check_dummy!0!
service_description SSH
hostgroup_name a-parent-hostgroup
}
define hostgroup {
hostgroup_name a-child-hostgroup
hostgroup_members a-parent-hostgroup
alias Our child hostgroup
}
define service {
use generic-service
check_command check_dummy!0!
service_description LOAD
hostgroup_name a-child-hostgroup
} |
As you can cleary see on line 14, I thought you define the relation between two hostgroups in the child hostgroup. The problem with it was basically (as I said in the earlier posts), that all the services defined for the child hostgroups are handed on upwards to the parent hostgroup(s).
But after talking to Tobi, I quickly found out, that the relation is in fact defined within the parent hostgroup. So if you simply put hostgroup_members within the parent hostgroup and define all child hostgroups which should inherit from the parent one, you should be just fine.