From 31710e11629b601c133e3bcf5419cef2fe1fb5e8 Mon Sep 17 00:00:00 2001 From: Silas <67681686+Tqnsls@users.noreply.github.com> Date: Wed, 1 Mar 2023 11:48:39 +0100 Subject: [PATCH] Added host.notes and service.notes output if specified --- etc/icinga2/scripts/mail-host-notification.sh | 10 +++++++++- .../scripts/mail-service-notification.sh | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/etc/icinga2/scripts/mail-host-notification.sh b/etc/icinga2/scripts/mail-host-notification.sh index 744481a77..3850ad651 100755 --- a/etc/icinga2/scripts/mail-host-notification.sh +++ b/etc/icinga2/scripts/mail-host-notification.sh @@ -27,6 +27,7 @@ Required parameters: Optional parameters: -4 HOSTADDRESS (\$address\$) -6 HOSTADDRESS6 (\$address6\$) + -X HOSTNOTES (\$host.notes\$) -b NOTIFICATIONAUTHORNAME (\$notification.author\$) -c NOTIFICATIONCOMMENT (\$notification.comment\$) -i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset) @@ -63,7 +64,7 @@ urlencode() { } ## Main -while getopts 4:6::b:c:d:f:hi:l:n:o:r:s:t:v: opt +while getopts 4:6::b:c:d:f:hi:l:n:o:r:s:t:v:X: opt do case "$opt" in 4) HOSTADDRESS=$OPTARG ;; @@ -77,6 +78,7 @@ do l) HOSTNAME=$OPTARG ;; # required n) HOSTDISPLAYNAME=$OPTARG ;; # required o) HOSTOUTPUT=$OPTARG ;; # required + X) HOSTNOTES="${OPTARG}" ;; r) USEREMAIL=$OPTARG ;; # required s) HOSTSTATE=$OPTARG ;; # required t) NOTIFICATIONTYPE=$OPTARG ;; # required @@ -129,6 +131,12 @@ if [ -n "$HOSTADDRESS6" ] ; then IPv6: $HOSTADDRESS6" fi +## Check whether host notes was specified. +if [ -n "$HOSTNOTES" ] ; then + NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE +Host-Notes: $HOSTNOTES" +fi + ## Check whether author and comment was specified. if [ -n "$NOTIFICATIONCOMMENT" ] ; then NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE diff --git a/etc/icinga2/scripts/mail-service-notification.sh b/etc/icinga2/scripts/mail-service-notification.sh index 8e560ac23..da277adb7 100755 --- a/etc/icinga2/scripts/mail-service-notification.sh +++ b/etc/icinga2/scripts/mail-service-notification.sh @@ -29,6 +29,8 @@ Required parameters: Optional parameters: -4 HOSTADDRESS (\$address\$) -6 HOSTADDRESS6 (\$address6\$) + -X HOSTNOTES (\$host.notes\$) + -x SERVICENOTES (\$service.notes\$) -b NOTIFICATIONAUTHORNAME (\$notification.author\$) -c NOTIFICATIONCOMMENT (\$notification.comment\$) -i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset) @@ -65,7 +67,7 @@ urlencode() { } ## Main -while getopts 4:6:b:c:d:e:f:hi:l:n:o:r:s:t:u:v: opt +while getopts 4:6:b:c:d:e:f:hi:l:n:o:r:s:t:u:v:X:x: opt do case "$opt" in 4) HOSTADDRESS=$OPTARG ;; @@ -79,6 +81,8 @@ do i) ICINGAWEB2URL=$OPTARG ;; l) HOSTNAME=$OPTARG ;; # required n) HOSTDISPLAYNAME=$OPTARG ;; # required + X) HOSTNOTES=$OPTARG ;; + x) SERVICENOTES=$OPTARG ;; o) SERVICEOUTPUT=$OPTARG ;; # required r) USEREMAIL=$OPTARG ;; # required s) SERVICESTATE=$OPTARG ;; # required @@ -134,6 +138,18 @@ if [ -n "$HOSTADDRESS6" ] ; then IPv6: $HOSTADDRESS6" fi +## Check whether host notes was specified. +if [ -n "${HOSTNOTES}" ] ; then + NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE +Host-Notes: $HOSTNOTES" +fi + +## Check whether service notes was specified. +if [ -n "${SERVICENOTES}" ] ; then + NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE +Service-Notes: $SERVICENOTES" +fi + ## Check whether author and comment was specified. if [ -n "$NOTIFICATIONCOMMENT" ] ; then NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE