Xymon Mailing List Archive search

alert question

12 messages in this thread

list Ryan Jay B. Lapuz · Fri, 23 May 2008 10:57:16 +0800 ·
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&amp;SECTION=msgs:/var/adm/messages">/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
list Josh Luthman · Thu, 22 May 2008 23:01:29 -0400 ·
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 <user-945139049f37@xymon.invalid>
quoted from Ryan Jay B. Lapuz
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&amp;SECTION=msgs:/var/adm/messages">/var/adm/messages</a>
*Hobbit 4.2.0 w/ all-in-one patch instaled in Fedora Core 6*


   [image: green] Listener LISTENER_RMAN1 UP

   [image: red] Listener LISTENER DOWN


   [image: red] Listener LISTENER DOWN

-- 
Josh Luthman
Office: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer
list Ryan Jay B. Lapuz · Fri, 23 May 2008 11:14:40 +0800 ·
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
quoted from Josh Luthman
  ----- Original Message ----- 
  From: Josh Luthman 
  To: user-ae9b8668bcde@xymon.invalid 
  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 <user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/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


  -- 
  Josh Luthman
  Office: XXX-XXX-XXXX
  Direct: XXX-XXX-XXXX
  XXXX Wayne St
  Suite XXXX
  Troy, OH XXXXX

  Those who don't understand UNIX are condemned to reinvent it, poorly.
  --- Henry Spencer
list Josh Luthman · Thu, 22 May 2008 23:19:18 -0400 ·
Here is some (well..only one =) custom alert scripts:

http://www.trantor.org/theshire/doku.php/alerts

On Thu, May 22, 2008 at 11:14 PM, Ryan Jay B. Lapuz <user-945139049f37@xymon.invalid>
quoted from Ryan Jay B. Lapuz
wrote:
 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 <user-4c45a83f15cb@xymon.invalid>
quoted from Ryan Jay B. Lapuz
*To:* user-ae9b8668bcde@xymon.invalid
*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 <
user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/var/adm/messages</a>
*Hobbit 4.2.0 w/ all-in-one patch instaled in Fedora Core 6*


   [image: green] Listener LISTENER_RMAN1 UP

   [image: red] Listener LISTENER DOWN


   [image: red] Listener LISTENER DOWN

--
Josh Luthman
Office: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer

-- 
Josh Luthman
Office: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer
list Andy France · Fri, 23 May 2008 15:32:37 +1200 ·
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 user-6560a5452968@xymon.invalid 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.
quoted from Ryan Jay B. Lapuz
 

From: Ryan Jay B. Lapuz [mailto:user-945139049f37@xymon.invalid] 
Sent: Friday, 23 May 2008 3:15 p.m.
To: user-ae9b8668bcde@xymon.invalid
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:user-4c45a83f15cb@xymon.invalid>  
	To: user-ae9b8668bcde@xymon.invalid 
	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 <
user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/me
ssages">/var/adm/messages</a>
quoted from Josh Luthman
		
		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.
#####################################################################################
list Phil Wild · Fri, 23 May 2008 11:34:07 +0800 ·
Have a read of the hobbit-alerts man page to get you staretd on how alert
scripts work.

Your script will need to read in the message from the environment variable
and do a replace of all the found &colour strings with a URL to each of the
coloured gifs from the hobbit web server. You may need to ensure the message
is sent as a valid html message etc so it works in your email client.

You will also need to reproduce the subject line etc using the env variables
that hobbit defines.

Cheers

Phil


2008/5/23 Josh Luthman <user-4c45a83f15cb@xymon.invalid>:
quoted from Andy France
Here is some (well..only one =) custom alert scripts:

http://www.trantor.org/theshire/doku.php/alerts


On Thu, May 22, 2008 at 11:14 PM, Ryan Jay B. Lapuz <
user-945139049f37@xymon.invalid> wrote:
 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 <user-4c45a83f15cb@xymon.invalid>
*To:* user-ae9b8668bcde@xymon.invalid
*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 <
user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/var/adm/messages</a>
*Hobbit 4.2.0 w/ all-in-one patch instaled in Fedora Core 6*


   [image: green] Listener LISTENER_RMAN1 UP

   [image: red] Listener LISTENER DOWN


   [image: red] Listener LISTENER DOWN

--
Josh Luthman
Office: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer

--
Josh Luthman
Office: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer
-- 

Tel: XXXX XXX XXX
Fax: XXXX XXX XXX
email: user-e365c1418192@xymon.invalid
list Ryan Jay B. Lapuz · Fri, 23 May 2008 12:22:24 +0800 ·
Hi Phil, Thanks for your help.

Hi Andy, Thank you for the script, I'll try to set it up first to my hobbit backup server.

Regards to all,
Ryan
quoted from Andy France
  ----- Original Message ----- 
  From: Andy France 
  To: user-ae9b8668bcde@xymon.invalid 
  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 user-6560a5452968@xymon.invalid 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:user-945139049f37@xymon.invalid] 
  Sent: Friday, 23 May 2008 3:15 p.m.
  To: user-ae9b8668bcde@xymon.invalid
  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 
    To: user-ae9b8668bcde@xymon.invalid 
    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 <user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/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.
  #####################################################################################
list Ryan Jay B. Lapuz · Sat, 24 May 2008 17:18:07 +0800 ·
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)
quoted from Ryan Jay B. Lapuz
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?
quoted from Ryan Jay B. Lapuz

Thanks in advance!

Regards,
Ryan
  ----- Original Message ----- 
  From: Andy France 
  To: user-ae9b8668bcde@xymon.invalid 
  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 user-6560a5452968@xymon.invalid 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:user-945139049f37@xymon.invalid] 
  Sent: Friday, 23 May 2008 3:15 p.m.
  To: user-ae9b8668bcde@xymon.invalid
  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 
    To: user-ae9b8668bcde@xymon.invalid 
    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 <user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/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.
  #####################################################################################
list Galen Johnson · Sat, 24 May 2008 10:24:48 -0400 ·
What shell have you set this to run as?  Andy is using bash...(#!/opt/csw/bi/bash)

=G=
quoted from Ryan Jay B. Lapuz

From: Ryan Jay B. Lapuz [mailto:user-945139049f37@xymon.invalid]
Sent: Saturday, May 24, 2008 5:18 AM
To: user-ae9b8668bcde@xymon.invalid
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:user-ee2a9e4eaf57@xymon.invalid>
To: user-ae9b8668bcde@xymon.invalid<mailto:user-ae9b8668bcde@xymon.invalid>
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 user-6560a5452968@xymon.invalid<mailto:user-6560a5452968@xymon.invalid> FORMAT=TEXT
quoted from Ryan Jay B. Lapuz
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:user-945139049f37@xymon.invalid]
Sent: Friday, 23 May 2008 3:15 p.m.
To: user-ae9b8668bcde@xymon.invalid
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:user-4c45a83f15cb@xymon.invalid>
To: user-ae9b8668bcde@xymon.invalid<mailto:user-ae9b8668bcde@xymon.invalid>
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 <user-945139049f37@xymon.invalid<mailto:user-945139049f37@xymon.invalid>> 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&amp;SECTION=msgs:/var/adm/messages">/var/adm/messages</a>
Hobbit 4.2.0 w/ all-in-one patch instaled in Fedora Core 6


   [cid:image001.gif at 01C8BD88.64EC2A60]  Listener LISTENER_RMAN1 UP

   [cid:image002.gif at 01C8BD88.64EC2A60]  Listener LISTENER DOWN


   [cid:image002.gif at 01C8BD88.64EC2A60]  Listener LISTENER DOWN
quoted from Ryan Jay B. Lapuz


#####################################################################################

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.
#####################################################################################
list Ryan Jay B. Lapuz · Mon, 26 May 2008 08:05:02 +0800 ·
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!
quoted from Galen Johnson

----- Original Message ----- 
  From: Galen Johnson 
  To: user-ae9b8668bcde@xymon.invalid 
  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:user-945139049f37@xymon.invalid] 
  Sent: Saturday, May 24, 2008 5:18 AM
  To: user-ae9b8668bcde@xymon.invalid
  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 

    To: user-ae9b8668bcde@xymon.invalid 

    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 user-6560a5452968@xymon.invalid 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:user-945139049f37@xymon.invalid] 
    Sent: Friday, 23 May 2008 3:15 p.m.
    To: user-ae9b8668bcde@xymon.invalid
    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 

      To: user-ae9b8668bcde@xymon.invalid 

      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 <user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/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.
    #####################################################################################
list Andy France · Thu, 29 May 2008 22:47:55 +1200 ·
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.
quoted from Ryan Jay B. Lapuz
 
Andy.


From: Ryan Jay B. Lapuz [mailto:user-945139049f37@xymon.invalid] 
Sent: Monday, 26 May 2008 12:05 p.m.
To: user-ae9b8668bcde@xymon.invalid
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:user-87f955643e3d@xymon.invalid>  
	To: user-ae9b8668bcde@xymon.invalid 
	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:user-945139049f37@xymon.invalid] 
	Sent: Saturday, May 24, 2008 5:18 AM
	To: user-ae9b8668bcde@xymon.invalid
	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:user-ee2a9e4eaf57@xymon.invalid>  

		To: user-ae9b8668bcde@xymon.invalid 

		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 
user-6560a5452968@xymon.invalid 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:user-945139049f37@xymon.invalid]

		Sent: Friday, 23 May 2008 3:15 p.m.
		To: user-ae9b8668bcde@xymon.invalid
		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

			To: user-ae9b8668bcde@xymon.invalid 

			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 <user-945139049f37@xymon.invalid> 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&amp;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.
#####################################################################################
list Ryan Jay B. Lapuz · Fri, 30 May 2008 14:31:44 +0800 ·
Hi Andy,

Thanks for your help.

Now, I am receiving alerts like this:

subj: HOST.msgs yellow

yellow System logs at Fri May 30 10:46:18 HKT 2008


 Warnings in /var/adm/sulog
 SU 05/30 10:11 + pts/11 user-root


No entries in /var/adm/messages


Full log /var/adm/messages

Full log /var/adm/sulog
SU 05/30 10:11 + pts/11 user-root

See http://hobbit/hobbit-cgi/bb-hostsvc.sh?HOST=host&SERVICE=msgs
and;

subj: HOST.msgs RECOVERED

green System logs at Fri May 30 10:51:20 HKT 2008


No entries in /var/adm/messages

No entries in /var/adm/sulog


Full log /var/adm/messages

Full log /var/adm/sulog

See http://hobbit/hobbit-cgi/bb-hostsvc.sh?HOST=HOST&SERVICE=msgs

Is this the normal email alert from your script?

Thanks again and regards,
quoted from Andy France
Ryan

  ----- Original Message ----- 
  From: Andy France 
  To: user-ae9b8668bcde@xymon.invalid 
  Sent: Thursday, May 29, 2008 6:47 PM
  Subject: RE: [hobbit] alert question


  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:user-945139049f37@xymon.invalid] 
  Sent: Monday, 26 May 2008 12:05 p.m.
  To: user-ae9b8668bcde@xymon.invalid
  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 
    To: user-ae9b8668bcde@xymon.invalid 
    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:user-945139049f37@xymon.invalid] 
    Sent: Saturday, May 24, 2008 5:18 AM
    To: user-ae9b8668bcde@xymon.invalid
    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 

      To: user-ae9b8668bcde@xymon.invalid 

      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 user-6560a5452968@xymon.invalid 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:user-945139049f37@xymon.invalid] 
      Sent: Friday, 23 May 2008 3:15 p.m.
      To: user-ae9b8668bcde@xymon.invalid
      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 

        To: user-ae9b8668bcde@xymon.invalid 

        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 <user-945139049f37@xymon.invalid> 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&amp;SECTION=msgs:/var/adm/messages">/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.
  #####################################################################################