monit系統監控
Monit 是用于對系統中的進程、文件、目錄、以及設備等進行監視和管理的工具.當你所指定的server宕機或者沒有反應,monit會將該進程殺死并重啟該 server.并通過郵件進行通知.Monit 包含一個內嵌的 HTTP(S) Web 界面,你可以使用瀏覽器方便地查看 Monit 所監視的服務器.
monit的安裝和配置:
tar xzvf monit-5.1.1.tar.gz cd monit-5.* ./configure make make install cp monitrc /etc/
在inittab文件中添加下面這句話,使init守護monit進程!!
vi /etc/inittab mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
Monitrc文件的配置
#設置monit檢查的間隔時間,單位是秒!! set daemon 120 #用syslog來記錄log set logfile syslog facility log_daemon #設置日志路徑 set logfile /var/log/monit.log #設置PID文件的位置 set idfile /var/.monit.id # primary mailserver 郵件服務器的IP set mailserver 192.168.0.21 #設置你的郵件從哪個賬號發出 set mail-format { from: monit@xxx.com } #接收郵件的信箱 set alert xxx@xxx.com #設置monit監聽的端口號 set httpd port 2812 # 設置monit服務器的IP,可以讓你方便的http訪問 use address 192.168.1.111 #設置用戶名和密碼 allow admin:pass
監控HTTP
check process http with pidfile /var/run/httpd.pid group www start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed host 127.0.0.1 port 80 then restart if cpu is greater than 80% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 512 mb for 5 cycles then restart if children > 200 then restart if loadavg(5min) greater than 10 for 8 cycles then stop if 3 restarts within 5 cycles then timeout
更多詳細配置可以參考默認的配置介紹
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!