Debugging monit

后端 未结 7 2036
迷失自我
迷失自我 2020-12-07 09:04

I find debugging monit to be a major pain. Monit\'s shell environment basically has nothing in it (no paths or other environment variables). Also, there are no log file that

7条回答
  •  情深已故
    2020-12-07 09:29

    Be sure to always double check your conf and monitor your processes by hand before letting monit handle everything. systat(1), top(1) and ps(1) are your friends to figure out resource usage and limits. Knowing the process you monitor is essential too.

    Regarding the start and stop scripts i use a wrapper script to redirect output and inspect environment and other variables. Something like this :

    $ cat monit-wrapper.sh
    
    #!/bin/sh
    {
      echo "MONIT-WRAPPER date"
      date
      echo "MONIT-WRAPPER env"
      env
      echo "MONIT-WRAPPER $@"
      $@
      R=$?
      echo "MONIT-WRAPPER exit code $R"
    } >/tmp/monit.log 2>&1
    

    Then in monit :

    start program = "/home/billitch/bin/monit-wrapper.sh my-real-start-script and args"
    stop program = "/home/billitch/bin/monit-wrapper.sh my-real-stop-script and args"
    

    You still have to figure out what infos you want in the wrapper, like process infos, id, system resources limits, etc.

提交回复
热议问题