[hobbit] alert question
Andy France
Andy at zespri.com
Thu May 29 12:47:55 CEST 2008
Hi again Ryan,
Are you testing via the standard hobbit alerting or from a shell? If
the latter, it may be because the RECOVERED environment is not set.
You could try changing the entry on line 30 to read ${RECOVERED:=1} so
that it has a value of 1 if it is not set (although you will probably
then run into further problems with BBCOLORLEVEL and BBALPHAMSG as
well!).
Otherwise, you will probably have to set the first line to "#!/bin/bash
-x" to get more detailed output of what the script is up to in the logs.
Andy.
________________________________
From: Ryan Jay B. Lapuz [mailto:rlapuz at fcpp.fujitsu.com]
Sent: Monday, 26 May 2008 12:05 p.m.
To: hobbit at hswn.dk
Subject: Re: [hobbit] alert question
Hi Galen,
I also use bash, (#!/bin/bash). My hobbit is version 2.4.0 w/ all-in-one
patch and is installed in Fedora Core 6
Thanks in advance!
----- Original Message -----
From: Galen Johnson <mailto:Galen.Johnson at sas.com>
To: hobbit at hswn.dk
Sent: Saturday, May 24, 2008 10:24 PM
Subject: RE: [hobbit] alert question
What shell have you set this to run as? Andy is using
bash...(#!/opt/csw/bi/bash)
=G=
From: Ryan Jay B. Lapuz [mailto:rlapuz at fcpp.fujitsu.com]
Sent: Saturday, May 24, 2008 5:18 AM
To: hobbit at hswn.dk
Subject: Re: [hobbit] alert question
Hi Andy,
There is a problem with my implementation, please refer to the
logs below:
error:
./htmlmail: line 30: [: =: unary operator expected
htmlmail:
(start of line 30)
if [ ${RECOVERED} = 1 ]
then
export BBCOLORLEVEL="RECOVERED"
export BBCOLOR="green"
else
export BBCOLOR=$BBCOLORLEVEL
fi
# Convert plain line breaks to HTML breaks
# export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
'/>$/!s/$/<BR>/'`"
# Convert Hobbit colour tags to embedded image tags
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&blue/<img
src="cid:blue.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&clear/<img
src="cid:clear.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&green/<img
src="cid:green.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&purple/<img
src="cid:purple.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&red/<img
src="cid:red.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&unknown/<img
src="cid:unknown.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's/&yellow/<img
src="cid:yellow.gif">/g'`"
# Fix link at base of message as they are removed in PLAIN
format
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed 's|http:.*|<a
href="&">&</a>|g'`"
# Run Perl script to generate email
/home/hobbit/server/bin/htmlmail.pl > /dev/null 2>&1
/var/log/hobbit/page.log:
Paging script /home/hobbit/server/bin/htmlmail terminated with
status 2
What seems to be the problem?
Thanks in advance!
Regards,
Ryan
----- Original Message -----
From: Andy France <mailto:Andy at zespri.com>
To: hobbit at hswn.dk
Sent: Friday, May 23, 2008 11:32 AM
Subject: RE: [hobbit] alert question
Hi Ryan,
Here's what I use, in three parts:
FIRST: The mail script /opt/hobbit/bin/htmlmail
#!/opt/csw/bin/bash
#
# Script get the following environment variables
pre-defined so
# that they can send a meaningful alert:
#
# BBCOLORLEVEL - The current color of the
status
# BBALPHAMSG - The full text of the status
log triggering the alert
# ACKCODE - The "cookie" that can be
used to acknowledge the alert
# RCPT - The recipient, from the
SCRIPT entry
# BBHOSTNAME - The name of the host that
the alert is about
# MACHIP - The IP-address of the host
that has a problem
# BBSVCNAME - The name of the service
that the alert is about
# BBSVCNUM - The numeric code for the
service. From SVCCODES definition.
# BBHOSTSVC - HOSTNAME.SERVICE that the
alert is about.
# BBHOSTSVCCOMMAS - As BBHOSTSVC, but dots in
the hostname replaced with commas
# BBNUMERIC - A 22-digit number made by
BBSVCNUM, MACHIP and ACKCODE.
# RECOVERED - Is "1" if the service has
recovered.
# EVENTSTART - Timestamp when the current
status (color) began
# DOWNSECS - Number of seconds the
service has been down.
# DOWNSECSMSG - When recovered, holds the
text "Event duration : N" where
# N is the DOWNSECS value.
# CFID - Line-number in the
hobbit-alerts.cfg file that caused the script to be invoked.
# Can be useful when
troubleshooting alert configuration rules
#
# Minumum hobbit-alerts.cfg entry -
# SCRIPT /opt/hobbit/bin/htmlmail support
FORMAT=PLAIN
#
if [ ${RECOVERED} = 1 ]
then
export BBCOLORLEVEL="RECOVERED"
export BBCOLOR="green"
else
export BBCOLOR=$BBCOLORLEVEL
fi
# Convert plain line breaks to HTML breaks
# export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
'/>$/!s/$/<BR>/'`"
# Convert Hobbit colour tags to embedded image
tags
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&blue/<img src="cid:blue.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&clear/<img src="cid:clear.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&green/<img src="cid:green.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&purple/<img src="cid:purple.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&red/<img src="cid:red.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&unknown/<img src="cid:unknown.gif">/g'`"
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's/&yellow/<img src="cid:yellow.gif">/g'`"
# Fix link at base of message as they are
removed in PLAIN format
export BBALPHAMSG="`echo \"$BBALPHAMSG\" | sed
's|http:.*|<a href="&">&</a>|g'`"
# Run Perl script to generate email
/opt/hobbit/bin/htmlmail.pl > /dev/null 2>&1
SECOND: The perl script to format and send the message
/opt/hobbit/bin/htmlmail.pl
#!/opt/csw/bin/perl -w
use strict;
use MIME::Lite;
my $rcpt = $ENV{'RCPT'};
my $bbhostsvc = $ENV{'BBHOSTSVC'};
my $bbcolorlevel = $ENV{'BBCOLORLEVEL'};
my $bbalphamsg = $ENV{'BBALPHAMSG'};
my $subject = $bbhostsvc . " " . $bbcolorlevel;
my $htmldata = join("",
"<BODY BGCOLOR=\"#FFFFFF\"
TEXT=\"#000000\" LINK=\"#0000FF\" ALINK =\"#FF0000\"
VLINK=\"#800080\">\n",
"<FONT FACE=\"Tahoma, Arial, Helvetica\"
SIZE=\"3\">\n",
"<PRE>\n",
$bbalphamsg,
"\n",
"</PRE>\n",
"</FONT>\n",
"</BODY>"
);
my $msg = MIME::Lite->new
(
Subject => $subject,
To => $rcpt,
Type => 'multipart/related'
);
$msg->attach
(
Type => 'text/html',
Data => $htmldata,
);
if($htmldata =~ m/blue.gif/)
{$msg->attach(Type => 'image/gif', Id =>
'blue.gif', Path => '/opt/hobbit/server/www/gifs/blue.gif')}
if($htmldata =~ m/clear.gif/)
{$msg->attach(Type => 'image/gif', Id =>
'clear.gif', Path => '/opt/hobbit/server/www/gifs/clear.gif')}
if($htmldata =~ m/green.gif/)
{$msg->attach(Type => 'image/gif', Id =>
'green.gif', Path => '/opt/hobbit/server/www/gifs/green.gif')}
if($htmldata =~ m/purple.gif/)
{$msg->attach(Type => 'image/gif', Id =>
'purple.gif', Path => '/opt/hobbit/server/www/gifs/purple.gif')}
if($htmldata =~ m/red.gif/)
{$msg->attach(Type => 'image/gif', Id =>
'red.gif', Path => '/opt/hobbit/server/www/gifs/red.gif')}
if($htmldata =~ m/yellow.gif/)
{$msg->attach(Type => 'image/gif', Id =>
'yellow.gif', Path => '/opt/hobbit/server/www/gifs/yellow.gif')}
$msg->send();
THIRD: Configure your hobbit-alerts.cfg lines like
this:
SCRIPT /opt/hobbit/bin/htmlmail
Someone at nowhere.com FORMAT=TEXT
You will obviously need to adjust all of the paths to
suit your installation! And don''t forget to check you have the
MIME::Lite perl module and whatever other dependencies it requires.
HTH,
Andy.
________________________________
From: Ryan Jay B. Lapuz [mailto:rlapuz at fcpp.fujitsu.com]
Sent: Friday, 23 May 2008 3:15 p.m.
To: hobbit at hswn.dk
Subject: Re: [hobbit] alert question
Thanks for the quick reply!
Make a custom script; can someone share me the their
script and teach me how to configure it?
Thanks in advance!
Regards.
Ryan
----- Original Message -----
From: Josh Luthman
<mailto:josh at imaginenetworksllc.com>
To: hobbit at hswn.dk
Sent: Friday, May 23, 2008 11:01 AM
Subject: Re: [hobbit] alert question
Pretty sure you'll have to create a custom
script and put in the HTML code in the data section of your email. To
my knowledge you can't simply stick in text in the alert Hobbit sends.
On Thu, May 22, 2008 at 10:57 PM, Ryan Jay B.
Lapuz <rlapuz at fcpp.fujitsu.com> wrote:
Hi all!
Just a follow up newbie question.
How can I make hobbit to send me alerts with
icon like that alert below?
I am receiving alerts like this:
&yellow Warnings in <a
href="/hobbit-cgi/bb-hostsvc.sh?CLIENT=HOST&SECTION=msgs:/var/adm/me
ssages">/var/adm/messages</a>
Hobbit 4.2.0 w/ all-in-one patch instaled in
Fedora Core 6
________________________________
Listener LISTENER_RMAN1 UP
Listener LISTENER DOWN
Listener LISTENER DOWN
#####################################################################################
This email is intended for the person to whom it is addressed
only. If you are not the intended recipient, do not read, copy
or use the contents in any way. The opinions expressed may not
necessarily reflect those of ZESPRI Group of Companies ('ZESPRI').
While every effort has been made to verify the information
contained herein, ZESPRI does not make any representations
as to the accuracy of the information or to the performance
of any data, information or the products mentioned herein.
ZESPRI will not accept liability for any losses, damage or
consequence, however, resulting directly or indirectly from
the use of this e-mail/attachments.
#####################################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20080529/1c164901/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 118 bytes
Desc: image001.gif
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20080529/1c164901/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.gif
Type: image/gif
Size: 1579 bytes
Desc: image002.gif
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20080529/1c164901/attachment-0001.gif>
More information about the Xymon
mailing list