0

I'm currently trying to use monit to purge my /var/log partition from specific files whenever the partition runs out of free disk space. I created a file named toto and tried this test after reading the doc:

check filesystem log path /var/log
    if space usage > 1% for 3 cycles then exec "/usr/bin/find /var/log/ -iname 'toto' -type f -exec rm -f {} \;"

When I start monit, it prints 'log' start skipped -- method not defined and I haven't found yet what it means?

1 Answers1

0

Looking at my own monit logs, I see this happen if for some reason Monit is trying to start a service for which no start method has been declared. Here's an example from the documentation:

check process mmonit with pidfile /usr/local/mmonit/mmonit/logs/mmonit.pid
   start program = "/usr/local/mmonit/bin/mmonit" as uid "mmonit" and gid "mmonit"
   stop program = "/usr/local/mmonit/bin/mmonit stop" as uid "mmonit" and gid "mmonit"

This service has the start and stop method defined. You do not specify such methods for your log service, so they are undefined and Monit cannot do anything if somehow it is requested to start, stop, or restart (which is a third method) the log service.

You don't need to define them if Monit is not actually going to be tasked with starting or stoping the service. I have a disk space test where the methods are not defined, and it works just fine.

Louis
  • 506
  • 3
  • 12
  • Thank you very much, it's a lot clearer now. Monit still won't execute my find and remove command though, is there a way to manually start a specific check? Until now I've been using only `monit start all -v` but it really does nothing but print things it doesn't really do... – johnfocker May 05 '15 at 11:13
  • I don't know of a specific command to cause monit to check a service right away. Perhaps doing `monit unmonitor log` followed by `monit monitor log` will trigger a check right away. I see you make it wait for 3 cycles though. So it won't be instantaneous even if it does trigger the check. – Louis May 05 '15 at 12:53
  • That's right, thanks again. I removed the '3 cycles' part and run `monit unmonitor log` followed by `monit monitor log` but no more luck though. Monit also says `State file '.monit.state': Unable to truncate` when I run `monit unmonitor log` by the way? – johnfocker May 05 '15 at 14:08