w.name = "hello"
w.start = "ruby xiaorui.rb"
w.keepalive(:memory_max => 333.megabytes,
:cpu_max => 50.percent)vi /etc/monit.conf
#检测的时间,默认是120s
set daemon 30
set mailserver localhost
set mail-format { from: monit@dd.com }
set alert example@dd.com
#原文:http://rfyiamcool.blog.51cto.com/1030776/1437572[root@66 ~]# cat /etc/monit.d/nginx.monit.conf
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed port 9000 type TCP then start[root@xiaorui ~]# monit -t
Control file syntax OK
[root@xiaorui ~]#
原文:http://rfyiamcool.blog.51cto.com/1030776/1437572
他可以像supervisord那样,直接启动、关闭、重启某个时间。
[root@xiaorui ~]# monit -h
Usage: monit [options] {arguments}
Options are as follows:
-c file Use this control file
-d n Run as a daemon once per n seconds
-g name Set group name for start, stop, restart, monitor and unmonitor
-l logfile Print log information to this file
-p pidfile Use this lock file in daemon mode
-s statefile Set the file monit should write state information to
-I Do not run in background (needed for run from init)
-t Run syntax check for the control file
-v Verbose mode, work noisy (diagnostic output)
-H [filename] Print SHA1 and MD5 hashes of the file or of stdin if the
filename is omited; monit will exit afterwards
-V Print version number and patchlevel
-h Print this text
Optional action arguments for non-daemon mode are as follows:
start all - Start all services
start name - Only start the named service
stop all - Stop all services
stop name - Only stop the named service
restart all - Stop and start all services
restart name - Only restart the named service
monitor all - Enable monitoring of all services
monitor name - Only enable monitoring of the named service
unmonitor all - Disable monitoring of all services
unmonitor name - Only disable monitoring of the named service
reload - Reinitialize monit
status - Print full status information for each service
summary - Print short status information for each service
quit - Kill monit daemon process
validate - Check all services and start if not running
(Action arguments operate on services defined in the control file)
#原文:http://rfyiamcool.blog.51cto.com/1030776/1437572salt.modules.monit
Monit service module. This module will create a monit type service watcher.
salt.modules.monit.monitor(name)
monitor service via monit
CLI Example:
salt '*' monit.monitor <service name>
salt.modules.monit.restart(name)
Restart service via monit
CLI Example:
salt '*' monit.restart <service name>
salt.modules.monit.start(name)
CLI Example:
salt '*' monit.start <service name>
salt.modules.monit.stop(name)
Stops service via monit
CLI Example:
salt '*' monit.stop <service name>
salt.modules.monit.summary(svc_name='')
Display a summary from monit
CLI Example:
salt '*' monit.summary
salt '*' monit.summary <service name>
salt.modules.monit.unmonitor(name)
Unmonitor service via monit
CLI Example:
salt '*' monit.unmonitor <service name> check process tomcat with pidfile /var/run/tomcat.pid
start program = "/etc/init.d/tomcat start"
as uid nobody and gid nobody
stop program = "/etc/init.d/tomcat stop"
# You can also use id numbers instead and write:
as uid 99 and with gid 99
if failed port 8080 then alert如果8080端口不同的话,报警 ! check process apache with pidfile /var/run/httpd.pid
start "/etc/init.d/httpd start"
stop "/etc/init.d/httpd stop"
if failed
host www.sol.no port 80 protocol http
then alert这里还可以指明是http 协议 ! check process apache with pidfile /var/run/httpd.pid
start "/etc/init.d/httpd start"
stop "/etc/init.d/httpd stop"
if failed
host www.sol.no port 80 and
send "GET / HTTP/1.1\r\nHost: www.sol.no\r\n\r\n"
expect "HTTP/[0-9\.]{3} 200.*"
then alert还可以用expect做数据的推送。 check host www.tildeslash.com with address www.tildeslash.com
if failed
icmp type echo count 5 with timeout 15 seconds
then alert check host tildeslash with address www.tildeslash.com
if failed
port 80 protocol http and
request "/monit/dist/monit-5.7.tar.gz"
with checksum f9d26b8393736b5dfad837bb13780786
then alert if failed
port 80
protocol http
request "/data/show?a=b&c=d"
then restart Name: | Allowed values: | Special characters:
---------------------------------------------------------------
Minutes | 0-59 | * - ,
Hours | 0-23 | * - ,
Day of month | 1-31 | * - ,
Month | 1-12 (1=jan, 12=dec) | * - ,
Day of week | 0-6 (0=sunday, 6=saturday) | * - ,
check process nginx with pidfile /var/run/nginx.pid
every 2 cycles
Example 2: Check every workday 8AM-7PM
check program checkOracleDatabase with
path /var/monit/programs/checkoracle.pl
every "* 8-19 * * 1-5"
Example 3: 在这个时间端,就不要检测 Sunday 0AM-3AM
check process mysqld with pidfile /var/run/mysqld.pid
not every "* 0-3 * * 0"#xiaorui.cc
check process freeswitch
with pidfile /usr/local/freeswitch/log/freeswitch.pid
start program = "/usr/local/freeswitch/bin/freeswitch -nc -hp"
stop program = "/usr/local/freeswitch/bin/freeswitch -stop"
if total memory > 1000.0 MB for 5 cycles then alert
if total memory > 1500.0 MB for 5 cycles then alert
if total memory > 2000.0 MB for 5 cycles then restart
if cpu > 60% for 5 cycles then alert
if failed
port 5060 type udp protocol SIP
target me@foo.bar and maxforward 10
then restart
check process asterisk
with pidfile /var/run/asterisk/asterisk.pid
start program = "/usr/sbin/asterisk"
stop program = "/usr/sbin/asterisk -r -x 'shutdown now'"
if total memory > 1000.0 MB for 5 cycles then alert
if total memory > 1500.0 MB for 5 cycles then alert
if total memory > 2000.0 MB for 5 cycles then restart
if cpu > 60% for 5 cycles then alert
if failed
port 5060 type udp protocol SIP
and target me@foo.bar maxforward 10
then restart #xiaorui.cc
check process apache with pidfile /var/run/httpd.pid
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if cpu > 40% for 2 cycles then alert
if total cpu > 60% for 2 cycles then alert
if total cpu > 80% for 5 cycles then restart
if mem > 100 MB for 5 cycles then stop
if loadavg(5min) greater than 10.0 for 8 cycles then stop
check process apache with pidfile /var/run/httpd.pid
start = "/etc/init.d/httpd start"
stop = "/etc/init.d/httpd stop"
alert admin@bar on {nonexist, timeout}
with mail-format {
from: bofh@$HOST
subject: apache $EVENT - $ACTION
message: This event occurred on $HOST at $DATE.
Your faithful employee,
monit
}
if failed host www.tildeslash.com port 80 then restart
if 3 restarts within 5 cycles then timeout
depend httpd_bin
group apache
check file httpd_bin with path /usr/local/apache/bin/httpd
alert security@bar on {checksum, timestamp,
permission, uid, gid}
with mail-format {subject: Alaaarrm! on $HOST}
if failed checksum
and expect 8f7f419955cefa0b33a2ba316cba3659
then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
if changed timestamp then alert
group apachecheck process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed port 443 type tcpssl protocol http
request "/lvs_vip/status_code" hostheader "xiaorui.cc"
with timeout 5 seconds
then alert
if failed port 443 type tcpssl protocol http
request "/lvs_vip/status_code" "xiaorui.cc"
with timeout 10 seconds
3 times within 4 cycles
then restart
depends on uwsgi我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
我正在使用i18n从头开始构建一个多语言网络应用程序,虽然我自己可以处理一大堆yml文件,但我说的语言(非常)有限,最终我想寻求外部帮助帮助。我想知道这里是否有人在使用UI插件/gem(与django上的django-rosetta不同)来处理多个翻译器,其中一些翻译器不愿意或无法处理存储库中的100多个文件,处理语言数据。谢谢&问候,安德拉斯(如果您已经在rubyonrails-talk上遇到了这个问题,我们深表歉意) 最佳答案 有一个rails3branchofthetolkgem在github上。您可以通过在Gemfi
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h