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" {
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
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.
command = PluginDir + "/check_swap"
arguments = {
- "-w" = "$swap_wfree$%",
+ "-w" = "$swap_wfree$%"
"-c" = "$swap_cfree$%"
}
command = PluginDir + "/check_snmp"
arguments = {
- "-H" = "$snmp_address$",
- "-o" = "$snmp_oid$",
+ "-H" = "$snmp_address$"
+ "-o" = "$snmp_oid$"
"-C" = "$snmp_community$"
}
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
+}