monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trigger for asterisk log file


From: Martin Pala
Subject: Re: trigger for asterisk log file
Date: Mon, 21 Apr 2014 19:05:28 +0200

Hi,

if you want to send just email, you can use the "alert" action:

--8<--
set mailserver my.mailserver.com

set alert address@hidden

check file asterisk with path /var/log/asterisk/full
     if match "channel" then alert
--8<--

The script execution should work, but note, that until Monit 5.7 the programs 
were executed in a sandbox: environment variables were stripped and PATH 
replaced with spartan settings: "PATH=/bin:/usr/bin:/sbin:/usr/sbin". As you 
don't use absolute path for "mail" in the script, if the "mail" is not in the 
mentioned default PATH, then the script will fail - it is always better to use 
absolute paths. We have stopped this environment purging in Monit 5.8, as it 
was confusing for lot of users.

Also note, that Monit will fire the alert when it finds full LF terminated line 
in the file - if the line is not terminated, then Monit records the position 
and next time starts the check on this line again. If you test with some 
editor, put the pattern at the end of the file with no new line behind it, then 
Monit will skip it.

You can run Monit in debug mode and foreground to see the details:

        monit -vI


Regards,
Martin



On 21 Apr 2014, at 18:36, Jorge Bastos <address@hidden> wrote:

> Hum monit seems to be running as root, but already chmod’ed var + log + 
> asterisk , and tried again and nothing,
> Maybe there’s something wrong in my conf,
>  
> From: address@hidden [mailto:address@hidden On Behalf Of Phil Townes
> Sent: segunda-feira, 21 de Abril de 2014 17:13
> To: This is the general mailing list for monit
> Subject: Re: trigger for asterisk log file
>  
> Does the account monit is running under have permissions to read the asterisk 
> log file?
> 
> On 21 Apr 2014 16:50, "Jorge Bastos" <address@hidden> wrote:
> Ok no luck,
>  
> My script is under conf.d, and conf.d is included in monitrc, I changed the 
> script to contain an error and I was alerted about it so it’s being executed:
>  
> check file asterisk with path /var/log/asterisk/full
>      if match "channel" then exec /sbin/asterisk-alert-channels
>  
> /sbin/asterisk-alert-channels has:
> --
> #!/bin/sh
> echo "o canal XXX caiu" |mail -s "asterisk channel down" address@hidden
> --
>  
> Of course it’s chmod +x.
>  
> I manually tailed the asterisk log and removed and inserted some lines to 
> have the “channel” word in the logs, but nothing happened.
>  
> Any ideas?
>  
> From: address@hidden [mailto:address@hidden On Behalf Of Jorge Bastos
> Sent: segunda-feira, 21 de Abril de 2014 10:24
> To: 'This is the general mailing list for monit'
> Subject: RE: trigger for asterisk log file
>  
> Let me play J
>  
> From: address@hidden [mailto:address@hidden On Behalf Of Anthony Griffiths
> Sent: domingo, 20 de Abril de 2014 21:36
> To: This is the general mailing list for monit
> Subject: Re: trigger for asterisk log file
>  
> yes it is. I'm only a beginner with monit but I got it to do that.
> In the control file you could try this:
>  
> check file asterisk with path /path/to/asterisk/log
>      if match "<your word>" then exec "echo "<your message> | mailx -s "monit 
> detection" address@hidden"
>  
>  
> 
> On Sun, Apr 20, 2014 at 9:12 PM, Jorge Bastos <address@hidden> wrote:
> Hi,
>  
> Is monit able to send an email when certain word appears in asterisk’s log ?
>  
> Jorge,
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>  
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general




reply via email to

[Prev in Thread] Current Thread [Next in Thread]