From 1eb152d863ab3c6b4e4e82281e0f3fe99f990234 Mon Sep 17 00:00:00 2001 From: "Marianne M. Spiller" Date: Wed, 7 Jun 2017 10:17:03 +0200 Subject: [PATCH] Update documentation for enhanced notification scripts refs #5170 --- doc/3-monitoring-basics.md | 137 ++++++++++++++++++++----------------- doc/9-object-types.md | 88 +++++++++++++++++++----- 2 files changed, 144 insertions(+), 81 deletions(-) diff --git a/doc/3-monitoring-basics.md b/doc/3-monitoring-basics.md index 087b3acdf..4d44cc2dd 100644 --- a/doc/3-monitoring-basics.md +++ b/doc/3-monitoring-basics.md @@ -1544,78 +1544,91 @@ when passing credentials to database checks: ### Notification Commands -[NotificationCommand](9-object-types.md#objecttype-notificationcommand) objects define how notifications are delivered to external -interfaces (email, XMPP, IRC, Twitter, etc.). - -[NotificationCommand](9-object-types.md#objecttype-notificationcommand) objects are referenced by -[Notification](9-object-types.md#objecttype-notification) objects using the `command` attribute. +[NotificationCommand](9-object-types.md#objecttype-notificationcommand) +objects define how notifications are delivered to external interfaces +(email, XMPP, IRC, Twitter, etc.). +[NotificationCommand](9-object-types.md#objecttype-notificationcommand) +objects are referenced by [Notification](9-object-types.md#objecttype-notification) +objects using the `command` attribute. > **Note** > > Make sure that the [notification](11-cli-commands.md#enable-features) feature is enabled > in order to execute notification commands. -Below is an example using runtime macros from Icinga 2 (such as `$service.output$` for -the current check output) sending an email to the user(s) associated with the -notification itself (`$user.email$`). - -If you want to specify default values for some of the custom attribute definitions, -you can add a `vars` dictionary as shown for the `CheckCommand` object. - - object NotificationCommand "mail-service-notification" { - command = [ SysconfDir + "/icinga2/scripts/mail-notification.sh" ] - - env = { - NOTIFICATIONTYPE = "$notification.type$" - SERVICEDESC = "$service.name$" - HOSTALIAS = "$host.display_name$" - HOSTADDRESS = "$address$" - SERVICESTATE = "$service.state$" - LONGDATETIME = "$icinga.long_date_time$" - SERVICEOUTPUT = "$service.output$" - NOTIFICATIONAUTHORNAME = "$notification.author$" - NOTIFICATIONCOMMENT = "$notification.comment$" - HOSTDISPLAYNAME = "$host.display_name$" - SERVICEDISPLAYNAME = "$service.display_name$" - USEREMAIL = "$user.email$" - } - } - -The command attribute in the `mail-service-notification` command refers to the following -shell script. The macros specified in the `env` array are exported -as environment variables and can be used in the notification script: - - #!/usr/bin/env bash - template=$(cat <