Custom macros in host definitions
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.