不能得到monit来运行“exec”操作

我已经在CentOS 6.5上安装了一个monit 。 事件正在被检测到,并且警报邮件正在发送,但是当事件触发时,通过exec特性,我试图让其他事情发生,而这些都不起作用。

例如,我有一个像这样的规则:

 if cpu usage (user) > 10% then exec "/bin/echo 'user limit' >> /tmp/monit-status-log" as uid someuser and gid somegroup 

该规则在CPU负载下适当触发,但没有任何内容写入文件(其保护设置为rw-rw-rw)。

执行的日志文件看起来是正确的,我猜:

 [PST Feb 20 09:31:04] info : 'linux2.example.com' Monit reloaded [PST Feb 20 09:31:31] info : Reinitializing monit daemon [PST Feb 20 09:31:31] info : Awakened by the SIGHUP signal [PST Feb 20 09:31:31] info : Reinitializing monit - Control file '/etc/monit.conf' [PST Feb 20 09:31:31] info : Shutting down monit HTTP server [PST Feb 20 09:31:32] info : monit HTTP server stopped [PST Feb 20 09:31:32] info : Starting monit HTTP server at [*:2812] [PST Feb 20 09:31:32] info : monit HTTP server started [PST Feb 20 09:31:32] info : 'linux2.example.com' Monit reloaded [PST Feb 20 09:32:32] error : 'linux2.example.com' cpu user usage of 24.4% matches resource limit [cpu user usage>10.0%] [PST Feb 20 09:32:32] info : 'linux2.example.com' exec: /bin/echo [PST Feb 20 09:33:32] info : 'linux2.example.com' 'linux2.example.com' cpu user usage check succeeded [current cpu user usage=0.0%] 

任何想法或build议?

我想你应该像这样设置exec命令,使其按预期工作:

 if cpu usage (user) > 10% then exec "/bin/bash -c '/bin/echo user limit >> /tmp/monit-status-log'" as uid someuser and gid somegroup