Hi,
I’m stuck trying to configure a command with multiple identical arguments. I try to create the following command w/ the director (ok, actually I want to leave out the --name A2
to check the whole switch).
# sudo -u nagios ./check_nwc_health --community public --mode interface-health --hostname 192.168.28.150 --warningx '.*broadcast_(in|out)'=90 --criticalx '.*broadcast_(in|out)'=95 --warningx '.*broadcast_usage_(in|out)'=1 --criticalx '.*broadcast_usage_(in|out)'=2 --name A2
OK - (OK)A2 is up/up, (OK)interface A2 usage is in:2.95% (29478392.00bit/s) out:7.27% (72702026.00bit/s), (OK)interface A2 errors in:0.00% out:0.00% , (OK)interface A2 discards in:0.00% out:0.00% , (OK)interface A2 broadcast in:0.00% out:0.44% (% of traffic) in:0.00% out:0.01% (% of bandwidth) | 'A2_usage_in'=2.95%;80;90;0;100 'A2_usage_out'=7.27%;80;90;0;100 'A2_traffic_in'=29478392;800000000;900000000;0;1000000000 'A2_traffic_out'=72702026;800000000;900000000;0;1000000000 'A2_errors_in'=0%;1;10;0;100 'A2_errors_out'=0%;1;10;0;100 'A2_discards_in'=0%;5;10;0;100 'A2_discards_out'=0%;5;10;0;100 'A2_broadcast_in'=0%;90;95;0;100 'A2_broadcast_out'=0.44%;90;95;0;100 'A2_broadcast_usage_in'=0%;1;2;0;100 'A2_broadcast_usage_out'=0.01%;1;2;0;100
As you can see my individual thresholds are recognized (e.g. last perfdata)
I learned toying around w/ the director, that I can put e.g. --criticalx '.*broadcast_usage_(in|out)'=2
directly into the arguments section (and did that successfully*).
Unfortunately I need multiple --warningx
and --criticalx
, since (as you can see above) I need to adjust multiple thresholds, which seems not possible at the arguments section (at least during my tries a new argument of the same name overwrites the previous one).
From [FeatureRequest: Allow array in arguments for CheckCommand objects · Issue #7326 · Icinga/icinga2 · GitHub] I learned that one can use custom-vars to accomplish this. Now my command looks imo pretty much like the examples from that link:
object CheckCommand "check_nwc_if_health" {
import "plugin-check-command"
import "nwc_health"
arguments += {
"--community" = "public"
"--criticalx" = {
repeat_key = true
value = "$vars.nwccta$"
}
"--mode" = "interface-health"
"--warningx" = {
repeat_key = true
value = "$vars.nwcwta$"
}
}
vars.nwccta = [ "'.*broadcast_(in|out)'=95", "'.*broadcast_usage.*'=2" ]
vars.nwcwta = [ "'.*broadcast_(in|out)'=90", "'.*broadcast_usage.*'=1" ]
But unfortunately the perfdata-section in the GUI shows the default values (w10/c20). When I tried putting the threshold into the argument section see * above, they were shown as I expected.
(I tried removing/adding the single quotes already).
Unfortunately the command isn’t completely displayed in the debug log: notice/Process: Running command '/usr/lib/nagios/plugins/check_nwc_health' '--community' 'public' '--hostname' '192.168.28.151' '--mode' 'interface-health': PID 786229
(Can I increase log level?)
Any hints? What am I missing?
Daniel