[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mailformat question
From: |
Martin Pala |
Subject: |
Re: Mailformat question |
Date: |
Mon, 28 Mar 2005 22:15:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050324 Debian/1.7.6-1 |
The new-line problem is caused in this mail handling code:
--8<--
do_send(&S, "%s\r\n", m->message);
if(m->opt_message) {
do_send(&S, "%s\r\n", m->opt_message);
}
--8<--
The optional event description (opt_message) is independent of
mail-format string and it is included after the mail-format message on
new line.
The result of the following mail-format message option:
--8<--
set mail-format { message: $EVENT $SERVICE at $DATE on $HOST }
--8<--
is for example:
--8<--
Data access error vfatfs at Mon, 28 Mar 2005 21:52:33 +0200 on unicorn
'vfatfs' unable to read device /dev/hda6 state
--8<--
... as you can see, the first line corresponds to the format string, but
the second line is extra one (not specified in format string).
We can maybe fix it by consolidation of message and opt_message data ...
by introduction of new event description token (for example
$EVENT_DESCRIPTION) and using it instead of explicit inclusion (it will
be needed to change default message format template ALERT_MESSAGE in
alert.h too). You one-line message format which will include event
description will then look for example like this:
--8<--
... { message: $EVENT $SERVICE at $DATE on $HOST - $EVENT_DESCRIPTION }
--8<--
$ACTION token in mail-format is supported since monit-4.3, i have tested
it on current cvs version (upcomming monit-4.5) ... it works well. You
may maybe want to try monit-4.5 beta
(http://www.tildeslash.com/monit/dist/beta/) and test it.
Martin
Christian Schoepplein wrote:
Hello!
On Sa, Mär 26, 2005 at 08:19:57 +0100, Martin Pala wrote:
You can use custom message format - see monit manual:
http://www.tildeslash.com/monit/doc/manual.php#alert_message_layout
Thanks for this link, but I've changed the default mailformat already.
It looks like this:
set mail-format {
from: address@hidden
subject: $SERVICE $EVENT at $DATE
message: $EVENT $SERVICE at $DATE on $HOST
}
But that doesn't solve my problem :-(.
Christian Schoepplein wrote:
[...]
mail2sms gateway. The mail2sms service seems to ignore new lines in a
message, it looks like \n is not working correctly.
Example: I recived a warning on a failed connection test per mail and
sms. The mail looks like this:
Connection test failed foo.tld at Fri, 25 Mar 2005 05:29:48 +0100 on
bar.tld
Event: 'foo.tld' failed, cannot open a connection to
INET[www.foo.tld:80]
The question is, what causes the last line in the example above:
Event: 'foo.tld' failed, cannot open a connection to
INET[www.foo.tld:80]
I think this can't be triggered via the mail-format settings. This line
is insertet with a line break in the alert and this line break and the
following text is ignored by the mail2sms gateway. So the sms looks like
this:
Connection test failed foo.tld at Fri, 25 Mar 2005 05:29:48 +0100 on
bar.tld
The line with the event gets lost :-(. I have to avoid line breaks in
the alerts, that would solve the problem. Or
BTW.: The $ACTION variable doesn't work with my monit version too :-(.
It causes a syntax error. Is this a known problem and is it fixed in
newer releases?