Centos7 MRTG-2.17.4安裝

Multi Router Traffic Grapher------MRTG是一個監控網絡鏈路流量負載的工具軟件,通過snmp協議得到設備的流量信息,並將流量負載以包含PNG格式的圖形的HTML 文檔方式顯示給用戶,以非常直觀的形式顯示流量負載。 

一、前期準備 

(1)MRTG需要以SNMP服務爲基礎,所以請確保你的系統已經啓用了此服務,修改SNMP的配置: 
#vi /etc/snmp/snmpd.conf 
將62行: 
access notConfigGroup "" any noauth exact systemview none none 
改爲 
access notConfigGroup "" any noauth exact mib2 none none 
把第89行前面的註釋符號#去掉,變成 
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc 

(2)linux Mrtg監控主機流量啓動http服務和snmp服務: 
首先查看兩個服務在系統啓動時是否已經開啓 
#chkconfig --list | grep nginx 
沒有啓動的話需要修改下在什麼啓動模式下要自己啓動: 
# chkconfig --level 35 nginx on 
對 snmpd 服務採用同樣的設置,現在手動啓動下 
#service nginx start 
#service snmpd start 
啓動之後最好是用setup配置服務,讓其隨機自動啓動 

查看端口的開啓狀況也可確認其是否已經被啓動 
# netstat -tunlp |grep snmp 
tcp 0 0 0.0.0.0:199 0.0.0.0:* LISTEN 4973/snmpd 
udp 0 0 0.0.0.0:161 0.0.0.0:* 4973/snmpd 

(3)MRTG生成供瀏覽圖像需要http服務的支持,同時也需要gd、libpng和zlib三個軟件包的支持,而gd的正常運行也需要其它的幾個軟件,(系統默認自帶,如果沒有自帶則需要我們手工安裝) 
1.安裝zlib-1.2.3 
#tar zxvf zlib-1.2.3.tar.gz 
#cd zlib-1.2.3 
#./configure --prefix=/usr/local/zlib 
#make 
#make install 

2.安裝httpd-2.2.4 
#tar zxvf httpd-2.2.4.tar.gz 
#cd httpd-2.2.4 
#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-track-vars --enable-rewrite --with-z-dir=/usr/local/zlib 
#make 
#make install 
啓動httpd 
/usr/local/apache/bin/apachectl -k start 

3.安裝libpng-1.2.14 
#tar zxvf libpng-1.2.14.tar.gz 
# cd libpng-1.2.14 
# cp scripts/makefile.linux makefile 
# make (若是提示找不到zlib庫文件或者頭文件,多半是makefile文件裏zlib的默認路徑有誤。可編輯makefile文件,找到zlib項並重新指定路徑到/usr/local/zlib/lib和/usr/local/zlib/include)。 
# make install 

4.安裝freetype-2.1.10 
# tar -zvxf freetype-2.1.10.tar.gz 
# cd freetype-2.1.10 
# mkdir -p /usr/local/freetype 
# ./configure --prefix=/usr/local/freetype 
# make;make install 

5.安裝jpegsrc.v6b 
jpeg默認不會自建目錄,因此需手動建立目錄: 
# mkdir -pv /usr/local/jpeg6/{,bin,lib,include,man/{,man1},man1} 
安裝 
#tar zxvf jpegsrc.v6b.tar.gz 
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static 
# make 
# make install 
# make install-lib 

6.安裝libxml2-2.6.19 
# tar -zxf libxml2-2.6.19.tar.gz 
# cd libxml2-2.6.19 
# mkdir -p /usr/local/libxml2 
# ./configure --prefix=/usr/local/libxml2 
# make; make install 
#cp xml2-config /usr/bin 

7.安裝GD-2.0.33庫 
# tar -zvxf gd-2.0.33.tar.gz 
# mkdir -p /usr/local/gd2 
# cd gd-2.0.33 
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/zlib/ --with-freetype=/usr/local/freetype/ 
# make 
# make install 

(4)修改系統語言配置 
#vi /etc/profile 
增加如下兩行 
LC_ALL=C 
LANGUAGE=on 

二、開始安裝 

(1)開始安裝mrtg 
#cd /usr/local/src 
#wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.14.5.tar.gz 
#tar zvxf mrtg-2.14.5.tar.gz 
#cd mrtg-2.14.5 
#./configure --prefix=/usr/local/mrtg 注意:“--prefix=/usr/local/mrtg”是指定的安裝路徑 
#make 

#make install 

Linux本機操作步驟:

1cfgmaker生成配置文件

/usr/local/mrtg/bin/cfgmaker [email protected] [email protected] --global"WorkDir: /var/www/html/mrtg" --global "Options[_]:growright,bits" --ifref=ip --output /usr/local/mrtg/bin/mrtg.cfg

2、修改配置文件: 
#vi mrtg.cfg 
a.#WorkDir:/home/http/mrtg 去掉註釋改爲 WorkDir: /var/www/html/mrtg(此處MRTGWEB目錄
b. #Options[_]: growright, bits 前面的#去掉,靠左對齊 
c.在最後加上Language: GB2312,然後保存 

### Global Config Options

RunAsDaemon: yes

3、創建初始web頁面

cd /var/www/html/mrtg

/usr/local/mrtg/bin/mrtg /usr/local/mrtg/bin/mrtg.cfg(此命令失敗,請執行下面命令)

env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/mrtg/bin/mrtg.cfg

4、生成索引首頁

/usr/local/mrtg/bin/indexmaker /usr/local/mrtg/bin/mrtg.cfg --output /var/www/html/mrtg/index.html

 

 總結、成立監控中心

     當我們有多個服務器來監控的時候,就需要成立一個監控中心來對我們的所有的服務器進行監控,這時候就會用到"indexmaker"這個命令,具體的用法如下所示:"perl indexmaker mrtg.cfg>D:/MRTGOutPut/index.htm文件的話,我們可以用perl indexmaker




發佈了75 篇原創文章 · 獲贊 37 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章