我有一个通过通常的init.d/service脚本运行的守护进程.
我有monit运行,确保这些守护进程在崩溃时重新启动.
我有一个请求'service foo stop'应该停止deamon,并且因为它被明确停止,而不是崩溃,monit不应该重启它.如何用monit实现这个目标?
我可以让服务脚本的stop()例程调用'monit unmonitor',但这似乎是循环和错误的.
谢谢,戴夫
我有几个应用程序在ruby 1.9.2上运行rails 3并使用nginx + passenger部署在Ubuntu 10.04 LTS机器上.现在,我需要添加一个在ruby 1.8.7(REE)和Rails 2上运行的新应用程序.我完成了使用RVM,Passenger Standalone和反向代理.
问题是,每次我必须重新启动服务器(例如安装安全更新)时,我必须手动启动Passenger Standalone.
有没有办法自动启动它?我被告知要使用Monit或God,但我无法编写适用于Passenger Standalone的正确配方.我也有上帝和RVM的一些问题,所以如果你有一个不使用上帝的解决方案,或者如果你知道如何正确配置God/Rvm,那就更好了.
我很难找到适用于php-fpm的monit配置.
这就是我尝试过的:
### Monitoring php-fpm: the parent process.
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
group phpcgi # phpcgi group
start program = "/etc/init.d/php-fpm start"
stop program = "/etc/init.d/php-fpm stop"
## Test the UNIX socket. Restart if down.
if failed unixsocket /var/run/php-fpm.sock then restart
## If the restarts attempts fail then alert.
if 3 restarts within 5 cycles then timeout
Run Code Online (Sandbox Code Playgroud)
但它失败了,因为没有php-fpm.sock(Centos 6)
在尝试了几个小时(并且还尝试了上帝和Bluepill)后,我决定在这里提出我的问题,因为我完全不知道如何解决这个问题.
我有一个Rails应用程序.我想使用Thin作为我的应用服务器.我想使用Monit来监控我的Thin实例.我使用RVM来管理我的Ruby版本作为我的本地用户.
我有以下monit文件设置,可以做我想做的事,但不是:
check process thin-81
with pidfile /Users/Michael/Desktop/myapp/tmp/pids/thin.81.pid
start program = "/Users/Michael/.rvm/gems/ruby-1.9.2-p180/bin/thin start -c /Users/Michael/Desktop/myapp -e production -p 81 -d -P tmp/pids/thin.81.pid"
stop program = "/Users/Michael/.rvm/gems/ruby-1.9.2-p180/bin/thin stop -c /Users/Michael/Desktop/myapp -P tmp/pids/thin.81.pid"
if totalmem is greater than 150.0 MB for 2 cycles then restart
Run Code Online (Sandbox Code Playgroud)
如果我只是将其复制/粘贴start program到命令行(Monit之外),它就可以工作.同样适用stop program于之后停止Thin实例.然而,通过Monit运行它似乎不起作用.
以-v详细模式运行它会产生以下结果:
monit: pidfile '/Users/Michael/Desktop/myapp/tmp/pids/thin.81.pid' does not exist
Run Code Online (Sandbox Code Playgroud)
这让我相信Thin永远不会初始化.Monit可以运行root吗?因为如果它确实那么它显然不会安装正确的gems,因为我使用RVM而不是"系统"Ruby.我目前在OSX上(但最终将部署到Linux) - 有谁知道这可能是什么原因?如果Monit是通过root运行的,我怎么能让它使用RVM呢?或者我可以告诉Monit执行启动/停止程序Michael:staff(我假设它将在OSX上?)
任何帮助深表感谢!
所以我的monitrc文件中有以下内容:
check process apache with pidfile /usr/local/apache/logs/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host XXX port 80 protocol http
and request "/monit/token" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu 80% for 5 cycles then restart
if totalmem 500 MB for 5 cycles then restart
if children 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts …Run Code Online (Sandbox Code Playgroud) 我对monit相当新,我想知道这个脚本是否足以重新启动崩溃的程序让我们说program1是程序的名称.
check process program1
matching "program1"
start program = "/home/user/files/start.sh"
stop program = "/home/user/files/stop.sh"
Run Code Online (Sandbox Code Playgroud)
它现在会重启一个崩溃的程序吗?我怎样才能保证它在工作时不重启程序?
编辑:更多信息该程序使用端口30000 udp.这会让它更加谨慎吗?"周期"之间有多少秒?
if failed port 30000 type UDP for 3 cycles then restart
Run Code Online (Sandbox Code Playgroud) 我想尝试用monit监视postfix队列.我从Stackoverflow的人那里得到了一个例子.我的monit版本是最新版本
这是Monit版本5.10
在/etc/monit.d我postfixlocal与
check program postfixcola with path "/usr/local/bin/postfixcola.sh"
#if status != 0 then alert
if status > 1 then alert
Run Code Online (Sandbox Code Playgroud)
然后/usr/local/bin/我postfixcola.sh用
#!/bin/sh
QUEUE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'`
exit $QUEUE
Run Code Online (Sandbox Code Playgroud)
但Monit每次都会抱怨脚本的输出.我已经做了测试,设置和回显之前exit和测试时它返回1(因为后缀的队列是1)
但错误仍然存在: [CET Dec 9 11:10:07] error : 'postfixcola' '/usr/local/bin/postfixcola.sh' failed with exit status (2) -- no output
我真的不知道这里有什么问题,有什么想法吗?
我创建了必须在崩溃时重启的monit应用程序golang site
$ cd /etc/monit/conf.d
$ vim checkSite
Run Code Online (Sandbox Code Playgroud)
它启动程序nohup并将其保存pid到文件:
check process site with pidfile /root/go/path/to/goSite/run.pid
start program = "/bin/bash -c 'cd /root/go/path/to/goSitePath; nohup ./goSite > /dev/null 2>&1 & echo $! > run.pid'" with timeout 5 seconds
stop program = "/bin/kill -9 `cat /root/go/path/to/goSitePath/run.pid`"
Run Code Online (Sandbox Code Playgroud)
它开始了.
Process 'site'
status Running
monitoring status Monitored
pid 29723
parent pid 1
uptime 2m
children 0
memory kilobytes 8592
memory kilobytes total 8592
memory percent 0.4%
memory percent total …Run Code Online (Sandbox Code Playgroud) 我有一个使用的程序phantomjs.该程序应该只有一个实例,并且没有使用的程序Phantomjs.
但有时会Phantomjs在同一时间启动多个实例.可能我的程序有一个bug.为了快速修复,如果Phantomjsmonit实例多于一个,我想杀死旧实例.
我可以通过使用matching函数找到Phantomjs的实例monit.但我无法找到如何比较两个实例状态并杀死旧实例状态.
我会非常感谢任何建议.
我望着使用monit的工具,我的Rails app.As这是我第一次使用任何监视工具可以有人指导我或点我一些参考试图对我如何设置和使用的monit使用默认的Rails的WEBrick服务器工具(当地的发展环境)?我发现了以下引用,但它们都展示了针对Apache,Nginx等的monit配置.
环境:
谢谢,
Jignesh