NagiosEnterprises / ncpa

Nagios Cross-Platform Agent
Other
177 stars 95 forks source link

Enable interpolation of config values #908

Open ccztux opened 1 year ago

ccztux commented 1 year ago

We deploy our plugins via rpm packages and some plugins needs to be executed via sudo. So the idea is to deploy the plugin and the regarding ncpa configuration /usr/local/ncpa/etc/ncpa.cfg.d/check_example.cfg via the rpm packages. Example config:

[plugin directives]

#
# Comma separated list of plugins to run through sudo. Note: You will need to update your sudoers
# configuration for these plugins to work when called with sudo.
#
# Example: check_special,check_root_files
# (Command line: sudo /<plugin_absolute_path>/check_special <arguments>)
#
run_with_sudo = check_example

The issue is, that the directive run_with_sudo will be overwritten if it was defined in the main config file /usr/local/ncpa/etc/ncpa.cfg or an include config file /usr/local/ncpa/etc/ncpa.cfg.d/* included before.

Using interpolation of config values as described in the documentation of the python configparser module should solve this issue. The idea is to append the values from each config file via interpolation. Example config with interpolation:

[plugin directives]

#
# Comma separated list of plugins to run through sudo. Note: You will need to update your sudoers
# configuration for these plugins to work when called with sudo.
#
# Example: check_special,check_root_files
# (Command line: sudo /<plugin_absolute_path>/check_special <arguments>)
#
run_with_sudo = ${run_with_sudo},check_example

Is this something other users are interested in too? Please comment.

Thanks!