Monitoring dualstacked service with Icinga

Having monitoring for dualstack connectivity in place helps a lot. Unfortunately in most cases we are running also services we want to offer dualstacked. In the past we just monitored in those cases IPv4 only or created a separate check for the same service on IPv6. This is a bit messy and I was looking for something to check services via IPv4 and IPv6. Digging my most boring search engine doesn't help much here. So I was talking with some people more involved into the core Icinga/Nagios stuff. Seems there is actually the best solution to use check_multi.

As we have the command definition for "check_multi_icinga" already in place, I created a check_smtp_dualstack.cmd for monitoring a dualstacked SMTP service

command[ IPv4 ]        = check_smtp -4 -H "$HOSTADDRESS$"
command[ IPv6 ]        = check_smtp -6 -H "$HOSTADDRESS6$"
state   [ CRITICAL   ] = COUNT(CRITICAL) > 1
state   [ WARNING    ] = COUNT(WARNING) > 0 || COUNT(CRITICAL) > 0
state   [ UNKNOWN    ] = COUNT(UNKNOWN) > 1

A simple SMTP service definition does the trick (don't forget 'address6' in host definition)

define service{
	use                             generic-service         ; Name of service template to use
	host_name                       localhost
	service_description             SMTP
	check_command                   check_multi_icinga!'check_smtp_dualstack.cmd'!'-r 1+2+4+8'
}

Okay .. that looks nice, but only at the first view. Imagining what we are actually running as service checks, it seems we just need for every unique service check a new cmd-file for check_multi as I didn't found a way to generalize the whole stuff yet.

Does anybody know a way to  pass commands for check_multi via service definitions? Something like:

define service{
[...]
	check_command                   check_multi_icinga!'check_general_dualstack.cmd'!'check_smtp -p 666'!'-r 1+2+4+8'
[...]
}