We have quite a few custom properties in our checks, which makes it really useful to write declarative checks like this:
define server {
use fs-check
host_name foo
description fs /mnt/test
_fs /mnt/test
_crit 10
_warn 15
}
But I've noticed a small problem for us: when I now include $_SERVICEFS$ in my perfdata template (which is global for all checks) the expanded value becomes $_SERVICEFS$ as well, which means in the following infrastructure processing the performance data I need to actively ignore this value, while an empty value would be ignored automatically. However the expanded string now also contains a literal $_SERVICEFS which is a valid shell variable.
For many of our checks I've worked around this by setting the custom variables to an empty in one of the templates early in the chain, but I do not want to add a custom variable to service definitions which have no point in having that variable (think a URL variable in a filesystem check and vice versa). This is further complicated by Thruk displaying a custom variable if it is defined, no matter if they have an empty string as the value or an actual value like /mnt/test above.
I'd much rather prefer, if nagios would expand custom variables to an empty string, instead of keeping the unexpanded text. This should be fairly easy, since nagios already tries to match the text following _HOST and _SERVICE to the custom variables, so it is aware that the macro currently being expanded is for a custom variable (grab_custom_object_macro_r() in macros.c), so if a variable of that name would be present it would be replaced, but without the value present we fall back to the behaviour that all macros share - not replacing the macro at all.
We have quite a few custom properties in our checks, which makes it really useful to write declarative checks like this:
But I've noticed a small problem for us: when I now include
$_SERVICEFS$
in my perfdata template (which is global for all checks) the expanded value becomes$_SERVICEFS$
as well, which means in the following infrastructure processing the performance data I need to actively ignore this value, while an empty value would be ignored automatically. However the expanded string now also contains a literal$_SERVICEFS
which is a valid shell variable.For many of our checks I've worked around this by setting the custom variables to an empty in one of the templates early in the chain, but I do not want to add a custom variable to service definitions which have no point in having that variable (think a URL variable in a filesystem check and vice versa). This is further complicated by Thruk displaying a custom variable if it is defined, no matter if they have an empty string as the value or an actual value like
/mnt/test
above.I'd much rather prefer, if nagios would expand custom variables to an empty string, instead of keeping the unexpanded text. This should be fairly easy, since nagios already tries to match the text following
_HOST
and_SERVICE
to the custom variables, so it is aware that the macro currently being expanded is for a custom variable (grab_custom_object_macro_r()
in macros.c), so if a variable of that name would be present it would be replaced, but without the value present we fall back to the behaviour that all macros share - not replacing the macro at all.We btw currently run this in production: