Define the default check command custom attribute `disk_wfree` and `disk_cfree`
(freely definable naming schema) and their default threshold values. You can
-then use these custom attributes as runtime macros on the command line.
+then use these custom attributes as runtime macros for [command arguments](#command-arguments)
+on the command line.
The default custom attributes can be overridden by the custom attributes
-defined in the service using the check command `disk`. The custom attributes
+defined in the service using the check command `my-disk`. The custom attributes
can also be inherited from a parent template using additive inheritance (`+=`).
- object CheckCommand "disk" {
+
+ object CheckCommand "my-disk" {
import "plugin-check-command"
-
- command = [
- PluginDir + "/check_disk",
- "-w", "$disk_wfree$%",
- "-c", "$disk_cfree$%"
- ],
-
+
+ command = PluginDir + "/check_disk"
+
+ arguments = {
+ "-w" = "$disk_wfree$%"
+ "-c" = "$disk_cfree$%"
+ }
+
vars.disk_wfree = 20
vars.disk_cfree = 10
}
-The host `localhost` with the service `disk` checks all disks with modified
+
+The host `localhost` with the service `my-disk` checks all disks with modified
custom attributes (warning thresholds at `10%`, critical thresholds at `5%`
free disk space).
address6 = "::1"
}
- object Service "disk" {
+ object Service "my-disk" {
import "generic-service"
host_name = "localhost"
- check_command = "disk"
+ check_command = "my-disk"
vars.disk_wfree = 10
vars.disk_cfree = 5
}
-#### <a id="commands-arguments"></a> Command Arguments
+#### <a id="command-arguments"></a> Command Arguments
By defining a check command line using the `command` attribute Icinga 2
will resolve all macros in the static string or array. Sometimes it is
the service is applied to. If not set, the check command `my-ssh` will omit the argument.
object CheckCommand "my-ssh" {
- import "plugin-check-command"
+ import "plugin-check-command"
- command = PluginDir + "/check_ssh"
+ command = PluginDir + "/check_ssh"
- arguments = {
- "-p" = "$ssh_port$"
- "host" = {
- value = "$ssh_address$"
- skip_key = true
- order = -1
- }
- }
+ arguments = {
+ "-p" = "$ssh_port$"
+ "host" = {
+ value = "$ssh_address$"
+ skip_key = true
+ order = -1
+ }
+ }
- vars.ssh_address = "$address$"
+ vars.ssh_address = "$address$"
}
/* apply ssh service */
The `my-host1` will get the `my-ssh` service checking on the default port:
- [2014-05-26 21:52:23 +0200] <Q #0x7f8bdd5f4a48 W #0x7f8bdd5f4b88> notice/base: Running command '/usr/lib/nagios/plugins/check_ssh', '129.168.1.50': PID 27281
+ [2014-05-26 21:52:23 +0200] notice/Process: Running command '/usr/lib/nagios/plugins/check_ssh', '129.168.1.50': PID 27281
The `my-host2` will inherit the `custom_ssh_port` variable to the service and execute a different command:
- [2014-05-26 21:51:32 +0200] <Q #0x7f8bdd5f4708 W #0x7f8bdd5f4848> notice/base: Running command '/usr/lib/nagios/plugins/check_ssh', '-p', '2222', '129.168.2.50': PID 26956
+ [2014-05-26 21:51:32 +0200] notice/Process: Running command '/usr/lib/nagios/plugins/check_ssh', '-p', '2222', '129.168.2.50': PID 26956
### <a id="notification-commands"></a> Notification Commands
)
/usr/bin/printf "%b" $template | mail -s "$NOTIFICATIONTYPE - $HOSTDISPLAYNAME - $SERVICEDISPLAYNAME is $SERVICESTATE" $USEREMAIL
+
+> **Note**
+>
+> This example is for `exim` only. Requires changes for `sendmail` and
+> other MTAs.
While it's possible to specify the entire notification command right
in the NotificationCommand object it is generally advisable to create a
(e.g. in other configuration attributes).
Here is an example of a command definition which uses user-defined custom attributes:
-
+
object CheckCommand "my-ping" {
import "plugin-check-command"
command = [
- PluginDir + "/check_ping",
- "-4",
- "-H", "$address$",
- "-w", "$ping_wrta$,$ping_wpl$%",
- "-c", "$ping_crta$,$ping_cpl$%",
- "-p", "$ping_packets$",
- "-t", "$ping_timeout$"
+ PluginDir + "/check_ping", "-4"
]
+ arguments = {
+ "-H" = "$ping_address$"
+ "-w" = "$ping_wrta$,$ping_wpl$%"
+ "-c" = "$ping_crta$,$ping_cpl$%"
+ "-p" = "$ping_packets$"
+ "-t" = "$ping_timeout$"
+ }
+
+ vars.ping_address = "$address$"
vars.ping_wrta = 100
vars.ping_wpl = 5
vars.ping_crta = 200
Custom attribute names used at runtime must be enclosed in two `$` signs, e.g.
`$address$`. When using the `$` sign as single character, you need to escape
-it with an additional dollar sign (`$$`).
+it with an additional dollar sign (`$$`). This example also makes use of the
+[command arguments](#command-arguments) passed to the command line. `-4` must
+be added as additional array key.
### <a id="runtime-custom-attributes-evaluation-order"></a> Runtime Custom Attributes Evaluation Order
when passing credentials to database checks:
object CheckCommand "mysql-health" {
- import "plugin-check-command",
+ import "plugin-check-command"
- command = PluginDir + "/check_mysql -H $address$ -d $db$",
+ command = [
+ PluginDir + "/check_mysql"
+ ]
+
+ arguments = {
+ "-H" = "$mysql_address$"
+ "-d" = "$mysql_database$"
+ }
- vars.mysql_user = "icinga_check",
+ vars.mysql_address = "$address$"
+ vars.mysql_database = "icinga"
+ vars.mysql_user = "icinga_check"
vars.mysql_pass = "password"
- env.MYSQLUSER = "$mysql_user$",
+ env.MYSQLUSER = "$mysql_user$"
env.MYSQLPASS = "$mysql_pass$"
}
to the Icinga 1.x example and a best practice hint only.
+#### <a id="manual-config-migration-hints-distributed-setup"></a> Manual Config Migration Hints for Distributed Setups
+
+* Icinga 2 does not use active/passive instances calling OSCP commands and requiring the NSCA
+daemon for passing check results between instances.
+* Icinga 2 does not support any 1.x NEB addons for check load distribution
+
+* If your current setup consists of instances distributing the check load, you should consider
+building a [load distribution](#cluster-scenarios-load-distribution) setup with Icinga 2.
+* If your current setup includes active/passive clustering with external tools like Pacemaker/DRBD
+consider the [High Availability](#cluster-scenarios-high-availability) setup.
+* If you have build your own custom configuration deployment and check result collecting mechanism
+you should re-design your setup and re-evaluate your requirements, and how they may be fulfilled
+using the Icinga 2 cluster capabilities.
## <a id="differences-1x-2"></a> Differences between Icinga 1.x and 2
vars.crta = 500
vars.cpl = 60
}
+
+> **Note**
+>
+> For better maintainability you should consider using [command arguments](#command-arguments)
+> for your check commands.
-The Classic UI feature named `Command Expander` does not work with Icinga 2.
+> **Note**
+>
+> The Classic UI feature named `Command Expander` does not work with Icinga 2.
#### <a id="differences-1x-2-environment-macros"></a> Environment Macros