command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
arguments += {
- "-4" = {
- required = true
- value = "$notification_address$"
- }
+ "-4" = "$notification_address$"
"-6" = "$notification_address6$"
"-b" = "$notification_author$"
"-c" = "$notification_comment$"
command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
arguments += {
- "-4" = {
- required = true
- value = "$notification_address$"
- }
+ "-4" = "$notification_address$"
"-6" = "$notification_address6$"
"-b" = "$notification_author$"
"-c" = "$notification_comment$"
cat << EOF
Required parameters:
- -4 HOSTADDRESS (\$address\$)
-d LONGDATETIME (\$icinga.long_date_time\$)
-l HOSTNAME (\$host.name\$)
-n HOSTDISPLAYNAME (\$host.display_name\$)
-t NOTIFICATIONTYPE (\$notification.type\$)
Optional parameters:
+ -4 HOSTADDRESS (\$address\$)
-6 HOSTADDRESS6 (\$address6\$)
-b NOTIFICATIONAUTHORNAME (\$notification.author\$)
-c NOTIFICATIONCOMMENT (\$notification.comment\$)
while getopts 4:6::b:c:d:f:hi:l:n:o:r:s:t:v: opt
do
case "$opt" in
- 4) HOSTADDRESS=$OPTARG ;; # required
+ 4) HOSTADDRESS=$OPTARG ;;
6) HOSTADDRESS6=$OPTARG ;;
b) NOTIFICATIONAUTHORNAME=$OPTARG ;;
c) NOTIFICATIONCOMMENT=$OPTARG ;;
## Check required parameters (TODO: better error message)
## Keep formatting in sync with mail-service-notification.sh
-if [ ! "$HOSTADDRESS" ] || [ ! "$LONGDATETIME" ] \
+if [ ! "$LONGDATETIME" ] \
|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
|| [ ! "$HOSTOUTPUT" ] || [ ! "$HOSTSTATE" ] \
|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
When: $LONGDATETIME
Host: $HOSTNAME (Display Name: "$HOSTDISPLAYNAME")
-IPv4: $HOSTADDRESS
EOF
`
+## Check whether IPv4 was specified.
+if [ -n "$HOSTADDRESS" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+IPv4: $HOSTADDRESS"
+fi
+
## Check whether IPv6 was specified.
if [ -n "$HOSTADDRESS6" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
cat << EOF
Required parameters:
- -4 HOSTADDRESS (\$address\$)
-d LONGDATETIME (\$icinga.long_date_time\$)
-e SERVICENAME (\$service.name\$)
-l HOSTNAME (\$host.name\$)
-u SERVICEDISPLAYNAME (\$service.display_name\$)
Optional parameters:
+ -4 HOSTADDRESS (\$address\$)
-6 HOSTADDRESS6 (\$address6\$)
-b NOTIFICATIONAUTHORNAME (\$notification.author\$)
-c NOTIFICATIONCOMMENT (\$notification.comment\$)
while getopts 4:6:b:c:d:e:f:hi:l:n:o:r:s:t:u:v: opt
do
case "$opt" in
- 4) HOSTADDRESS=$OPTARG ;; # required
+ 4) HOSTADDRESS=$OPTARG ;;
6) HOSTADDRESS6=$OPTARG ;;
b) NOTIFICATIONAUTHORNAME=$OPTARG ;;
c) NOTIFICATIONCOMMENT=$OPTARG ;;
## Check required parameters (TODO: better error message)
## Keep formatting in sync with mail-host-notification.sh
-if [ ! "$HOSTADDRESS" ] || [ ! "$LONGDATETIME" ] \
+if [ ! "$LONGDATETIME" ] \
|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
|| [ ! "$SERVICENAME" ] || [ ! "$SERVICEDISPLAYNAME" ] \
|| [ ! "$SERVICEOUTPUT" ] || [ ! "$SERVICESTATE" ] \
When: $LONGDATETIME
Service: $SERVICENAME (Display Name: "$SERVICEDISPLAYNAME")
Host: $HOSTNAME (Display Name: "$HOSTDISPLAYNAME")
-IPv4: $HOSTADDRESS
EOF
`
+## Check whether IPv4 was specified.
+if [ -n "$HOSTADDRESS" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+IPv4: $HOSTADDRESS"
+fi
+
## Check whether IPv6 was specified.
if [ -n "$HOSTADDRESS6" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE