mrtg源碼包 服務器監控 流量監控

linux MRTG 搭建實驗文檔
 
os 版本 Rad Hat Enterprise Linux 5
還須要有 apache 的支持 , 本次試驗 apache 安裝在 /usr/local/apache
 
所需軟件安裝包以下 均爲源代碼安裝包
gd- 2.0.33 .tar.gz
zlib- 1.2.3 .tar.gz
libpng- 1.2.15 .tar.gz
jpegsrc.v6b.tar.gz
freetype- 2.1.9 .tar.gz
fontconfig- 2.3.2 .tar.gz
mrtg- 2.13.2 .tar.gz
 
 
1、安裝在 MRTG 所需的組件
1 、安裝 GD
     安裝命令以下
     tar -zxvf gd- 2.0.33 .tar.gz
      cd gd- 2.0.33
      ./configure
      若是在輸出信息中以下圖  
   Support for PNG library: no
    Support for JPEG library: no
    Support for Freetype 2.x library: no
    Support for Fontconfig library: no
   Support for Xpm library: no
   Support for pthreads: yes
     若是都顯示的爲 yes ,咱們就能夠直接去裝 MRTG 了,這次環境中只有      一項顯示爲 yes, 因此還要安裝其組件
2 、安裝 zlib
   tar -xvf zlib- 1.2.3 .tar.gz
   cd zlib- 1.2.3
   ./configure
   make
   make install
3. 安裝 libpng
   tar -zxvf libpng- 1.2.15 .tar.gz
   cd libpng- 1.2.15
   ./configure
   cp scripts/makefile.std makefile( 能夠不要 )
   make
   make install
4 、安裝 JPEG
   tar -zxvf jpegsrc.v6b.tar.gz
    cd jpeg-6b
./configure --enable-static --enable-shared 必須有
   make
   make install
5 、安裝安裝 Freetype
   tar -zxvf freetype- 2.1.9 .tar.gz
   cd freetype- 2.1.9
   ./configure
   make
   make install
6 、安裝 Fontconfig (若是提示 expat to old, 則安裝 expat expat-devel
   tar -zxvf fontconfig- 2.3.2 .tar.gz
   cd fontconfig- 2.3.2 .tar.gz
   ./configure
   make
   make install
7 、編譯 GD
  cd gd- 2.0.33
  ./configure
    make
    make install
 
 
2、安裝 mrtg
   tar -zxvf mrtg- 2.13.2 .tar.gz
   cd mrtg- 2.13.2
    ./configure --prefix=/usr/local/mrtg --with-gd=/usr/include --with-gd-lib=/usr/lib --with-gd-inc=/usr/include --with-png=/usr/include --with-png-lib=/usr/lib --with-zlib=/usr/include --with-zlib-lib=/usr/lib
   make
   make install
 
3、調整參數,對端口進行流量監控
 1 生成 mrtg.cfg 文件,用於存放 mrtg 配置信息
 /usr/local/mrtg/bin/cfgmake —output /usr/local/apache/htdocs/mrtg.cfg   public@121.52.209.160 laoda@121.52.214.63 public@121.52.214.10
 
 2 、修改 mrtg.cfg 文件參數
      vi /usr/local/apache/htdocs/mrtg.cfg
     # 去掉   Workdir 後的路徑改爲 /usr/local/apache/htdocs   :指定 mrtg 的工做目錄
     #Options[_]: growright, bits  :前面的 # 去掉
     在加入一行 Language:Chinese :使 mrtg 支持中文
 
  3 env LANG=C /usr/local/mrtg/bin/mrtg   /usr/local/apache/htdocs/mrtg.cfg   :多執行幾遍,直到不出現信息
 
 
4 、生成頁面文件
/usr/local/mrtg/bin/indexmaker --output /usr/local/apache/htdocs/index.html --title=ruishengIDC  /usr/local/apache/htdocs/mrtg.cfg (中間的參數能夠省略)
 
5 、讓數據自動刷新
  crontab -e
而後寫入 */5 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg.cfg ( 注:如以前未加 env LANG=C 的話,則這裏也不用加) , 意思爲讓系統在後臺每五分鐘執行一次 env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg.cfg)
  注:第三塊調整參數時有前後順序,如只出來的圖上沒有顯示流量有多是步驟執行前後錯誤,使用 rm -f /usr/local/apache/htdocs/.mrtg.cfg.swp 清除一下緩存,而後在按照順序執行一下便可
相關文章
相關標籤/搜索