I've wrote a macro that can be called as such
Code: Select all
$USER1$/event_handler_customer_mail.sh "$SERVICEDESC$" $SERVICESTATE$ "$NOTIFICATIONCOMMENT$" $CONTACTEMAIL$* The notification is not sent when it is created in the Nagios Core website, but is only triggered when the scheduled downtime starts (so in my example the notification is sent at 2016-07-14 20:00:00 and not at 15:30)
* The notification is sent when the downtime starts, but also when the downtime ends. How can I make sure that is only sent once?
* In my macro I cannot find a way to use the strings for the scheduled start and end.
This is currently my macro:
Code: Select all
#!/bin/bash
DATE=$(date)
SERVICEDESC="$1"
SERVICESTATETYPE=$2
NOTIFICATIONCOMMENT="$3"
EMAIL=$4
if [[ "$SERVICESTATE" == "CRITICAL" ]]; then
/usr/bin/printf "%b" "Dear client:\n\nWe regret to inform you that our website $SERVICEDESC is currently not available due to an unplanned issue. We're aware of this unavailability and are doing our utmost to bring our service back as soon as possible.\n\nWe will send you an update as soon as our website is working as normal again.\n\nDate/Time: $DATE\n" | /usr/bin/mail -s "WARNING: $SERVICEDESC is currently not available" $EMAIL
exit 0
elif [[ "$SERVICESTATE" == "OK" ]]; then
/usr/bin/printf "%b" "Dear client:\n\nWe are glad to inform you that our website $SERVICEDESC is behaving normally again.\n\nDate/Time: $DATE\n" | /usr/bin/mail -s "SOLVED: $SERVICEDESC is available" $EMAIL
exit 0
elif [[ ! -z "$NOTIFICATIONCOMMENT" ]]; then
/usr/bin/printf "%b" "Dear client:\n\nWe are a scheduling an update of our website $SERVICEDESC.\n\n$NOTIFICATIONCOMMENT\n\nDate/Time: $DATE\n" | /usr/bin/mail -s "WARNING: Scheduled maintenance for $SERVICEDESC" $EMAIL
exit 0
else
exit 0
fi
-- Ivan