[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [hobbit] How to customize the subject line in Alert E-mail



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 <some-email (at) example.com>"
TO="To: some-email (at) example.com"
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