mirror of https://github.com/Icinga/icinga2.git
Notification Scripts: Ensure that mail from address works on Debian/RHEL/SUSE (mailutils vs mailx)
fixes #5299
This commit is contained in:
parent
6b8015a127
commit
f5d3428563
|
@ -1583,7 +1583,10 @@ defaults can always be overwritten locally.
|
|||
|
||||
#### <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.
|
||||
|
||||
|
@ -1600,13 +1603,16 @@ 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.
|
||||
|
||||
|
@ -1625,7 +1631,7 @@ 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`.
|
||||
|
||||
|
|
|
@ -1113,7 +1113,10 @@ Example:
|
|||
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
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
/* 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" ]
|
||||
|
||||
|
@ -15,7 +21,10 @@ object NotificationCommand "mail-host-notification" {
|
|||
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
|
||||
|
@ -78,7 +87,10 @@ object NotificationCommand "mail-service-notification" {
|
|||
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
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
|
||||
|
||||
PROG="`basename $0`"
|
||||
HOSTNAME="`hostname`"
|
||||
|
@ -28,7 +30,7 @@ Optional parameters:
|
|||
-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
|
||||
|
@ -133,8 +135,17 @@ fi
|
|||
## 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
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
|
||||
|
||||
PROG="`basename $0`"
|
||||
HOSTNAME="`hostname`"
|
||||
|
@ -30,7 +32,7 @@ Optional parameters:
|
|||
-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
|
||||
|
@ -139,8 +141,17 @@ fi
|
|||
## 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
|
||||
|
|
Loading…
Reference in New Issue