#### <a id="mail-host-notification"></a> mail-host-notification
-A quick overview of the arguments that can be used. See also [host runtime
+The `mail-host-notification` NotificationCommand object uses the
+example notification script located in `/etc/icinga2/scripts/mail-host-notification.sh`.
+
+Here is a quick overview of the arguments that can be used. See also [host runtime
macros](3-monitoring-basics.md#-host-runtime-macros) for further
information.
`notification_address6` | **Optional.** The host's IPv6 address. Defaults to `$address6$`.
`notification_author` | **Optional.** Comment author. Defaults to `$notification.author$`.
`notification_comment` | **Optional.** Comment text. Defaults to `$notification.comment$`.
- `notification_from` | **Optional.** Define a valid From: string (e.g. `"Icinga 2 Host Monitoring <icinga@example.com>"`)
+ `notification_from` | **Optional.** Define a valid From: string (e.g. `"Icinga 2 Host Monitoring <icinga@example.com>"`). Requires `GNU mailutils` (Debian/Ubuntu) or `mailx` (RHEL/SUSE).
`notification_icingaweb2url` | **Optional.** Define URL to your Icinga Web 2 (e.g. `"https://www.example.com/icingaweb2"`)
`notification_logtosyslog` | **Optional.** Set `true` to log notification events to syslog; useful for debugging. Defaults to `false`.
#### <a id="mail-service-notification"></a> mail-service-notification
-A quick overview of the arguments that can be used. See also [service runtime
+The `mail-service-notification` NotificationCommand object uses the
+example notification script located in `/etc/icinga2/scripts/mail-service-notification.sh`.
+
+Here is a quick overview of the arguments that can be used. See also [service runtime
macros](3-monitoring-basics.md#-service-runtime-macros) for further
information.
`notification_address6` | **Optional.** The host's IPv6 address. Defaults to `$address6$`.
`notification_author` | **Optional.** Comment author. Defaults to `$notification.author$`.
`notification_comment` | **Optional.** Comment text. Defaults to `$notification.comment$`.
- `notification_from` | **Optional.** Define a valid From: string (e.g. `"Icinga 2 Host Monitoring <icinga@example.com>"`)
+ `notification_from` | **Optional.** Define a valid From: string (e.g. `"Icinga 2 Host Monitoring <icinga@example.com>"`). Requires `GNU mailutils` (Debian/Ubuntu) or `mailx` (RHEL/SUSE).
`notification_icingaweb2url` | **Optional.** Define URL to your Icinga Web 2 (e.g. `"https://www.example.com/icingaweb2"`)
`notification_logtosyslog` | **Optional.** Set `true` to log notification events to syslog; useful for debugging. Defaults to `false`.
required = true
value = "$notification_servicename$"
}
- "-f" = "$notification_from$"
+ "-f" = {
+ value = "$notification_from$"
+ description = "Set from address. Requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE)"
+ }
"-i" = "$notification_icingaweb2url$"
"-l" = {
required = true
/* Command objects */
+/* Notification Commands
+ *
+ * Please check the documentation for all required and
+ * optional parameters.
+ */
+
object NotificationCommand "mail-host-notification" {
command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
required = true
value = "$notification_date$"
}
- "-f" = "$notification_from$"
+ "-f" = {
+ value = "$notification_from$"
+ description = "Set from address. Requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE)"
+ }
"-i" = "$notification_icingaweb2url$"
"-l" = {
required = true
required = true
value = "$notification_servicename$"
}
- "-f" = "$notification_from$"
+ "-f" = {
+ value = "$notification_from$"
+ description = "Set from address. Requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE)"
+ }
"-i" = "$notification_icingaweb2url$"
"-l" = {
required = true
-#!/bin/sh
+#!/usr/bin/env bash
+#
+# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
PROG="`basename $0`"
HOSTNAME="`hostname`"
-b NOTIFICATIONAUTHORNAME (\$notification.author\$)
-c NOTIFICATIONCOMMENT (\$notification.comment\$)
-i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset)
- -f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils)
+ -f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE))
-v (\$notification_sendtosyslog\$, Default: false)
EOF
## Send the mail using the $MAILBIN command.
## If an explicit sender was specified, try to set it.
if [ -n "$MAILFROM" ] ; then
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
- | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+
+ ## Modify this for your own needs!
+
+ ## Debian/Ubuntu use mailutils which requires `-a` to append the header
+ if [ -f /etc/debian_version ]; then
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+ ## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
+ else
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
+ fi
+
else
/usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
| $MAILBIN -s "$SUBJECT" $USEREMAIL
-#!/bin/sh
+#!/usr/bin/env bash
+#
+# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
PROG="`basename $0`"
HOSTNAME="`hostname`"
-b NOTIFICATIONAUTHORNAME (\$notification.author\$)
-c NOTIFICATIONCOMMENT (\$notification.comment\$)
-i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset)
- -f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils)
+ -f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE))
-v (\$notification_sendtosyslog\$, Default: false)
EOF
## Send the mail using the $MAILBIN command.
## If an explicit sender was specified, try to set it.
if [ -n "$MAILFROM" ] ; then
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
- | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+
+ ## Modify this for your own needs!
+
+ ## Debian/Ubuntu use mailutils which requires `-a` to append the header
+ if [ -f /etc/debian_version ]; then
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+ ## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
+ else
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
+ fi
+
else
/usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
| $MAILBIN -s "$SUBJECT" $USEREMAIL