Xymon Mailing List Archive search

Sending email alerts for xymon

3 messages in this thread

list Raghuv Adhepalli · Thu, 26 Jul 2012 05:19:13 +0800 (SGT) ·
Hello,

I am trying to use the xymon alert system to send emails.

When I use "MAIL", I am able to receive the mails as they were intended.
HOST=* SERVICE=* COLOR=yellow
        MAIL user-342b4930477d@xymon.invalid


But, the problem occurs when I start using the "SCRIPT". The mails aren't being forwarded

HOST=* SERVICE=* COLOR=yellow
        SCRIPT test.sh user-342b4930477d@xymon.invalid

I understand that the "SCRIPT" uses two arguments, the script name and the recipient name.

Here's how my script looks like,

*****************************************************************
#!bin/bash

mail -s "$BBALPHAMSG $BBHOSTNAME $MACHIP $BBSVCNAME $RECOVERED" $RCPT

*****************************************************************


Can anyone please explain to me a bit more on how the alert system works when the "SCRIPT" is used?

Thanks you
Raghuv Adhepalli.

ps: I encountered the same problem when I tried using "mutt" instead of "mail" in my script. When I use "mutt" as a command on my terminal the command works, but it doesn't work when I use it with "SCRIPT"
list Henrik Størner · Wed, 25 Jul 2012 23:29:44 +0200 ·
quoted from Raghuv Adhepalli
On 25-07-2012 23:19, Raghuv adhepalli wrote:
Hello,

I am trying to use the xymon alert system to send emails.

When I use "MAIL", I am able to receive the mails as they were intended.
HOST=* SERVICE=* COLOR=yellow
         MAIL user-342b4930477d@xymon.invalid

But, the problem occurs when I start using the "SCRIPT". The mails
aren't being forwarded

HOST=* SERVICE=* COLOR=yellow
         SCRIPT test.sh user-342b4930477d@xymon.invalid

I understand that the "SCRIPT" uses two arguments, the script name and
the recipient name.

Here's how my script looks like,

*****************************************************************
#!bin/bash

mail -s "$BBALPHAMSG $BBHOSTNAME $MACHIP $BBSVCNAME $RECOVERED" $RCPT

*****************************************************************
I don't really understand why you are not using MAIL in alerts.cfg then.
quoted from Raghuv Adhepalli
Can anyone please explain to me a bit more on how the alert system works
when the "SCRIPT" is used?
Check the alert.log logfile, it should log whatever error-message the 
alert-script generates (if any). I suspect that your "mail" utility 
drops messages with no message body.

So I wouldn't put $BBALPHAMSG in the subject of a mail. Better to put it 
into the mail body, e.g.

echo "$BBALPHSMSG" | mail -s "$BBHOSTNAME $MACHIP $BBSVCNAME $RECOVERED" 
$RCPT


Regards,
Henrik
list Tim McCloskey · Wed, 25 Jul 2012 14:47:57 -0700 ·
quoted from Henrik Størner
From: xymon-bounces at xymon.com [xymon-bounces at xymon.com] On Behalf Of Henrik Størner [user-ce4a2c883f75@xymon.invalid]
Sent: Wednesday, July 25, 2012 2:29 PM
To: xymon at xymon.com
Subject: Re: [Xymon] Sending email alerts for xymon

On 25-07-2012 23:19, Raghuv adhepalli wrote:
Hello,

I am trying to use the xymon alert system to send emails.

When I use "MAIL", I am able to receive the mails as they were intended.
HOST=* SERVICE=* COLOR=yellow
         MAIL user-342b4930477d@xymon.invalid

But, the problem occurs when I start using the "SCRIPT". The mails
aren't being forwarded

HOST=* SERVICE=* COLOR=yellow
         SCRIPT test.sh user-342b4930477d@xymon.invalid

I understand that the "SCRIPT" uses two arguments, the script name and
the recipient name.

Here's how my script looks like,

*****************************************************************
#!bin/bash

mail -s "$BBALPHAMSG $BBHOSTNAME $MACHIP $BBSVCNAME $RECOVERED" $RCPT

*****************************************************************
I don't really understand why you are not using MAIL in alerts.cfg then.
Can anyone please explain to me a bit more on how the alert system works
when the "SCRIPT" is used?
Check the alert.log logfile, it should log whatever error-message the
alert-script generates (if any). I suspect that your "mail" utility
drops messages with no message body.

So I wouldn't put $BBALPHAMSG in the subject of a mail. Better to put it
into the mail body, e.g.

echo "$BBALPHSMSG" | mail -s "$BBHOSTNAME $MACHIP $BBSVCNAME $RECOVERED"
$RCPT


Regards,
Henrik


Here is another example.  I have some old rules that are used to send simple alerts without the fluff.  Then, I have some rules for folks that like all of the $BBvars.  What I did for a simple alert follows.  I know there are other ways but this works fine for me.  In the info screen the recipient will show up as the name 'web-mail-prim' in this example.  So, really the recipient is not coming out of the alert config, it's from the shell script which is in turn controlled by another widget in cron.

(alerts)
PAGE=%^somepage/(linux|solaris) EXSERVICE=conn COLOR=red DURATION>6m 
SCRIPT $alertdir/morepathinfo/mail-primary.sh mail-web-prim FORMAT=sms  REPEAT=1h


(mail-primary.sh)
#!/bin/bash

/bin/mail -s "$BBHOSTSVC" user-c936774e58ff@xymon.invalid < /dev/null