Apparently the variable with the default parameter is not being passed through.
What’s even stranger is that the same setup works for other checkcommands.
I have no clue what’s different here.
How do I go about debugging this problem?
Thanks for any hints!
Andy
Hello Andy,
You are receiving this error because the check command argument “required” field is set to “true” for the critical and warning argument. Set the required field to false to get past this error.
True, but - no matter whether required set to true or false - the command option is not being used.
Somehow Icinga doesn’t see the default value which I set.
then the variables get passed through as they should. So it must have to do with the by_ssh-template.
I thought this line takes care of this in the by_ssh-template: vars.by_ssh_arguments = {{ get_check_command(service.vars.original_check_command).arguments }}
template Service "ssh-service" {
import "generic-service"
// "save" original command name, and replace it
vars.original_check_command = check_command
check_command = "by_ssh"
vars.by_ssh_port = "5522"
vars.by_ssh_quiet = 1
vars.by_ssh_timeout = 90
// these get evaluated at runtime
vars.by_ssh_command = {{ get_check_command(service.vars.original_check_command).command }}
vars.by_ssh_arguments = {{ get_check_command(service.vars.original_check_command).arguments }}
// for integration with graphite
// https://github.com/Icinga/icingaweb2-module-graphite/blob/master/doc/03-Configuration.md
// To make the respective graphs work as expected
// you have to tell the monitored object's "actual" check command
// by setting its custom variable "check_command"
vars.check_command = vars.original_check_command
}
i changed the check command arguments = to arguments += and added vars.uptime1_perfdata = true to your service. The trick only handles variables that are defined in the service and not if they are defined in the command.
Yes, but I want to avoid having to set all default values again.
If you don’t add that line, does the service pick up the default value from the command definition and thus add the “–perfparse” parameter?
Oh, too bad. But in other commands it works.
I have the feeling it only works if I use it within a “for” loop.
Here’s an example:
object CheckCommand "lm-sensors" {
command = [ PluginLocalDir + "/check_lm_sensors" ]
arguments = {
"--nodrives" = {
set_if = "$lm_sensors_nodrives$"
}
"--sanitize" = {
set_if = "$lm_sensors_sanitize$"
}
"--high" = {
value = "$lm_sensors_high$"
description = "specifies a check for a sensor value which is too high"
}
"--low" = {
value = "$lm_sensors_low$"
description = "specifies a check for a sensor value which is too low"
}
"--range" = {
value = "$lm_sensors_range$"
description = "specifies a check for a sensor value which should stay in a given range"
}
}
vars.lm_sensors_nodrives = true
vars.lm_sensors_sanitize = true
vars.lm_sensors_high = "Core0=60,90"
}
And the service:
apply Service for (lmsensor => config in host.vars.lmsensors) {
check_command = "lm-sensors"
import "ssh-service"
vars += config
}
Why does it pick up the default values in this case?
the += adds/merges all variables under the variable arguments or vars and does not complete overwrite the arguments or vars. For example if you have a command that imports another command and adds only 1 argument. If you write arguments = ... all the arguments from the import are gone and only the one you defined in the new command is there. If you use arguments += the variables from arguments are merged.
Why it works in a foor loop you have to ask the developers, maybe @theFeu can get the information from one.
Carsten wrote above: “Why it works in a foor loop you have to ask the developers”
I still did not find a solution to that. Could you point me in the right direction please?
Thanks, Andy
PS: And I still haven’t found out how to use log() in the service/command configuration. Help!
Thanks. Wow, that’s pretty complicated.
No wonder, I didn’t find any usage examples. Thank you!
Okay, now I see "[2020-07-11 00:12:24 +0200] information/config: " in my icinga2.log
This means that the variable “uptime1_perfdata” is actually “false”
although the CheckCommand defines a default value (see above).
I’m starting to believe I’ve found a bug. What do you think?