SOLVED:
I had to abandon the perl script.
Big CREDIT to jwalton from here -
http://www.opsview.com/forum/opsview-co ... tification
I use his 2 scripts.
They work right away.
To Scott and Spencer from this forum, I truly appreciate your help.
In the end, there was something wrong with the perl script which is way beyond me to try to fix.
Cheers
=== in case you want them right away, here they are, jwalton's scripts (modify to fit your environment) ===
.procmail script
=============
LOGFILE=/home/opsview/.procmail.log
MAILDIR=/home/opsview/
VERBOSE=YES
:0
* ^SUBJECT: .*PROBLEM.*
|/home/opsview/myscriptname.sh
=======================================
Verbose is handy for debugging. In short, I have a local mailbox for the From: account on my alert emails. I forward emails with PROBLEM in the subject to my script.
Here is myscriptname.sh. This is not the most elegant way of handling it, but it seems to be working well enough for my specific use case. I'm using nagios external commands since I could never figure out how to get the ackowledgements to work from opsview_rest.
The following script gives me 4 options for handling alerts.
A simple reply with no required additional text acknowledges the service/host issue that is being replied to
Replying with: "maint", schedules downtime for 2 hours which can be changed by editing the date command for $END
Replying with: "notify" and "nonotify" respectively enable/disable notifications for the monitoring server.
You may need to update the location of nagios.cmd in CMDF below, as well as ensure your user this is running under has write access to nagios.cmd
"
#!/bin/bash
START=`/bin/date +%s`
END=`/bin/date +%s --date="2 hours"`
CMDF='/usr/local/nagios/var/rw/nagios.cmd'
MAIL=`/bin/cat /dev/stdin`
HOST=`/bin/echo "$MAIL" | grep Host: | awk -F "Host:" {'print $2'} | sed -e 's/^[ \t]*//' | head -1`
ACKBY=`/bin/echo "$MAIL" | grep From: | awk -F ":" {'print $2'} | sed -e 's/^[ \t]*//'`
USER="system"
SERVICE=`/bin/echo "$MAIL" | grep Service: | awk -F "Service:" {'print $2'} | sed -e 's/^[ \t]*//' | head -1`
MSG="Acknowledged via email by $ACKBY"
MAINT=`/bin/echo "$MAIL" | grep -i maint | wc -l`
NOTIFY=`/bin/echo "$MAIL" | grep -i notify | wc -l`
NONOTIFY=`/bin/echo "$MAIL" | grep -i nonotify | wc -l`
##Check notify
if [ "${NONOTIFY}" -ge "1" ];
then
/bin/echo "[%lu] DISABLE_NOTIFICATIONS" > $CMDF
exit 0
elif [ "${NOTIFY}" -ge "1" ];
then
/bin/echo "[%lu] ENABLE_NOTIFICATIONS" > $CMDF
exit 0
fi
if [ -n ${HOST} ];
then
if [ -n "${SERVICE}" ];
then
if [ "${MAINT}" -ge "1" ];
then
/bin/echo "[%lu]SCHEDULE_SVC_DOWNTIME;"$HOST";"$SERVICE";$START;$END;0;0;7200;"$USER";"$MSG"" > $CMDF
elif [ "${MAINT}" -eq "0" ];
then
/bin/echo "[%lu] ACKNOWLEDGE_SVC_PROBLEM;"$HOST";"$SERVICE";1;1;1;"$USER";"$MSG"" > $CMDF
fi
else
if [ "${MAINT}" -ge "1" ];
then
/bin/echo "[%lu] SCHEDULE_HOST_DOWNTIME;"$HOST";$START;$END;0;0;7200;"$USER";"$MSG"" > $CMDF
elif [ "${MAINT}" -eq "0" ];
then
/bin/echo "[%lu] ACKNOWLEDGE_HOST_PROBLEM;"$HOST";1;1;1;"$USER";"$MSG"" > $CMDF
fi
fi
fi
================================================