隨筆 - 0, 文章 - 264, 評論 - 170, 引用 - 0
          數據加載中……

          linux配置monit自動監控程序運行狀態

          為了監控程序正常運行,即當程序掛掉時,能夠自動重啟。
          特配置如下:
          check process pusher-admin with pidfile /var/run/admin.pid
              start program 
          = "/etc/init.d/pusherd start"
              stop program 
          = "/etc/init.d/pusherd stop"
              
          if 5 restarts within 5 cycles then timeout
              group pusherd

          查看是否監控正常,運行命令如下:
          [root@pusher-ECM-1-226 pusher]# monit status
          The Monit daemon 
          5.2.5 uptime: 1m 

          System 
          '127.0.0.1'
            status                            running
            monitoring status                 monitored
            load average                      [
          0.00] [0.02] [0.05]
            cpu                               
          0.0%us 0.0%sy 0.0%wa
            memory usage                      
          1731472 kB [10.6%]
            swap usage                        
          0 kB [0.0%]
            data collected                    Mon Mar 
          24 16:44:25 2014

          Process 
          'pusher-admin'
            status                            running
            monitoring status                 monitored
            pid                               
          9245
            parent pid                        
          1
            uptime                            5m 
            children                          
          6
            memory kilobytes                  
          978964
            memory kilobytes total            
          983880
            memory percent                    
          6.0%
            memory percent total              
          6.0%
            cpu percent                       
          0.0%
            cpu percent total                 
          0.0%
            data collected                    Mon Mar 
          24 16:44:25 2014

          可以看到,monit已經監控到pusher-admin應用。

          注意:在配置pusherd.monit的時候,如果添加上
          mode manual
          ,則需要在/etc/init.d/pusherd中手動去monit這個pusherd應用,即在啟動是monit上,在關閉時unmonit,代碼示例如下:
          start時:
          if
           [ -/etc/init.d/monit ] ; then
                      
          for APPLICATION_TYPE in ${APPLICATION_TYPES}; do
                          
          /usr/bin/monit monitor "${APPLICATION_PRODUCT}-${APPLICATION_TYPE}"
                      done
                  fi
                  ;;
          stop時:
          if [ -f /etc/init.d/monit ] ; then
                      for APPLICATION_TYPE in ${ALL_TYPES[@]}; do
                          /usr/bin/monit unmonitor "${APPLICATION_PRODUCT}-${APPLICATION_TYPE}"
                      done
                  fi


          另注:若monit stauts顯示某一項服務為not monitored,則可以刪除/var/monit/state文件,再重啟monit即可。

          posted on 2014-03-24 17:02 小一敗涂地 閱讀(4241) 評論(0)  編輯  收藏 所屬分類: linux相關

          主站蜘蛛池模板: 元阳县| 厦门市| 石城县| 舒城县| 萨嘎县| 铜鼓县| 皮山县| 赣榆县| SHOW| 弋阳县| 海阳市| 清丰县| 云阳县| 浪卡子县| 明星| 太白县| 宁津县| 新昌县| 禄劝| 临潭县| 府谷县| 新蔡县| 娄烦县| 晋州市| 改则县| 马鞍山市| 玉龙| 宣恩县| 达日县| 荆门市| 临汾市| 武定县| 南和县| 都匀市| 凌源市| 察雅县| 玛沁县| 原平市| 龙口市| 绍兴市| 鹤岗市|