MRTG網路流量統計軟體

一、概述:

二、運作原理:

三、使用上的限制:

四、安裝環境:

五、套件來源:

六、網路資源:

七、檢查己安裝之套件:

  1. 檢查是否安裝apache及其版本號碼:

  2.  
    [root@test /]# rpm -qa | grep apache- 
    apache-1.3.6-7 
     
  3. 檢查是否安裝gd及其版本號碼:

  4.  
    [root@test /]# rpm -qa | grep gd- 
    gd-1.3-5
     
  5. 檢查是否安裝perl及其版本號碼:

  6.  
    [root@test /]# rpm -qa | grep perl 
    perl-5.00503-2
     

八、安裝未安裝之套件(或升級版本不符之套件):

    安裝套件之命令為:rpm -ivh + 套件檔.rpm
    升級套件之命令為:rpm -Uvh + 套件檔.rpm
    以下範例將以『安裝套件』為例,若您欲將套件升級,請將『rpm -ivh』改為『rpm -Uvh』即可,其餘操作均一樣。
 
  1. 請將您系統之身份轉為root,或登出以root身份登入才可做以下之安裝。
  2. 放入您的RedHat 6.0 + CLE 0.8光碟至光碟機,並執行下列命今將光碟掛入檔案系統:

  3.  
    [root@test /]# cd /mnt 
    [root@test /mnt]# mount cdrom
     
  4. 切換到光碟中的RPMS目錄下後,開始安裝所缺乏之套件:

  5.  
    [root@test /mnt]# cd /mnt/cdrom/RedHat/RPMS/ 
    [root@test RPMS]#
     
  6. 安裝apache套件:

  7.  
    [root@test RPMS]# rpm -ivh apache-1.3.6-7.i386.rpm 
     
  1. 安裝gd套件:

  2.  
    [root@test RPMS]# rpm -ivh gd-1.3-5.i386.rpm 
     
  3. 安裝gd套件:

  4.  
    [root@test RPMS]# rpm -ivh perl-5.00503-2.i386.rpm 
     

 九、安裝MRTG:

  1. ftp至ftp://vdn1.hmes.kh.edu.tw/pub/mrtg/取回套件:

  2.  
    [root@test RPMS]# cd /root 
    [root@test /root]# ftp vdn1.hmes.kh.edu.tw 
    Connected to vdn1.hmes.kh.edu.tw. 
    220 vdn1.hmes.kh.edu.tw FTP server (Version wu-2.4.2-VR17(1) Mon Apr 19 09:21:5. 
    Name (vdn1.hmes.kh.edu.tw:jang): anonymous 
    331 Guest login ok, send your complete e-mail address as password. 
    Password:<--輸入您的email做為密碼 
    230 Guest login ok, access restrictions apply. 
    Remote system type is UNIX. 
    Using binary mode to transfer files. 
    ftp> cd pub 
    250 CWD command successful. 
    ftp> cd mrtg 
    250 CWD command successful. 
    ftp> bin 
    200 Type set to I. 
    ftp> get mrtg-2.8.8-cfix.tar.gz 
    local: mrtg-2.8.8-cfix.tar.gz remote: mrtg-2.8.8-cfix.tar.gz 
    200 PORT command successful. 
    150 Opening BINARY mode data connection for mrtg-2.8.8-cfix.tar.gz (479215 byte. 
    226 Transfer complete. 
    479215 bytes received in 0.0497 secs (9.4e+03 Kbytes/sec) 
    ftp> exit 
    221-You have transferred 479215 bytes in 1 files. 
    221-Total traffic for this session was 479820 bytes in 1 transfers. 
    221-Thank you for using the FTP service on vdn1.hmes.kh.edu.tw. 
    221 Goodbye. 
    [root@test /root]#
     
  3. 解開套件

  4.  
    [root@test /root]# tar zxvf mrtg-2.8.8-cfix.tar.gz 
    [root@test /root]# ls -al 
    drwxr-xr-x   7 root     root         1024 Oct 20 17:08 mrtg-2.8.8
     
  5. 將mrtg-2.8.8目錄移至/home底下

  6.  
    [root@test /root]# mv mrtg-2.8.8 /home
     
  7. 組態mrtg

  8.  
    [root@test /root]# cd /home/mrtg-2.8.8 
    [root@test mrtg-2.8.8]# ./configure 
    loading cache ./config.cache 
    checking for gcc... (cached) gcc 
    checking whether the C compiler (gcc  ) works... yes 
    checking whether the C compiler (gcc  ) is a cross-compiler... no 
    checking whether we are using GNU C... (cached) yes 
    checking whether gcc accepts -g... (cached) yes 
    checking how to run the C preprocessor... (cached) gcc -E 
    checking whether make sets ${MAKE}... (cached) yes 
    checking for perl... (cached) /usr/bin/perl 
    checking for acos in -lm... (cached) yes 
    checking for gdImageGif in -lgd... (cached) yes 
    checking for gdImagePng in -lgd... (cached) no 
    checking the weather... (cached) its fine 
    checking if we can use GCC-specific compiler options... (cached) yes 
    creating ./config.status 
    creating Makefile 
    ordering CD from http://cdnow.com/gift/oetiker@ee.ethz.ch .... just kidding ;-) 

    ---------------------------------------------------------------- 
    Config is DONE! 

    Type 'make' to compile the software 

           ... that wishlist mentioned above does realy exist. So if 
    you feel like showing your appreciation for rrdtool this is the 
    place to go. :-) 

                                -- Tobi Oetiker <oetiker@ee.ethz.ch> 
    ----------------------------------------------------------------

     
  9. 開始編譯

  10.  
    [root@test mrtg-2.8.8]# make 
    /usr/bin/perl -0777 -pi -e 's@^#!\s*/\S*perl@#! /usr/bin/perl@' run/cfgmaker rug 
    /usr/bin/perl -0777 -pi -e 's@(day|week|month|year|peri.)\.(png|gif)@$1.gif@g' r 
    [root@test mrtg-2.8.8]#
     
  11. 將MRTG的logo圖檔copy到/home/httpd/html/mrtg底下:

  12.  
    [root@test mrtg-2.8.8]# mkdir /home/httpd/html/mrtg 
    [root@test mrtg-2.8.8]# cp images/mrtg*.gif /home/httpd/html/mrtg
    [說明]:一般而言,通常我們將mrtg繪製好的圖檔及html檔放在WWW網站上,直接讓user查詢。所以我們選擇放在apache(WWW server)的目錄底下(/home/httpd/html),再放一個新目錄來存mrtg所繪製出來的圖檔及html檔,同時我們也要將mrtg的logo圖案存放於此目錄,以示尊重原著作者。
    mkdir /home/httpd/html/mrtg是製造一個新的目錄mrtg在/home/httpd/html底下。
    cp images/mrtg*.gif /home/httpd/html/mrtg是將logo圖檔複製到/home/httpd/html/mrtg底下。
     
  13. 設定mrtg的組態檔

  14.  
    [root@test mrtg-2.8.8]# cd run 
    [root@test run]# ./cfgmaker public@163.18.225.254>mrtg.cfg
    [說明]:先要知道您所要監控的 device 的 SNMPOID  (Zylan 4024 預設 public),device的IP(若您的Zylan 4024是當router的話,則是.254;以漢民國小為例:漢民國小的IP為163.18.225.0,Zylan 4024則為163.18.225.254,再加上snmpoid,則為public@163.18.225.254)
    cd run是進入mrtg設定目錄
    ./cfgmaker public@163.18.225.254>mrtg.cfg是執行設定程式cfgmaker針對public@163.18.225.254這項設備,並將結果轉向成mrtg.cfg這個檔案。
     
  15. 修改mrtg.cfg檔

  16.  
    [root@test run]# qe mrtg.cfg
    以類似PE2的文書處理器來依實際情況編修設定檔。因作者在做中文化同時,己將高雄市國中小的設備狀況列入修改範圍,因此需要修改的地方非常少!
     
    在Target[163.18.225.254.2001]: -2001:public@163.18.225.254(IP位置會依實際情況而不同) 
    中2001代表Zylan 4024的S2/1 port,也就是接ATU-R的port,可用來當成對外的流量! 
    -2001應改為2001,其餘port均保留負號不變。
     
    找出各 port 之使用 server 及 相對編號 

        [XzLan 4024]: 
     
        2001 : S2/01 
        3001 : S3/01 

    修改各個port的抬頭說明: 
    找到<BR><FONT color="#ff0000" SIZE=5>[xxxx國小 - xxxx伺服器 (2001)]</FONT> 
    這行,將[...]內的文字加以修改。 
    注意:(2001)內的號碼請勿加以修改,那是對應到您設備port號碼

     
  17. 第一次執行mrtg

  18.  
    [root@test run]# cd /home/mrtg/run 
    [root@test run]# ./mrtg mrtg.cfg
     
  19. 檢查mrtg的log檔,gif檔及html檔是否正確存在

  20.  
    [root@test run]# cd /home/httpd/html/mrtg/ 
    [root@test mrtg]# ls -al
    正確的話您會看到一堆依ip.port為檔名的各種.gif,.gif.meta,.html,.log檔
     
  21. 修改排程檔

  22.  
    [root@test mrtg]# cd /home/mrtg-2.8.8 
    [root@test mrtg-2.8.8]# qe cron.mrtg
    若您的mrtg不是安裝在/home底下者,請修改mrtg及mrtg.cfg的絕對路徑。
     
  23. 將排程併入root的時間排程內

  24.  
    [root@test mrtg-2.8.8]# crontab cron.mrtg
     
  25. 檢查root的時間排程是否正確

  26.  
    [root@vdn1 mrtg-2.8.8]# crontab -l 
    # DO NOT EDIT THIS FILE - edit the master and reinstall. 
    # (cron.mrtg installed on Tue Oct 26 15:19:16 1999) 
    # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/mrtg-2.8.8/run/mrtg /home/mrtg-2.8.8/run/mrtg.cfg
     
  27. 設計 Web server 之首頁索引頁。
  28.     每一 port 之統計圖在 163.18.242.254.xxxx.html 中 (xxxx 為 port 代碼)
        位址如下 : http://<web server IP or domain name >/<traffic data directory>/<traffic data html>
                   <web server IP> : 福康流量統計網站 : mrtg.fkps.kh.edu.tw
                   <traffic data directory> : 目錄  nettraffic \
                   <traffic data html> : 單一 port 之流量統計網頁 163.18.242.254.2001.html
        如:
     
        2001 port : http://mrtg.fkps.kh.edu.tw/nettraffic/163.18.242.254.2001.html

十、附記: