Hi,

monit executes the program directly, if you want to use pipe, you need to wrap 
the whole command like this:

        if cpu > 1% for 2 cycles then exec "/bin/bash -c 'top -bn1 | mail -s 
top [email protected]'"


Regards,
Martin


> On 12 Nov 2014, at 17:01, [email protected] wrote:
> 
> Howdy, I try to add an option to send (exactly the output of top by
> email), so I've added that line:
> 
> if cpu > 75% for 2 cycles then exec "/bin/bash -c top -bn1 | mail -s top
> [email protected]"
> 
> as below (but does not run)
> 
> any idea?
> 
> thanks!
> 
> Pol
> 
> # APACHE
> 
>  check process apache with pidfile /var/run/apache2.pid
>    start program = "/etc/init.d/apache2 start" with timeout 60 seconds
>    stop program  = "/etc/init.d/apache2 stop"
>    if cpu > 60% for 2 cycles then alert
>    if cpu > 80% for 5 cycles then restart      # 10minutes
>    if cpu > 1% for 2 cycles then exec "/bin/bash -c top -bn1 | mail -s
> top [email protected]"
>    if totalmem > 200.0 MB for 5 cycles then restart
>    if children > 250 then restart
>    if loadavg(5min) greater than 10 for 8 cycles then stop
>    if failed host 192.168.1.212 port 80 protocol http
>       and request "/monit/token"
>       then restart
> 
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to