When my server gets into high load, a graceful restart of Apache seems to bring things back under control. So I set up monit, with this configuration:
set daemon 10
check system localhost
if loadavg (1min) > 5 then exec "/etc/init.d/apache2 graceful"
So every 10 seconds, I poll the server load, and when it gets above 5, I gracefully restart Apache. However, that temporarily raises the load, so we get into a death spiral. What I want is for it to notice after 10 seconds that the load is 5 or more, and gracefully restart Apache, then wait for 5 minutes or so before checking that particular metric again.
Is there a way to do this with monit?