mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
Implement better way to check parameters in notification scripts
This changes the function for checking required parameters in the notification scripts. This also enhances the error message. refs #5812
This commit is contained in:
parent
a8b5d8e64a
commit
12a40d7244
@ -90,14 +90,14 @@ done
|
|||||||
|
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
## Check required parameters (TODO: better error message)
|
|
||||||
## Keep formatting in sync with mail-service-notification.sh
|
## Keep formatting in sync with mail-service-notification.sh
|
||||||
if [ ! "$LONGDATETIME" ] \
|
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
|
||||||
|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
|
eval "PAR=\$${P}"
|
||||||
|| [ ! "$HOSTOUTPUT" ] || [ ! "$HOSTSTATE" ] \
|
|
||||||
|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
|
if [ ! "$PAR" ] ; then
|
||||||
Error "Requirement parameters are missing."
|
Error "Required parameter '$P' is missing."
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
## Build the message's subject
|
## Build the message's subject
|
||||||
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
|
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
|
||||||
|
@ -94,15 +94,14 @@ done
|
|||||||
|
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
## Check required parameters (TODO: better error message)
|
|
||||||
## Keep formatting in sync with mail-host-notification.sh
|
## Keep formatting in sync with mail-host-notification.sh
|
||||||
if [ ! "$LONGDATETIME" ] \
|
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
|
||||||
|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
|
eval "PAR=\$${P}"
|
||||||
|| [ ! "$SERVICENAME" ] || [ ! "$SERVICEDISPLAYNAME" ] \
|
|
||||||
|| [ ! "$SERVICEOUTPUT" ] || [ ! "$SERVICESTATE" ] \
|
if [ ! "$PAR" ] ; then
|
||||||
|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
|
Error "Required parameter '$P' is missing."
|
||||||
Error "Requirement parameters are missing."
|
fi
|
||||||
fi
|
done
|
||||||
|
|
||||||
## Build the message's subject
|
## Build the message's subject
|
||||||
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
|
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user