mirror of https://github.com/Icinga/icinga2.git
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))
|
||||
|
||||
## Check required parameters (TODO: better error message)
|
||||
## Keep formatting in sync with mail-service-notification.sh
|
||||
if [ ! "$LONGDATETIME" ] \
|
||||
|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
|
||||
|| [ ! "$HOSTOUTPUT" ] || [ ! "$HOSTSTATE" ] \
|
||||
|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
|
||||
Error "Requirement parameters are missing."
|
||||
fi
|
||||
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
|
||||
eval "PAR=\$${P}"
|
||||
|
||||
if [ ! "$PAR" ] ; then
|
||||
Error "Required parameter '$P' is missing."
|
||||
fi
|
||||
done
|
||||
|
||||
## Build the message's subject
|
||||
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
|
||||
|
|
|
@ -94,15 +94,14 @@ done
|
|||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
## Check required parameters (TODO: better error message)
|
||||
## Keep formatting in sync with mail-host-notification.sh
|
||||
if [ ! "$LONGDATETIME" ] \
|
||||
|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
|
||||
|| [ ! "$SERVICENAME" ] || [ ! "$SERVICEDISPLAYNAME" ] \
|
||||
|| [ ! "$SERVICEOUTPUT" ] || [ ! "$SERVICESTATE" ] \
|
||||
|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
|
||||
Error "Requirement parameters are missing."
|
||||
fi
|
||||
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
|
||||
eval "PAR=\$${P}"
|
||||
|
||||
if [ ! "$PAR" ] ; then
|
||||
Error "Required parameter '$P' is missing."
|
||||
fi
|
||||
done
|
||||
|
||||
## Build the message's subject
|
||||
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
|
||||
|
|
Loading…
Reference in New Issue