mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6822 from unki/change/add-line-breaks-to-service-output
service and host mail-notifications, add line-breaks to very long out…
This commit is contained in:
commit
09892a9cd5
|
@ -94,13 +94,33 @@ shift $((OPTIND - 1))
|
||||||
|
|
||||||
## Keep formatting in sync with mail-service-notification.sh
|
## Keep formatting in sync with mail-service-notification.sh
|
||||||
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
|
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
|
||||||
eval "PAR=\$${P}"
|
eval "PAR=\$${P}"
|
||||||
|
|
||||||
if [ ! "$PAR" ] ; then
|
if [ ! "$PAR" ] ; then
|
||||||
Error "Required parameter '$P' is missing."
|
Error "Required parameter '$P' is missing."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
## Add line-breaks to very long host-outputs to avoid
|
||||||
|
## mail servers rejecting the message because of hitting
|
||||||
|
## a max. message line limit (RFC821 max. 1000b per line)
|
||||||
|
##
|
||||||
|
## but move on, if the strings seems to take care of its
|
||||||
|
## own formating (containing \n or \r)
|
||||||
|
if [ ! -z "${HOSTOUTPUT}" ] \
|
||||||
|
&& [ "${#HOSTOUTPUT}" -ge 900 ] \
|
||||||
|
&& ! [[ "${HOSTOUTPUT}" =~ ($'\n'|$'\r') ]]; then
|
||||||
|
TMP_OUTPUT=''
|
||||||
|
STR_CNT=0
|
||||||
|
STR_STEPS=600
|
||||||
|
while [ $STR_CNT -lt ${#HOSTOUTPUT} ]; do
|
||||||
|
TMP_OUTPUT+="${HOSTOUTPUT:$STR_CNT:$STR_STEPS}\\n"
|
||||||
|
((STR_CNT+=STR_STEPS)) || true
|
||||||
|
done
|
||||||
|
HOSTOUTPUT="${TMP_OUTPUT}"
|
||||||
|
unset TMP_OUTPUT STR_CNT
|
||||||
|
fi
|
||||||
|
|
||||||
## Build the message's subject
|
## Build the message's subject
|
||||||
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
|
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
|
||||||
ENCODED_SUBJECT="=?utf-8?B?$(base64 --wrap=0 <<< "$SUBJECT")?="
|
ENCODED_SUBJECT="=?utf-8?B?$(base64 --wrap=0 <<< "$SUBJECT")?="
|
||||||
|
|
|
@ -98,13 +98,33 @@ shift $((OPTIND - 1))
|
||||||
|
|
||||||
## Keep formatting in sync with mail-host-notification.sh
|
## Keep formatting in sync with mail-host-notification.sh
|
||||||
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
|
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
|
||||||
eval "PAR=\$${P}"
|
eval "PAR=\$${P}"
|
||||||
|
|
||||||
if [ ! "$PAR" ] ; then
|
if [ ! "$PAR" ] ; then
|
||||||
Error "Required parameter '$P' is missing."
|
Error "Required parameter '$P' is missing."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
## Add line-breaks to very long service-outputs to avoid
|
||||||
|
## mail servers rejecting the message because of hitting
|
||||||
|
## a max. message line limit (RFC821 max. 1000b per line)
|
||||||
|
##
|
||||||
|
## but move on, if the strings seems to take care of its
|
||||||
|
## own formating (containing \n or \r)
|
||||||
|
if [ ! -z "${SERVICEOUTPUT}" ] \
|
||||||
|
&& [ "${#SERVICEOUTPUT}" -ge 900 ] \
|
||||||
|
&& ! [[ "${SERVICEOUTPUT}" =~ ($'\n'|$'\r') ]]; then
|
||||||
|
TMP_OUTPUT=''
|
||||||
|
STR_CNT=0
|
||||||
|
STR_STEPS=600
|
||||||
|
while [ $STR_CNT -lt ${#SERVICEOUTPUT} ]; do
|
||||||
|
TMP_OUTPUT+="${SERVICEOUTPUT:$STR_CNT:$STR_STEPS}\\n"
|
||||||
|
((STR_CNT+=STR_STEPS)) || true
|
||||||
|
done
|
||||||
|
SERVICEOUTPUT="${TMP_OUTPUT}"
|
||||||
|
unset TMP_OUTPUT STR_CNT
|
||||||
|
fi
|
||||||
|
|
||||||
## Build the message's subject
|
## Build the message's subject
|
||||||
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
|
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
|
||||||
ENCODED_SUBJECT="=?utf-8?B?$(base64 --wrap=0 <<< "$SUBJECT")?="
|
ENCODED_SUBJECT="=?utf-8?B?$(base64 --wrap=0 <<< "$SUBJECT")?="
|
||||||
|
|
Loading…
Reference in New Issue