Add running_kernel_use_sudo option for the running_kernel check

fixes #10693
This commit is contained in:
Gunnar Beutner 2015-11-23 13:26:42 +01:00
parent b14a48d519
commit 330e8db486
2 changed files with 24 additions and 2 deletions

View File

@ -2066,7 +2066,11 @@ mem_critical | **Required.** Specify the critical threshold as number interprete
Check command object for the `check_running_kernel` plugin
provided by the `nagios-plugins-contrib` package on Debian.
The `running_kernel` check command does not support any vars.
Custom attributes:
Name | Description
---------------------------|-------------
running\_kernel\_use\_sudo | Whether to run the plugin with `sudo`. Defaults to false except on Ubuntu where it defaults to true.
#### <a id="plugin-contrib-command-yum"></a> yum

View File

@ -53,7 +53,25 @@ object CheckCommand "mem" {
object CheckCommand "running_kernel" {
import "plugin-check-command"
command = [ "sudo", PluginContribDir + "/check_running_kernel" ]
command = {{
var use_sudo = macro("$running_kernel_use_sudo$")
if (use_sudo == null && PlatformName == "Ubuntu") {
use_sudo = true
}
var args
if (use_sudo) {
args = [ "sudo" ]
} else {
args = []
}
args += [ PluginContribDir + "/check_running_kernel" ]
return args
}}
}
object CheckCommand "yum" {