Monit安裝配置及其使用

來源:互聯網
上載者:User
Monit是一款功能非常豐富的進程、檔案、目錄和裝置的監測軟體,用於Unix平台。 它可以自動修複那些已經停止運作的程式,特使適合處理那些由於多種原因導致的軟體錯誤。monit運行於應用程式層安裝很簡單,三部曲#./configure#make#make install 複製設定檔# cp monitrc /etc/monitrc 接下來我們根據實際情況來修改這個設定檔set daemon 120 # Poll at 2-minute intervals//每2分鐘檢查一次
set logfile /home/monit/log/monit.log          //monit的記錄檔
set alert zhouwei@chinabank.com.cn with reminder on 1 cycle  //出現1次錯誤的時候發警示郵件到指定的郵箱
#set mailserver mail.tildeslash.com, mail.foo.bar port 10025, localhost with tim
eout 15 seconds
set mailserver 10.10.9.109    //設定郵件伺服器set httpd port 2812 and use address 10.10.8.2 //設定http監控頁面的連接埠和ip
    allow localhost   # Allow localhost to connect //允許本機訪問
    allow 10.10.8.0/24                                            //允許此IP段訪問
    allow admin:nishiwode # Allow Basic Auth   //認證的使用者名稱和密碼# all system                                                         //平均負載.記憶體使用量率,cpu使用率
check system 10.10.8.2
   if loadavg (1min) > 4 then alert
   if loadavg (5min) > 2 then alert
   if memory usage > 75% then alert
   if cpu usage (user) > 70% then alert
   if cpu usage (system) > 30% then alert
   if cpu usage (wait) > 20% then alert# all disk                                                              //磁碟空間使用率
check device data with path /dev/sda2
   if space usage > 90% then alert
   if inode usage > 85% then alertcheck device home with path /dev/sda3
   if space usage > 85% then alert
   if inode usage > 85% then alert
# all rsync#10.10.8.2
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed host 127.0.0.1 port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout//監控ssh服務
check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout
//監控http服務//監控自訂服務
check process web_lb with pidfile /data/v20/server/web_lb/httpd.pid
    start program = "/data/v20/bin/lb.sh"  //啟動指令碼
    stop  program = "/data/v20/bin/lb_stop.sh" //停止指令碼
    if failed host 10.10.8.2 port 16101 proto http then restart
    if failed host 10.10.8.2 port 16101 proto http for 5 times within 5 cycles t
hen exec "/data/v20/bin/lb_pay.sh"
    if failed host 10.10.8.2 port 16102 type TCPSSL proto http then restart
    if failed host 10.10.8.2 port 16102 type TCPSSL proto http for 5 times withi
n 5 cycles then exec "/data/v20/bin/lb_pay.shRHEL可以用如下方法啟動monit
# vi /etc/inittab
添加:
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc

Now start monit:
# init -q或者# telinit -q
You can verify that monit is started from /var/log/message log file:
# tail -f /var/log/message
如果正常啟動能看到如下輸出:
Nov 21 04:39:21 server monit[8759]: Starting monit daemon
Nov 21 04:39:21 server monit[8759]: Monit started

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.