Closed plastikat closed 2 years ago
As far as I understand, the current arguments parsing logic in Icinga2 always puts a space between an option and its value.
That is correct. It should be possible to work around this with the help of skip_key and macros, but there is no icinga functionality that makes it easier. Which is why I took the liberty of expanding the scope of your issue.
@Crunsher I would keep this workaround hidden in the ITL, and not bloat up the process class here. I'm strongly against changing this.
Hello @plastikat and thank you for reporting!
Please tell whether this fits your need:
Best, AK
@Al2Klimov, thank you for the refinement, it looks good to me!
Please let me know if any further action is expected on my side.
This is also true for at least all check-plugins that work with python's argparse library. Example is this executable python script called negative-option-value.py
(doesn't matter if you use Python 2 or Python 3):
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-w', '--warning', dest='WARN')
args = parser.parse_args()
print(args)
Suppose we want to test for a Nagios-range that contains negative values. This works:
$ ./negative-option-value.py --warning=-60:10
Namespace(WARN='-60:10')
Pay attention to the equal sign between option and value. It is needed because the following variant does not work:
$ ./negative-option-value.py --warning -60:10
negative-option-value.py: error: argument -w/--warning: expected one argument
The possibility to specify parameter separators other than spaces for the check execution would be more than helpful.
Generally the --parameter=value
style of options will be more robust against any wildcard expansion. This now also has impact on Windows if running Python checks compiled with Nuitka/MinGW64 with cmd.exe (see https://github.com/Nuitka/Nuitka/issues/1370 for details).
ref/IP/38043
apt
command definition initl/command-plugins.conf
is currently half-broken. This is because thecheck_apt
plugin seems to have a unique arguments parsing logic. For example--upgrade
option requires an equals sign (and no spaces) between the option and its value. And even if you use a short variant-d
it again requires no spaces between an option and its value. Just try to runcheck_apt
directly specifying "-o 'Debug::NoLocking=true' -s -qq" (which is the default) as the value for the options mentioned above. The same applies to--dist-upgrade
option. At the same time--include
,--exclude
and--critical
seem to work without an equals sign.Possible Solution
As far as I understand, the current arguments parsing logic in Icinga2 always puts a space between an option and its value. One way to solve it could probably be to join these without any delimiter and put the necessary delimiter inside option name - but this would require the change in all commands definitions...
Your Environment
icinga2 --version
): icinga2 - The Icinga 2 network monitoring daemon (version: r2.8.4-1)Copyright (c) 2012-2017 Icinga Development Team (https://www.icinga.com/) License GPLv2+: GNU GPL version 2 or later http://gnu.org/licenses/gpl2.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Application information: Installation root: /usr Sysconf directory: /etc Run directory: /run Local state directory: /var Package data directory: /usr/share/icinga2 State path: /var/lib/icinga2/icinga2.state Modified attributes path: /var/lib/icinga2/modified-attributes.conf Objects path: /var/cache/icinga2/icinga2.debug Vars path: /var/cache/icinga2/icinga2.vars PID path: /run/icinga2/icinga2.pid
System information: Platform: Ubuntu Platform version: 16.04.4 LTS (Xenial Xerus) Kernel: Linux Kernel version: 4.4.0-122-generic Architecture: x86_64
Build information: Compiler: GNU 5.3.1 Build host: 9c880c2f42f5
Operating System and version: Ubuntu 16.04.4 LTS
Enabled features (
icinga2 feature list
): Disabled features: compatlog debuglog elasticsearch gelf influxdb livestatus opentsdb perfdata statusdata syslog Enabled features: api checker command graphite ido-pgsql mainlog notification