I can see how to alert when a regex appears in a log file. I can see how to alert when a regex does not appear on EVERY line of a log file. But I can't see how to alert when a regex has not appeared in a log file over a period of time.

I could create a bash script which regex's the file for me, and writes out to a file which monit monitors, but would rather keep the solution within monit.

Any help would be appreciated.


From the manual:

IF [NOT] MATCH {regex|path} [[] CYCLES] THEN action

The content is only being checked every cycle. If content is being added and removed between two checks they are unnoticed.

Use the CYCLE option. The limitation I see here is the cycles. The manual defaults to 300 seconds (5 minutes). Determine how many cycles are needed and then tweak the alerting.

  • 1
    Thanks John. I'll give it a go on my server and report back. – Ben Sep 7 '10 at 5:24
  • Not sure that this works John. I entered the following: – Ben Sep 7 '10 at 21:51
  • check file system.log with path /var/log/system.log if NOT match "BLAH" within 2 cycles then alert group prices – Ben Sep 7 '10 at 21:51
  • 1
    This will alert on every line which does not match the pattern "BLAH". Which is different to what I want to do. I want to alert when I don't receive something over a period of time. – Ben Sep 7 '10 at 21:52
  • If that entry is not working I would then post to the monit mailing list and ask them. Sorry if that didn't help. – John Sep 9 '10 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.