search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

Monit。我所使用的系統及服務監控軟體 :: 哇哇3C日誌

monit.gif

要維持部落格的運作,我就得持續的監控主機的健康狀態,勢必需要一個監控軟體來幫忙達成,我之前持續使用了監控寶好一陣子,我覺得監控寶真的做得還不錯,甚至透過SNMP有很多的數據報表都可以呈現,就礙於免費的帳號對於監控頻率以及監控數量有所限定,而且其實有時候我只是要最基本的監控,譬如說網路不通、或是HTTP和FTP的服務不通,發生狀況時有訊息的通知即可!


為了符合我自己的簡單監控需求,我找到了一套很特別的【Moint】,幾個特點和大家分享一下:
  • 這是免費的!免費版的設定檔得自己去編寫,沒有網頁介面可以去設定,但是這點對我影響不大。
  • 有WEB介面可以查看即時的狀態,並且可以透過網頁進行「enable」與「disable」的動作。
  • 內建有retry的機制,可以自己設定行為動作,避免誤判的發生。
  • 可以幫您重新啟動服務,若是發現WEB服務中斷了,能達成重新啟動服務的動作。
  • 監控System、Process、FileSystem、File、Fifo、Directory和Host。
  • 不同觸發事件,可以指定寄信給不同的收件者。
Moint:http://mmonit.com/monit/
ScreenShots:http://mmonit.com/monit/screenshots/
文件:http://mmonit.com/monit/documentation/
其實我覺得能監控的項目真的不少,大家可以看官方的ScreenShots參考一下,設定檔的部分就自己努力的編寫一次囉!官方也有很充足的文件可以參考,我想達成系統的監控絕對沒有問題的!不過這監控是屬於即時的狀態,並不會有長期的數據統計,只會留下系統紀錄。

$ monit -h
Usage: monit [options] {arguments}
Options are as follows:
 -c file       Use this control file
 -d n          Run as a daemon once per n seconds
 -g name       Set group name for start, stop, restart, monitor and unmonitor
 -l logfile    Print log information to this file
 -p pidfile    Use this lock file in daemon mode
 -s statefile  Set the file monit should write state information to
 -I            Do not run in background (needed for run from init)
 -t            Run syntax check for the control file
 -v            Verbose mode, work noisy (diagnostic output)
 -H [filename] Print SHA1 and MD5 hashes of the file or of stdin if the
               filename is omited; monit will exit afterwards
 -V            Print version number and patchlevel
 -h            Print this text
Optional action arguments for non-daemon mode are as follows:
 start all      - Start all services
 start name     - Only start the named service
 stop all       - Stop all services
 stop name      - Only stop the named service
 restart all    - Stop and start all services
 restart name   - Only restart the named service
 monitor all    - Enable monitoring of all services
 monitor name   - Only enable monitoring of the named service
 unmonitor all  - Disable monitoring of all services
 unmonitor name - Only disable monitoring of the named service
 reload         - Reinitialize monit
 status         - Print full status information for each service
 summary        - Print short status information for each service
 quit           - Kill monit daemon process
 validate       - Check all services and start if not running

(Action arguments operate on services defined in the control file)

基本的command秀給大家看一下,基本上我是將主要設定檔寫在/usr/local/etc/monitrc,因為此軟體不能透過snmp監控遠端主機的CPU資訊等等,像是ping或http的監控定我就會放在/usr/local/etc/monit.d目錄下。

基本設定項目:
set daemon  60 # 設定監控頻率
set logfile /var/log/monit.log  # 設定log寫入的檔案,不設定會寫入/var/log/message
set mailserver msa.hinet.net  # 寄信的mailserver

set mail-format {
 From: taipei@$HOST
 Subject: [ monit通知 ] - $EVENT $SERVICE

 message:$EVENT 監控項目 $SERVICE

        時間:$DATE
        動作:$ACTION
        主機:$HOST
        描述:$DESCRIPTION
}    # 設定發信出來的Format,若是記出來為亂碼,請更改編碼

set alert [email protected]  # [email protected]會收到所有的異常通知
set alert [email protected] only on { timeout }  # [email protected]收到timeout的異常通知

set httpd port 2812 and  # 預設WEB Listen 2182 port
     allow 帳號:密碼      # WEB介面設定帳號與密碼

check system taipei.easylife.tw  # 監控主機CPU、Memory、Swap以及Uptime的數值
    if loadavg (1min) > 4 then alert
    if loadavg (5min) > 2 then alert
    if memory usage > 75% then alert
    if swap usage > 25% then alert
    if cpu usage (user) > 70% then alert
    if cpu usage (system) > 30% then alert
    if cpu usage (wait) > 20% then alert

check file shadow with path /etc/shadow  # 監控密碼檔案,有人改密碼則會通知,或是被更改了屬性及權限
    if failed checksum and
       expect the sum f456845a152cdc7339f2282641a9df2c then unmonitor
    if failed permission 400 then unmonitor
    if failed uid root then unmonitor
    if failed gid root then unmonitor

check process mysqld with pidfile /var/run/httpd.pid  # 監控apache,並且可以設定alert與重新啟動服務
    start program = "/etc/init.d/httpd start" with timeout 60 seconds
    stop program  = "/etc/init.d/httpd stop"
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart
    if totalmem > 200.0 MB for 5 cycles then restart
    if children > 250 then restart
    if loadavg(5min) greater than 10 for 8 cycles then stop

check filesystem root-filesystem with path /dev/sda2 # 監控硬碟空間的使用
    if space usage > 40% for 5 times within 15 cycles then alert
    if space usage > 99% then stop
    if inode usage > 300000 then alert
    if inode usage > 50% then stop

check host taipei-HTTP with address 220.132.12.209  # WEB的監控,會監控80 port的狀態,10秒沒回應就算Fail
    if failed port 80 protocol http with timeout 10 seconds then alert

check host taipei-PING with address 220.132.12.209  # 最基本的ping監控,可以設定ping幾次及timeout值
    if failed icmp type echo count 3 with timeout 3 seconds then alert

我這裡是最簡易的設定,若是多多參考官方的文件,會發現真的可以監控到非常多的東西,而且可以設定一些執行的動作,若是不當成監控軟體,也可以設定系統執行一些動作,反正我覺得還算強大!可惜就是設定要自己動手打,還好設定檔的語法算是簡單,若是看得懂英文應該都很容易懂吧!我在這裡推薦大家可以使用看看,若你也有監控需求的話!

官方其實還有M/Monit付費的版本,功能就整個非常的不錯,甚至可以監控到多台主機的狀態,也可以藉由WEB去設定,看了真的很想使用看看,而且還有iPhone的版本!但是還好免費版本沒有限制監控的數量,雖然設定較麻煩,但是功能也算超值了!

Moint:http://mmonit.com/monit/
ScreenShots:http://mmonit.com/monit/screenshots/
文件:http://mmonit.com/monit/documentation/


更多資訊請參考:
開箱推薦 POIEMA 免耗材空氣清淨機
虛擬主機推薦|台灣 VPS 推薦

訪客留言

Monit。我所使用的系統及服務監控軟體 參考資料

Monit。我所使用的系統及服務監控軟體 - 神魂顛倒論壇
2011年1月4日 - Monit。我所使用的系統及服務監控軟體. 要維持部落格的運作,我就得持續的監控主機的健康狀態,勢必需要一個監控軟體來幫忙達成,我之前持續 ...
Monit系統監控軟體 本機運作小而美 - 專題報導 - 網管人NetAdmin
什麼是Monit監控軟體 Monit是一個功能非常強大的資源監控軟體,主要應用在監控服務主機上的相關資源,可監控的範圍包括檔案系統的變動(如某個目錄或檔案變動)、運作中的程序(Process)的監控以及網路服務(如網站伺服器或郵件伺服器等網路服務 ...
Monit。我所使用的系統及服務監控軟體| ContentParty 文章交換平台
要維持部落格的運作,我就得持續的監控主機的健康狀態,勢必需要一個監控軟體來幫忙達成,我之...
軟體教學與介紹-Monit。我所使用的系統及服務監控軟體 - 神魂顛倒論壇
2011年1月4日 - 軟體教學與介紹-Monit。我所使用的系統及服務監控軟體-Flash,Silverlight,HTML5,CSS3,購物,網頁,後台開發,設計,電子商務,論壇-神魂顛倒論壇是 ...
icodding愛程式: centos 安裝monitorix即時系統狀態監控
monit 即時監控系統 狀態 首先安裝epel 套件 (Extra Packages for Enterprise Linux) yum install https://dl.fedoraproject.org ... 當我們想要利用 Python 開發 windows 視窗軟體其實有幾種套件可以使用,PyQt、PyGTK、wx、tkinter、pywin等,其中我們 ...
Android 軟體《最酷的工具 (system stats)》即時監控你的手機系統資訊 - 就是教不落
對於手機 APP 開發者來說,除了要設計好 UI 及實用的功能之外,也得注意到手機的效能佔用情況,畢竟以 Android 手機來說,低中高階的手機那麼多,如果你開發的 APP 愈不佔用系統,能夠使用的人就愈多,Android 軟體《最酷的
推薦!國外工程師整理的系統管理員資源大全 | TechOrange
·Rsnapshot – 文件系統快照工具 ·SafeKeep – 使用 rdiff-backup,集中的,基於 pull ... ·Consul – Consule 是伊戈爾服務發現,監控和配置的工具 ·Doozerd – Doozer 是一個高可用,完全一致的存儲,用於少量非常重要的數據 ...
Monit。我所使用的系統及服務監控軟體← 軟體教學與介紹← 神魂顛倒 ...
2011年1月4日 - Monit。我所使用的系統及服務監控軟體. 要維持部落格的運作,我就得持續的監控主機的健康狀態,勢必需要一個監控軟體來幫忙達成,我之前持續 ...
系統監控軟體《Moo0 SystemMonitor》硬體、網路、系統一手包辦,還會告訴你誰拖慢了電腦 - 就是教不落
可以即時監控系統的軟體相當的多,不過可以詳細的監控又會電腦變慢時告訴你原因的軟體就真的不多了,《Moo0 SystemMonitor》是一套免費的系統監控軟體,監控範圍從CPU、GPU、硬碟、記憶體到網路流量、程式執行數量、連線數等


熱門推薦

本文由 ez3c 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦