서버 모니터링 소프트웨어 Monit 배치 실천

3633 단어
monit는 기능이 매우 강한 서버 모니터링 소프트웨어로 다음과 같이 제가 실천적으로 배치한 경험입니다.
1, 소프트웨어 다운로드 및 설치
wget http://mmonit.com/monit/dist/monit-5.2.5.tar.gz
tar zxvf monit-5.2.5.tar.gz
./configure
make
make install
2, Monit의 프로그램 경로 which monit monit 3 보기, 설정 파일 쓰기vim/etc/monitrc 참조 템플릿은 다음과 같습니다.nginx,juggernaut,redis,delayed질문
set daemon  20
set logfile /var/log/monit.log
set mail-format { from: [email protected] }
set mailserver smtp.gmail.com port 587
    username "[email protected]" password "xxxxxx"
    using tlsv1
    with timeout 30 seconds
set alert [email protected]
set httpd port 2812 and
    allow username:password
check process nginx with pidfile /opt/nginx/logs/nginx.pid
    start program = "/opt/nginx/sbin/nginx"
    stop program  = "/usr/bin/pkill -f '/opt/nginx/sbin/nginx'"
    if failed host paii.cn port 80 protocol http then restart
    if 3 restarts within 5 cycles then timeout

check host juggernaut with address 127.0.0.1
    start program = "/usr/bin/nohup /usr/local/bin/node /root/node_modules/.bin/juggernaut"
    stop program  = "/usr/bin/pkill -f 'node /root/node_modules/.bin/juggernaut'"
    if failed port 8080 protocol HTTP
        request /application.js
        with timeout 10 seconds
 then restart

check process redis with pidfile /var/run/redis.pid
   start program = "/root/redis-2.2.5/src/redis-server /etc/redis.conf"
   stop program = "/usr/bin/pkill -f '/root/redis-2.2.5/src/redis-server /etc/redis.conf'"
   if failed host 127.0.0.1 port 6379  then restart

check process leshi-daemon with pidfile /var/run/leshi.pid
   start program = "cmd...."
   stop program = "/usr/bin/pkill -f 'http://xxxxx:80/api'"
   if failed host 127.0.0.1 port 30002 protocol HTTP
        request /live.xml
        with timeout 10 seconds
  then restart

#check process delayed_job with pidfile /var/www/web/tmp/pids/delayed_job.pid
#   start program = "/usr/bin/env  RAILS_ENV=production /usr/local/bin/ruby  /var/www/web/script/delayed_job start"
#   stop program = "/usr/bin/env  RAILS_ENV=production /usr/local/bin/ruby /var/www/web/script/delayed_job  stop"


################################################################################################
faye 및 resque 모니터링 추가 참조 파일:
https://gist.github.com/3140446 https://github.com/defunkt/resque/blob/master/examples/monit/resque.monit#################wowza 모니터링run.sh
#!/bin/bash

# put in /usr/local/WowzaMediaServer/bin

if [ -z "$1" ]; then
echo -e "Usage: run.sh [startup|shutdown]"
  exit 1
fi

mkdir -p /usr/local/WowzaMediaServer/tmp
cd /usr/local/WowzaMediaServer/bin
./$1.sh &
sleep 5
if [ "startup" == $1 ]; then
PID=`ps auwx | grep java | grep -v grep | awk -F " " ' { print $2 }'`
  echo $PID > /usr/local/WowzaMediaServer/tmp/wowza.pid
fi
# /etc/monit/conf.d/wowza.conf
check process wowza with pidfile /usr/local/WowzaMediaServer/tmp/wowza.pid
    start program = "/usr/local/WowzaMediaServer/bin/run.sh startup" with timeout 60 seconds
    stop program = "/usr/local/WowzaMediaServer/bin/run.sh shutdown"
    if 2 restarts within 3 cycles then timeout
    # if totalmem > 100 Mb then alert # don't do this one, wowza needs lots of memory (?)
    if children > 255 for 5 cycles then stop
    if cpu usage > 95% for 3 cycles then restart
    if failed port 1935 protocol http then restart

좋은 웹페이지 즐겨찾기