110 likes | 289 Views
MRTG 安裝與介紹 ( Multi Router Traffic Grapher ). 張淳雄. MRTG 主要用途. 系統資源負荷量統計 各種網路伺服器流量統計 網路設備流量統計 其他統計資料. 安裝 MRTG ( 以 Linux7.3 為例 ). 元件檢查 rpm -qa | grep perl --> 有 rpm -qa | grep zlib --> 有 rpm -qa | grep gd --> 有 rpm -qa | grep libpng --> 有 rpm -qa ucd-snmp --> 有 rpm -qa mrtg --> 有
E N D
MRTG主要用途 • 系統資源負荷量統計 • 各種網路伺服器流量統計 • 網路設備流量統計 • 其他統計資料
安裝MRTG(以Linux7.3為例) • 元件檢查 rpm -qa | grep perl --> 有 rpm -qa | grep zlib --> 有 rpm -qa | grep gd --> 有 rpm -qa | grep libpng --> 有 rpm -qa ucd-snmp --> 有 rpm -qa mrtg --> 有 Linux7.3本身就有perl,zlib,gd,libpng,ucd-snmp,mrtg元件,不需再安裝
下載ucd-snmp-4.2.5.tar.gz cp ucd-snmp-4.2.5.tar.gz /usr/local/src cd /usr/local/src tar -zxvf ucd-snmp-4.2.5.tar.gz cd ucd-snmp-4.2.5 ./configure --prefix=/usr/local/snmp .......(過程我就省略了)
************** Configuration Section ************** You are about to be prompted by a series of questions. Answer them carefully, as they determine how the snmp agent and related applications are to function. After the configure script finishes, you can browse the newly created config.h file for further - less important - parameters to modify. Be careful if you re-run configure though since config.h will be over written. -Press return to continue- (這裡按 enter 吧)disabling above prompt for future runs... yes checking System Contact Information... *** System Contact Information: Describes who should be contacted about the host the agent is running on. This information is available in the MIB-II tree. This Can Also Be Over-Ridden Using The "syscontact" Syntax In The Agent'S Configuration Files. System Contact Information (root@):t30504@webmail.inhs.tc.edu.tw(這裡輸入你的 e-mail)setting System Contact Information to... t30504@webmail.inhs.tc.edu.twchecking System Location...
*** System Location: Describes the location of the system. This information is available in the MIB-II tree. This Can also be over-ridden using the “syslocation” syntax in the agent‘s configuration files. System Location (Unknown):RedHat 7.3 (輸入Linux版本,不正確也沒關係)setting System Location to... RedHat 7.3 checking Location to write logfile... *** Logfile location: Enter the default location for the snmpd agent to dump information & errors to. If not defined (enter the keyword "none" at the prompt below) the agent will use stdout and stderr instead. (Note: This value can be over-ridden using command line options.) Location to write logfile (/var/log/snmpd.log):(按 enter 即可)setting Location to write logfile to... /var/log/snmpd.log checking Location to write persistent information... *** snmpd persistent storage location: Enter a directory for the snmp library to store persistent data in the form of a configuration file. Location to write persistent information (/var/ucd-snmp):(按 enter 即可)
完成上述動作後 make make install 然後啟動 ucd-snmp /usr/local/snmp/sbin/snmpd 並且修改 /etc/rc.d/rc.local加入上面那行,使開機後可以自動執行 另外,要關閉開機自動執行原本Linux所內定安裝的ucd-snmp 請在終端機下鍵入 ntsysv,然後把 snmpd 的勾選項目去掉~~ 這樣就不會去執行舊的 ucd-snmp 囉~~
使用系統的MRTG mkdir /var/www/html/mrtg/net (ps: /var/www/html/mrtg 系統安裝mrtg時已經建立!) /usr/bin/cfgmaker --output=/var/www/html/mrtg/net/mrtg.cfg public@203.72.158.4(ps: public不可改,203.72.158.8就是您的網址) vi /var/www/html/mrtg/net/mrtg.cfg (修改三處!) WorkDir: /var/www/html/mrtg/net/ Options[_]: growright, bits Language: big5 存檔後,連續執行下列命令3次 /usr/bin/mrtg /var/www/html/mrtg/net/mrtg.cfg
製作index.html /usr/bin/indexmaker --output=/var/www/html/mrtg/net/3326s.html --title=DES-3326s主機流量統計表 /var/www/html/mrtg/net/mrtg.cfg
每5分鐘,自動統計一次 vi /etc/crontab (加入下面一行,使每5分鐘統計一次) */5 * * * * root /usr/bin/mrtg /var/www/html/mrtg/net/mrtg.cfg > /dev/null 2>&1 存檔後即可,觀看您的結果: http://203.72.158.8/mrtg/net/3326s.html