Web-Server

用 monit 監控 mongrel

  • May 3, 2010

我為在這個版本中工作的 mongrels 編寫了一個 monit.d 文件:

check process redmine with pidfile /home/redmine/service/redmine.pid
group webservice

start program = "/usr/bin/mongrel_rails start -p 41328 -e production -d --pid /home/redmine/service/redmine.pid --user redmine --group redmine -a 127.0.0.1 -c /home/redmine/app"
stop program  = "/usr/bin/mongrel_rails stop --pid /home/redmine/service/redmine.pid  -c /home/redmine/app && rm /home/redmine/service/redmine.pid > /dev/null 2>&1"

if cpu greater 50% for 2 cycles then alert
if cpu greater 80% for 3 cycles then restart


if totalmem greater 60.0 MB for 5 cycles then restart
if loadavg (5min) greater 4 for 8 cycles then restart

if 3 restarts within 5 cycles then timeout


$ Checking monit control file syntax...
$ Control file syntax OK

我還想監控 http 響應,所以我在最後添加了這一行:

if failed port 41328 protocol http with timeout 10 seconds then restart

現在監控抱怨:

$ Checking monit control file syntax...
$ /etc/monit.d/redmine:16: Error: exceeded maximum number of program arguments 'http'
$ ERROR: CHECK MONIT CONFIG FILE SYNTAX

如何正確監控埠?

*編輯:*我終於發現了我的錯誤:我不小心沒有把右引號放在上面“停止程序”行的末尾。我現在在問題和我的伺服器上更正了它。

我終於發現了我的錯誤:我不小心沒有把結束引號放在上面“停止程序”行的末尾。我現在在問題和我的伺服器上更正了它。

現在埠線也可以正常工作:

if failed port 41328 protocol http with timeout 10 seconds then restart

正確的指令是:

if failed port 41328 protocol http then restart

with timeout 10 seconds超時後啟動程序以創建失敗時適用。

最好的問候,

若昂·米格爾·內維斯

引用自:https://serverfault.com/questions/136992