]> granicus.if.org Git - icinga2/commitdiff
Add running_kernel_use_sudo option for the running_kernel check
authorGunnar Beutner <gunnar@beutner.name>
Mon, 23 Nov 2015 12:26:42 +0000 (13:26 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 26 Nov 2015 10:19:33 +0000 (11:19 +0100)
fixes #10693

doc/7-icinga-template-library.md
itl/plugins-contrib.d/operating-system.conf

index b3227a865747a523a887391b5d5b19eac04a0e75..69cec1e5f4f0a7315811d0b82ccf48baa6a8e0fc 100644 (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
 
index ca7214578590708b27699262bb95a4b4f2f486b2..c065c18c20c206536c84955113ff4e3664effc1c 100644 (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" {