[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Monit and SQL query
From: |
Jan-Henrik Haukeland |
Subject: |
Re: Monit and SQL query |
Date: |
Sun, 16 Sep 2012 17:20:31 +0200 |
Yes, more or less. To have Monit send an alert message that is printed from
your script, follow this receipt
1) Add a custom mail format to the check, where the message body is just
$DESCRIPTION:
check program foo with path "/path/to/foo.sh"
alert address@hidden mail-format { message: $DESCRIPTION }
if status != 0 then alert
2) Make your script write the error message you want to send to stderr. Here is
a demo script I used to test this:
foo.sh:
#!/bin/bash
echo 1>&2 "Hello this is an error message from $0";
exit 1;
3) The alert mail you get from Monit will look something like this.
status failed (1) for /path/to/foo.sh -- Error: Hello this is an error message
from /path/to/foo.sh
The prefix 'status failed (1) for /path/to/foo.sh -- Error: ' is hardcoded in
validate.c:check_program and if it bothers you, just remove the prefix.
That is replace this line
Event_post(s, Event_Status, STATE_FAILED, status->action, "status failed
(%d) for %s -- Error: %s..", s->program->exitStatus, s->path, buf);
With this one:
Event_post(s, Event_Status, STATE_FAILED, status->action, "%s", buf);
and recompile Monit.
Hope this helps.
On Sep 16, 2012, at 4:33 PM, Charles Pino <address@hidden> wrote:
> i had it somehow working, but the alerts message / email is somewhat not
> really nice to look at.
>
>
> Status failed Service foo
>
> Date: Sun, 16 Sep 2012 21:12:38
> Action: alert
> Host: orecx
> Description: status failed (1) for /root/mysql.py. Error: 1
> .
>
> Your faithful employee,
> Monit
>
>
> my question is. can i change the status failed service to my own message? as
> well as
> Description: status failed (1) for /root/mysql.py. Error: 1 -- id like to
> have it say that the db hasnt been any writes in the past 12 hrs etc etc.
- Monit and SQL query, (continued)
- Monit and SQL query, Charles Pino, 2012/09/09
- Re: Monit and SQL query, Martin Pala, 2012/09/10
- RE: Monit and SQL query, Charles Pino, 2012/09/10
- Re: Monit and SQL query, Nestor Urquiza, 2012/09/10
- RE: Monit and SQL query, Charles Pino, 2012/09/11
- RE: Monit and SQL query, Callum Macdonald, 2012/09/11
- RE: Monit and SQL query, Charles Pino, 2012/09/11
- Re: Monit and SQL query, Nestor Urquiza, 2012/09/11
- RE: Monit and SQL query, Charles Pino, 2012/09/16
- RE: Monit and SQL query, Charles Pino, 2012/09/16
- Re: Monit and SQL query,
Jan-Henrik Haukeland <=
- RE: Monit and SQL query, Charles Pino, 2012/09/16
- Re: Monit and SQL query, Nestor Urquiza, 2012/09/17
- Re: Monit and SQL query, Callum Macdonald, 2012/09/17
- RE: Monit and SQL query, Charles Pino, 2012/09/17
- Re: Monit and SQL query, Jan-Henrik Haukeland, 2012/09/17
- RE: Monit and SQL query, Charles Pino, 2012/09/18