Xymon Mailing List Archive search

removing <!-- [flags:ordAstLe] > from custom email script

4 messages in this thread

list Usa Ims · Wed, 1 Oct 2014 08:19:03 -0700 ·
Hi,

My boss didn't like the subject line of the default email alerts and he asked me to change it.

I found a script online that does it -- so I modified the script and the subject line is doing what is expected but the body of the email is displaying some text that I would like not to be displayed.

How can I remove the " red [965282] red <!-- [flags:ordAstLe] >" or more importantly "<!-- [flags:ordAstLe] >"?

Here is the script: 

#!/bin/bash

SM="/usr/sbin/sendmail"
DATE=`date +%Y%m%d-%H%M%S`
FROM="From: Xymon Server <user-d20034f1156f@xymon.invalid>"
TO="To:user-e1be9155d8fc@xymon.invalid"

     if [ "$RECOVERED" = "1" ]; then
     RECOVERED="(Recovered)"
     else
     RECOVERED=""
     fi

SUBJECT="Subject: D0 BIG BROTHER ALERT - $BBSVCNAME test on $BBHOSTNAME"  


MSG="$FROM\n$TO\n$SUBJECT\n\n\n\n$BBALPHAMSG\n"


echo -e "$MSG" | $SM -t
#####################################################

On a 'conn' test, it is displaying:

xxxxxxx.corp.local:conn red [965282] red <!-- [flags:ordAstLe] --> Wed Oct  1 10:46:24 2014 conn NOT ok 

Service conn on xxxxxxx.corp.local is not OK : Host does not respond to ping


System unreachable for 20 poll periods (5386 seconds)

&red 5.5.5.5 is unreachable

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

Is there anyway to remove that? Thanks in advance.

usaims
list Jeremy Laidman · Thu, 2 Oct 2014 18:36:28 +1000 ·
There's probably a better solution to this problem. But you could get by
with this:

NEWMSG=`echo "$BBALPHAMSG" | sed 's/<!--[^>]*>//'`
MSG="$FROM\n$TO\n$SUBJECT\n\n\n\n$NEWMSG\n"

J
 On 02/10/2014 1:24 AM, "usa ims via Xymon" <xymon at xymon.com> wrote:
---------- Forwarded message ----------
From: usa ims <user-42bb6445007b@xymon.invalid>
To: xymon at xymon.com
Cc:
Date: Wed, 1 Oct 2014 08:19:03 -0700
Subject: removing <!-- [flags:ordAstLe] > from custom email script
quoted from Usa Ims
Hi,

My boss didn't like the subject line of the default email alerts and he
asked me to change it.

I found a script online that does it -- so I modified the script and the
subject line is doing what is expected but the body of the email is
displaying some text that I would like not to be displayed.

How can I remove the " red [965282] red <!-- [flags:ordAstLe] >" or more
importantly "<!-- [flags:ordAstLe] >"?

Here is the script:

#!/bin/bash

SM="/usr/sbin/sendmail"
DATE=`date +%Y%m%d-%H%M%S`
FROM="From: Xymon Server <user-d20034f1156f@xymon.invalid>"
TO="To:user-e1be9155d8fc@xymon.invalid"

     if [ "$RECOVERED" = "1" ]; then
     RECOVERED="(Recovered)"
     else
     RECOVERED=""
     fi

SUBJECT="Subject: D0 BIG BROTHER ALERT - $BBSVCNAME test on $BBHOSTNAME"


MSG="$FROM\n$TO\n$SUBJECT\n\n\n\n$BBALPHAMSG\n"


echo -e "$MSG" | $SM -t
#####################################################

On a 'conn' test, it is displaying:

xxxxxxx.corp.local:conn red [965282] red <!-- [flags:ordAstLe] --> Wed
Oct  1 10:46:24 2014 conn NOT ok

Service conn on xxxxxxx.corp.local is not OK : Host does not respond to
ping


System unreachable for 20 poll periods (5386 seconds)

&red 5.5.5.5 is unreachable

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

Is there anyway to remove that? Thanks in advance.

usaims

list Jeremy Laidman · Fri, 3 Oct 2014 07:52:33 +1000 ·
Have you tried using FORMAT=SMS on alerts.cfg?

Or try this in your script:

NEWMSG=`echo "$BBALPHAMSG" | grep -v '<!--[^>]*>'`

J
On 03/10/2014 12:19 AM, "usa ims" <user-42bb6445007b@xymon.invalid> wrote:
Hey Jeremy -- I'm Rod with Boca Raton, Florida USA.

Thanks for the advice. Is there any way to eliminate that whole line?

Here is the output of one test:
###
10.204.40.148:BobProd red [0]
green

            BIG BROTHER MESSAGE
            DATACENTER : D0
            HOSTNAME : 10.x.x.x
            STATE : Normal
            STATUS : Green
            TEST : BobProd EchoTest
            RESPONSE SUCCEEDED : 7.628518237 sec
            IP : 10.xxx.xxx.xxx
            EVENT TIME : Wed 01 Oct 2014 03:35:24 PM EDT


See
http://localhost/xymon-cgi/svcstatus.sh?HOST=10.204.40.148&SERVICE=BobProd
###

It would be nice to eliminate "10.xxx.xxx.xxx:BobProd red [0]"

list Rodney Simioni · Thu, 2 Oct 2014 23:16:22 +0000 ·
Jeremy,
NEWMSG=`echo "$BBALPHAMSG" | grep -v '<!--[^>]*>'`

Worked! Thanks!

Rod
quoted from Jeremy Laidman

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jeremy Laidman
Sent: Thursday, October 02, 2014 5:53 PM
To: usa ims; xymon at xymon.com
Subject: Re: [Xymon] removing <!-- [flags:ordAstLe] > from custom email script


Have you tried using FORMAT=SMS on alerts.cfg?

Or try this in your script:

NEWMSG=`echo "$BBALPHAMSG" | grep -v '<!--[^>]*>'`

J
On 03/10/2014 12:19 AM, "usa ims" <user-42bb6445007b@xymon.invalid<mailto:user-42bb6445007b@xymon.invalid>> wrote:
Hey Jeremy -- I'm Rod with Boca Raton, Florida USA.

Thanks for the advice. Is there any way to eliminate that whole line?

Here is the output of one test:
###
10.204.40.148:BobProd red [0]
green

            BIG BROTHER MESSAGE
            DATACENTER : D0
            HOSTNAME : 10.x.x.x
            STATE : Normal
            STATUS : Green
            TEST : BobProd EchoTest
            RESPONSE SUCCEEDED : 7.628518237 sec
            IP : 10.xxx.xxx.xxx
            EVENT TIME : Wed 01 Oct 2014 03:35:24 PM EDT


See http://localhost/xymon-cgi/svcstatus.sh?HOST=10.204.40.148&SERVICE=BobProd
###

It would be nice to eliminate "10.xxx.xxx.xxx:BobProd red [0]"