[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: monit sms alert with script
From: |
Lutz Mader |
Subject: |
Re: monit sms alert with script |
Date: |
Sat, 15 Oct 2016 14:13:40 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
Hi Damjan,
Monit use some environment variables are available in user script.
> I also hope if there is possible to use variable for defined alarm in
>
> The end of my string 'Message on SMS - Monit Problem XYZ'
Some of my check file monitor definitions use scripts with something
like this.
Get some information based on the service name used by monit.
if [ -n "$MONIT_SERVICE" ]; then
SERV="$MONIT_SERVICE"
# APPL=`echo "$MONIT_SERVICE" | cut -f 1 -d '_'`
CELL=`echo "$MONIT_SERVICE" | cut -f 2 -d '_'`
SRVR=`echo "$MONIT_SERVICE" | cut -f 3 -d '_'`
PROC="Serv_${CELL}_${SRVR}"
else
:
fi
# Handle some events.
if [ -n "$MONIT_EVENT" ]; then
:
fi
Handle the message lines found by the match.
# Handle matched lines.
if [ -n "$MONIT_DESCRIPTION" ]; then
echo $MONIT_DESCRIPTION | grep -e "^content match" >/dev/null
if [ $? -eq 0 ]; then
# Remove duplicate lines.
echo -e $MONIT_DESCRIPTION | uniq | \
while read desc; do
if [[ "$desc" = *'ORBX0390E:'* ]]; then
:
fi
done
fi
I use
check file file.log with path "/path/to/file.log"
if not exist then exec "/path/t/file.log"
if match "error" then alert
if match "ORBX0390E:" then exec "/path/to/script.sh"
:
A suggestion only,
with regards,
Lutz
p.s.
See https://mmonit.com/wiki/MMonit/PushoverNotification