I've got a working monit
installation on CentOS 6.5. Events are getting detected and alert mail is getting sent, but I'm trying to get other things to happen when an event fires, via the exec
feature, and none of these are working.
For instance, I have a rule like:
if cpu usage (user) > 10% then
exec "/bin/echo 'user limit' >> /tmp/monit-status-log" as uid someuser and gid somegroup
The rule fires appropriately under cpu load, but nothing is written into the file (whose protection setting is rw-rw-rw).
The log file for an execution looks correct as far as it goes, I guess:
[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%]
Any thoughts or advice?
I think you should setup the
exec
command like this to make it works as expected :