Xymon Mailing List Archive search

How to customize the subject line in Alert E-mail

2 messages in this thread

list Vpn Cluster · Wed, 10 Sep 2008 08:16:30 -0400 ·
How to customize the contents of the subject line in alerts and recovery
e-mails.
list Bill Arlofski · Wed, 10 Sep 2008 11:47:22 -0400 ·
quoted from Vpn Cluster
VPN Cluster wrote:
How to customize the contents of the subject line in alerts and recovery
e-mails.
Below is a simple/sample alert script I use.

Tell hobbit to use your script by editing your 
~hobbit/server/etc/hobbit-alerts.cfg file and set the recipient of your alerts 
to a SCRIPT instead of MAIL like so:

HOST=*
SCRIPT /usr/local/sbin/hobbit-alert.sh FORMAT=SCRIPT DURATION>5m REPEAT=2h


Here's my /usr/local/sbin/hobbit-alert.sh script. Modify as you see fit. The 
SUBJECT line in this email will wrap. Put it all on one line.
Hope this helps.


--[snip]--
#!/bin/bash
#
# waa - 20080325
# --------------
SM="/usr/bin/sendmail"
DATE=`date +%Y%m%d-%H%M%S`
FROM="From: ClientSiteName Hobbit Server <user-13290d8d6ccd@xymon.invalid>"
TO="To: user-13290d8d6ccd@xymon.invalid"
if [ "$RECOVERED" = "1" ]; then
  RECOVERED="(Recovered)"
  else
   RECOVERED=""
fi

SUBJECT="Subject: Hobbit Alert - ($BBCOLORLEVEL) $BBSVCNAME on $BBHOSTNAME at 
$DATE for $DOWNSECS seconds $RECOVERED"

MSG="$FROM\n$TO\n$SUBJECT\n\nDown for: $DOWNSECS Seconds\n\n$BBALPHAMSG\n"

echo -e "$MSG" | $SM -t
--[snip]--


--
Bill Arlofski
Reverse Polarity, LLC
http://www.revpol.com/
* Stop the NSA from illegally eavesdropping on your personal email *
Learn about PGP and start encrypting your email today
http://gnupg.org or http://www.pgp.com