0

I'm trying to use monit to monitor a backgroundrb process (that gets killed occasionally), but I cant seem to seem the start or stop commands to work (i simply get 'execution failed') - though they do work fine from the command prompt.

I'm not doing anything particularly sophisticated:

check process backgroundrb_11006
    with pidfile "/home/user/site/tmp/pids/backgroundrb_11006.pid"
    start = "/usr/bin/ruby /home/user/site/script/backgroundrb start"
    stop = "/usr/bin/ruby /home/user/site/script/backgroundrb stop"
    if cpu > 90% for 2 cycles then restart
    if totalmem > 512 MB for 2 cycles then restart
    if 4 restarts within 4 cycles then timeout
group backgroundrb

I have a custom location for my some of my gems like packet (/home/user/.gem/ruby/1.8/bin), and I suspect that part of the problem is that monit uses a spartan PATH (To quote http://mmonit.com/monit/documentation/monit.html - PATH=/bin:/usr/bin:/sbin:/usr/sbin), rendering these gems unreachable. Also, I get no errors in the backgroundrb debug log.

I'd love to hear from anyone who has any idea how I might adjust backgroundrb (or my start/stop commands) in order to make this work.

Cheers, Vaughan.

200_success
  • 4,701
  • 1
  • 24
  • 42

1 Answers1

1

You could make custom start/stop scripts with the right path's set and then use those scripts with monit.

Very simple start-script (backgroundrb_monit_start)

#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/add/your/other/paths
GEM_HOME=/home/mygemrepository
/usr/bin/ruby /home/user/site/script/backgroundrb start

And monit config:

start = "/usr/bin/ruby /home/user/site/script/backgroundrb_monit_start"
rkthkr
  • 8,503
  • 26
  • 38
  • Thanks, but I've tried this and it doesnt work - I get the same symptoms. Also, when I pass the PATH in the start command I get the same result as well. –  Aug 12 '09 at 01:56
  • Those paths are independent of "monit's" spartan paths, so it should work, check what envs that monit pass and which you got in your shell where it works and add those that are missing. (env that is related) – rkthkr Aug 12 '09 at 06:12
  • Hi, I understand your point - but with more examination even the most simplest of experiments wont work. That is, running '/bin/bash /home/user/simplescript.sh' doesnt run either - which (AFAIK) doesnt rely on any environmental variables? –  Aug 16 '09 at 22:16