[Xymon] blank recovered sms alerts on mail

Bill Arlofski waa-hobbitml at revpol.com
Sat May 25 17:47:50 CEST 2013


On 05/25/13 06:46, deepak deore wrote:
> FORMAT=PLAIN is working, I am receiving the recovered messages on my mobile.
> But that message is way long since it is not in sms format.
> 
> could you tell where should i look?

deepak, I think I may have run into a similar issue a long time ago, or maybe
my issue was that I didn't like the level, or type of detail in the SMS format
(i forget now), so I wrote a script to take the PLAIN format and TXT it to me
via the AT&T email-to-SMS gateway. The benefit of this is that you have
complete control to manipulate the format and contents of the SMS that gets sent.


Here's what I did:


First, in alerts.cfg

# Define recipient variables
# --------------------------
$waaphone=##########

# Define scripts
# --------------
$xymon-email-alert=/usr/local/sbin/xymon-email-alert.sh
$xymon-sms-alert=/usr/local/sbin/xymon-SMS-alert.sh

# Define Times
# ------------
$ninetofive=W:0900:1700
$afterhours=W:1701:0859
$weekends=60:0000:2359
$smsalerthours=W:0730:2359,60:0900:2200
$never=365d

# Define Alerts
# -------------
# Match ALL FIREWALLS
# -------------------
PAGE=revpol/client_firewalls
  SCRIPT $xymon-sms-alert $waaphone TIME=$smsalerthours DURATION>5m /
  FORMAT=SMS REPEAT=$neverCOLOR=yellow,red RECOVERED



Then my SMS alert script (/usr/local/sbin/xymon-SMS-alert.sh) follows. It
could probably use some improvement, been a while since I worked with it. :)
(this may wrap poorly in email)

--[snip]--
#!/bin/bash
#
# waa - 20100209
# ---------------
date=`date +%Y%m%d-%H:%M:%S`
log="/tmp/xymon-SMS.log"
FROM="From: RP Xymon <someone at example.com>"
TO="To: $RCPT"

# First, determine if this is a NOTICE message
# (eg: disabling or enabling a test)
# --------------------------------------------
NOTICE=`echo "$BBALPHAMSG" | grep " INFO"`
if [ ! -z "$NOTICE" ]; then

  # This is an INFO type report, so get the event
  # (what was enabled/disabled) and the reason
  # ---------------------------------------------
  EVENT=`echo "$BBALPHAMSG" | grep "Monitoring of"`
  REASON=`echo "$BBALPHAMSG" | grep "Reason:" | cut -d':' -f2-`
  if [ -z "$REASON" ]; then
    MSG="$EVENT"
    else
      MSG="$EVENT:$REASON"
  fi

  else
    # This was not an INFO type report so create
    # and format the normal SMS message
    # ------------------------------------------

    # Determine if this is a recovery notice for a test
    # -------------------------------------------------
    if [ "$RECOVERED" = "1" ]; then
      RECOVERED=" (Recovered)"
      else
        RECOVERED=""
    fi

    # Uppercase the service name
    # --------------------------
    UPSVCNAME=`echo $BBSVCNAME | tr [:lower:] [:upper:]`

    # Set the message text
    # --------------------
    MSG="$RECOVERED ($BBCOLORLEVEL) $UPSVCNAME on $BBHOSTNAME\nDown for
$DOWNSECS seconds"
fi

EMAIL="$FROM\n$TO\n\n$MSG"

# Send the email to the email-to-SMS gateway
# ------------------------------------------
echo -e "$EMAIL" | /usr/sbin/sendmail -t
--[snip]--


Hope this helps.

-- 
Bill Arlofski
Reverse Polarity, LLC
http://www.revpol.com/
--not responsible for anything below this line--



More information about the Xymon mailing list