友链
导航
These are the good times in your life,
so put on a smile and it'll be alright
友链
导航
error connecting to the monit daemon
. 需修改配置开启 HTTP 服务set httpd port 2812 and use address localhost # only accept connection from localhost allow localhost # allow localhost to connect to the server and
set httpd port 2812 allow admin:monit # require user 'admin' with password 'monit'
set daemon 120 # check services at 2-minute intervals with start delay 240 # optional: delay the first check by 4-minutes (by # default Monit check immediately after Monit start)
check process foo with pidfile "/var/run/foo.pid" start program = "/sbin/start foo" stop program = "/sbin/stop foo" if mem > 30 MB then restart
check
中 ''check 多 matching “foo*” 或 “/var/run/foo*.pid” 的进程的. 如若想让符合某 pattern 的各进程在 mem 超标时 kill, 可如下 cron: #!/bin/bash # /etc/cron.d/foo # */5 * * * * root /etc/kill_over_mem_foo_procs.sh # 遍历 foo 的 pid 和 memory(RSS), # 若 memory 使用超过 mem_limit, 则 kill pid. # 由于 scripts 是 forever 挂起的, 所以稍后会重启. # (Xiaopei Li@2013-12-31) # 设内存使用上限为 18M mem_limit=18000 ps aux | grep -F 'foo' | grep -v grep | awk '{print $2, $6}' | \ while read pid mem; do if [[ $mem > $mem_limit ]]; then kill $pid fi done