[Top][All Lists]

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

Re: sending a custom email on text-string match

From: Martin Pala
Subject: Re: sending a custom email on text-string match
Date: Thu, 28 Jul 2016 15:21:58 +0200

You need to use the "exec" action - it executes the program directly (not using 
shell), so if you want to use pipe, you need to wrap it using for example bash:

      if match "<text string>" then exec "/bin/bash -c 'echo <email message 
body here> | mailx -s <email subject line> <email address here>'"

> On 28 Jul 2016, at 15:04, Anthony Griffiths <address@hidden> wrote:
> I'm running centos 6 server with monit-5.14-1.el6.i686 and I want monit to 
> send a small custom email when it finds a match in a log file, I'm using 
> mailx and having difficulty with the correct syntax. I have this command in 
> monit.conf:
> check file <filename> with path /path/to/log/file
>       if match "<text string>" then
>       echo "<email message body here>"| mailx -s "<email subject line>" 
> <email address here>"
> but this doesn't work, when restarting monit I get:
> Starting monit: /etc/monit.conf:51: syntax error 'echo'.
> I know I could use 'if match "<text string>" then alert' but I'd rather use 
> my own custom message,
> I know I could create a little bash script and execute that but it seems a 
> long way round to do such a small thing. Can monit do this and if so what is 
> the correct syntax?
> --
> To unsubscribe:

reply via email to

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