]> granicus.if.org Git - icinga2/commitdiff
Add by_ssh command object.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 22 May 2014 12:05:56 +0000 (14:05 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 22 May 2014 12:05:56 +0000 (14:05 +0200)
Refs #5795

doc/4-monitoring-remote-systems.md
doc/5-configuring-icinga-2.md
itl/command-plugins.conf

index a1425ebe23900dd85fc7950948f4a0afc13d36fd..700ec194558a6fd93050dea221d2d38afae3350e 100644 (file)
@@ -22,31 +22,30 @@ the `check_snmp` plugin binary, but there are plenty of [existing plugins](#inte
 for specific use cases already around, for example monitoring Cisco routers.
 
 The following example uses the [SNMP ITL](#itl-snmp) `CheckCommand` and just
-overrides the `oid` custom attribute. A service is created for all hosts which
-have the `community` custom attribute.
+overrides the `snmp_oid` custom attribute. A service is created for all hosts which
+have the `snmP-community` custom attribute.
 
     apply Service "uptime" {
       import "generic-service"
 
       check_command = "snmp"
-      vars.oid = "1.3.6.1.2.1.1.3.0"
+      vars.snmp_oid = "1.3.6.1.2.1.1.3.0"
   
-      assign where host.vars.community
+      assign where host.vars.snmp_community != ""
     }
 
 ### <a id="agent-based-checks-ssh"></a> SSH
 
 Calling a plugin using the SSH protocol to execute a plugin on the remote server fetching
-its return code and output. `check_by_ssh` is available in the [Monitoring Plugins package](#setting-up-check-plugins).
+its return code and output. The `by_ssh` command object is part of the built-in templates and
+requires the `check_by_ssh` check plugin which is available in the [Monitoring Plugins package](#setting-up-check-plugins).
 
-    object CheckCommand "check_by_ssh_swap" {
-      import "plugin-check-command"
+    object CheckCommand "by_ssh_swap" {
+      import "by_ssh"
 
-      command = [ PluginDir + "/check_by_ssh",
-                  "-l", "remoteuser",
-                  "-H", "$address$",
-                  "-C", "\"/usr/local/icinga/libexec/check_swap -w $warn$ -c $crit$\""
-                ]
+      vars.by_ssh_command = "/usr/lib/nagios/plugins/check_swap -w $by_ssh_swap_warn$ -c $by_ssh_swap_crit$"
+      vars.by_ssh_swap_warn = "50%"
+      vars.by_ssh_swap_crit = "75%"
     }
 
     object Service "swap" {
@@ -54,11 +53,9 @@ its return code and output. `check_by_ssh` is available in the [Monitoring Plugi
 
       host_name = "remote-ssh-host"
 
-      check_command = "check_by_ssh_swap"
-      vars = {
-            "warn" = "50%"
-            "crit" = "75%"
-      }
+      check_command = "by_ssh_swap"
+
+      vars.by_ssh_logname = "icinga"
     }
 
 ### <a id="agent-based-checks-nrpe"></a> NRPE
index 0adb37b44ef92907415484f2d0c46a722f071adb..615fbef4232d521c9f8fd76b0772a2a108a7109b 100644 (file)
@@ -1949,6 +1949,24 @@ nscp_warn       | **Optional.** The warning threshold.
 nscp_crit       | **Optional.** The critical threshold.
 nscp_timeout    | **Optional.** The query timeout in seconds.
 
+#### <a id="plugin-check-command-by-ssh"></a> by_ssh
+
+Check command object for the `check_by_ssh` plugin.
+
+Custom Attributes:
+
+Name            | Description
+----------------|--------------
+by_ssh_address  | **Optional.** The host's address. Defaults to "$address$".
+by_ssh_port     | **Optional.** The SSH port. Defaults to 22.
+by_ssh_command  | **Optional.** The command that should be executed.
+by_ssh_logname  | **Optional.** The SSH username.
+by_ssh_identity | **Optional.** The SSH identity.
+by_ssh_quiet    | **Optional.** Whether to suppress SSH warnings. Defaults to false.
+by_ssh_warn     | **Optional.** The warning threshold.
+by_ssh_crit     | **Optional.** The critical threshold.
+by_ssh_timeout  | **Optional.** The timeout in seconds.
+
 #### <a id="plugin-check-command-apt"></a> apt
 
 Check command for the `check_apt` plugin.
index f127e96c67fe1933791fb7c630080f81d8f726e0..30109081d32b4ae9346845cd77bf15662c9862ff 100644 (file)
@@ -231,7 +231,7 @@ object CheckCommand "swap" {
        command = PluginDir + "/check_swap"
 
        arguments = {
-               "-w" = "$swap_wfree$%",
+               "-w" = "$swap_wfree$%"
                "-c" = "$swap_cfree$%"
        }
 
@@ -264,8 +264,8 @@ object CheckCommand "snmp" {
        command = PluginDir + "/check_snmp"
 
        arguments = {
-               "-H" = "$snmp_address$",
-               "-o" = "$snmp_oid$",
+               "-H" = "$snmp_address$"
+               "-o" = "$snmp_oid$"
                "-C" = "$snmp_community$"
        }
 
@@ -312,16 +312,42 @@ object CheckCommand "nscp" {
        command = PluginDir + "/check_nt"
 
        arguments = {
-               "-H" = "$nscp_address$",
-               "-p" = "$nscp_port$",
-               "-s" = "$nscp_password$",
-               "-v" = { value = "$nscp_variable$", required = true },
-               "-l" = "$nscp_params$",
-               "-w" = "$nscp_warn$",
-               "-c" = "$nscp_crit$",
+               "-H" = "$nscp_address$"
+               "-p" = "$nscp_port$"
+               "-s" = "$nscp_password$"
+               "-v" = {
+                       value = "$nscp_variable$"
+                       required = true
+               }
+               "-l" = "$nscp_params$"
+               "-w" = "$nscp_warn$"
+               "-c" = "$nscp_crit$"
                "-t" = "$nscp_timeout$"
        }
 
        vars.nscp_address = "$address$"
        vars.nscp_port = 12489
 }
+
+object CheckCommand "by_ssh" {
+       import "plugin-check-command"
+
+       command = PluginDir + "/check_by_ssh"
+
+       arguments = {
+               "-H" = "$by_ssh_address$"
+               "-p" = "$by_ssh_port$"
+               "-C" = "$by_ssh_command$"
+               "-l" = "$by_ssh_logname$"
+               "-i" = "$by_ssh_identity$"
+               "-q" = {
+                       set_if = "$by_ssh_quiet$"
+               }
+               "-w" = "$by_ssh_warn$"
+               "-c" = "$by_ssh_crit$"
+               "-t" = "$by_ssh_timeout$"
+       }
+
+       vars.by_ssh_address = "$address$"
+       vars.by_ssh_quiet = false
+}