0

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.

Ben
  • 121
  • 3

1 Answers1

0

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.

John
  • 567
  • 2
  • 4
  • 1
    Thanks John. I'll give it a go on my server and report back. – Ben Sep 07 '10 at 05:24
  • Not sure that this works John. I entered the following: – Ben Sep 07 '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 07 '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 07 '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 09 '10 at 00:31
  • Combine John's suggestion with the nagios [check_logs](http://exchange.nagios.org/directory/Plugins/Uncategorized/Operating-Systems/Linux/check_logs/details) script and you should be golden. There are multiple nrpe log plugins that you could utilize. – Jodie C Mar 07 '12 at 23:40