mirror of https://github.com/Icinga/icinga2.git
pass nwc_health check SNMPv3 args only if needed (#9095)
* pass nwc_health check SNMPv3 args only if needed
check_nwc_health fails if any of the SNMPv3 arguments were passed but
the SNMP version 3 protocol was not requested.
For instance the following works:
check_nwc_health --hostname 192.0.2.3 --mode cpu-load \
--protocol 1 --community public
While the following plugin invocation results in an error:
check_nwc_health --hostname 192.0.2.3 --mode cpu-load \
--protocol 1 --community public \
--username joe --authpassword xxx
The superfluous SNMPv3 arguments may easily get inherited e.g. from host
templates.
* string()ify the result of macro() calls
Always convert results of macro("$nwc_health_protocol$") to strings
so both numbers and strings are correctly recognized.
* Revert "string()ify the result of macro() calls"
This reverts commit 3636b5b4ba
.
Wrong method applied to the result of macro().
* string()ify the result of macro() calls
Always convert results of macro("$nwc_health_protocol$") in the
set_if clauses of the nwc_health command arguments to strings.
Both numbers and strings are then correctly recognized as the
nwc_health_protocol argument.
* string()ify the result of macro() calls
Always convert results of macro("$nwc_health_protocol$") in the
set_if clauses of the nwc_health command arguments to strings.
Both numbers and strings are then correctly recognized as the
nwc_health_protocol argument.
This commit is contained in:
parent
31c564182a
commit
e05128fa3c
|
@ -525,22 +525,27 @@ object CheckCommand "nwc_health" {
|
|||
"--username" = {
|
||||
value = "$nwc_health_username$"
|
||||
description = "The securityName for the USM security model (SNMPv3 only)"
|
||||
set_if = {{ string(macro("$nwc_health_protocol$")) == "3" }}
|
||||
}
|
||||
"--authpassword" = {
|
||||
value = "$nwc_health_authpassword$"
|
||||
description = "The authentication password for SNMPv3"
|
||||
set_if = {{ string(macro("$nwc_health_protocol$")) == "3" }}
|
||||
}
|
||||
"--authprotocol" = {
|
||||
value = "$nwc_health_authprotocol$"
|
||||
description = "The authentication protocol for SNMPv3 (md5|sha)"
|
||||
set_if = {{ string(macro("$nwc_health_protocol$")) == "3" }}
|
||||
}
|
||||
"--privpassword" = {
|
||||
value = "$nwc_health_privpassword$"
|
||||
description = "The password for authPriv security level"
|
||||
set_if = {{ string(macro("$nwc_health_protocol$")) == "3" }}
|
||||
}
|
||||
"--privprotocol" = {
|
||||
value = "$nwc_health_privprotocol$"
|
||||
description = "The private protocol for SNMPv3 (des|aes|aes128|3des|3desde)"
|
||||
set_if = {{ string(macro("$nwc_health_protocol$")) == "3" }}
|
||||
}
|
||||
"--contextengineid" = {
|
||||
value = "$nwc_health_contextengineid$"
|
||||
|
|
Loading…
Reference in New Issue