監(jiān)測(cè)Linux上面的流量MRTG-安裝MRTG
監(jiān)測(cè)Linux上面的流量MRTG-安裝MRTG
本文講述的是監(jiān)測(cè)Linux上面的流量MRTG:前言、安裝MRTG準(zhǔn)備工作、安裝MRTG
監(jiān)測(cè)網(wǎng)路卡流量、mrtg.cfg參數(shù)的含義、監(jiān)測(cè)CPU負(fù)載量
開(kāi)始安裝 MRTG
由于 MRTG 是透過(guò) SNMP 通訊協(xié)定來(lái)要求資料,因此你的 Linux 上面需要先安裝相關(guān)的軟體,通常我們都是安裝 ucd-snmp 這套軟體的,那就來(lái)安裝吧!
下載 ucd-snmp-4.2.1.tar.gz, mrtg-2.9.17.tar.gz ;
安裝 ucd-snmp-4.2.1.tar.gz: [root @tsai /root]# cd /usr/local/src
- [root @tsai src]# cp /root/ucd-snmp-4.2.1.tar.gz .
- [root @tsai src]# tar -zxvf ucd-snmp-4.2.1.tar.gz
- [root @tsai src]# cd ucd-snmp-4.2.1
- [root @tsai ucd-snmp-4.2.1]# ./configure --prefix=/usr/local/snmp
- .......(過(guò)程我就省略了)
- ************** 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@):root@tsai.adsldns.org (這裡輸入你的 e-mail)
- setting System Contact Information to... root@tsai.adsldns.org
- checking 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 6.1 (這裡可以隨便輸入,不正確也沒(méi)關(guān)係)
- setting System Location to... RedHat 6.1
- 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 即可)
- [root @tsai ucd-snmp-4.2.1]# make
- [root @tsai ucd-snmp-4.2.1]# make install
上面輸入的資訊,在進(jìn)行 MRTG 的製圖時(shí),會(huì)顯示在圖表上面,不過(guò),這也是可以改的資訊,所以,如果不小心輸入錯(cuò)誤也沒(méi)關(guān)係的。這樣就將 ucd-snmp 安裝妥當(dāng)了!
啟動(dòng) ucd-snmp :
直接在 shell 下面打上 /usr/local/snmp/sbin/snmpd 即可!或者直接加在 /etc/rc.d/rc.local 當(dāng)中,就可以自動(dòng)開(kāi)機(jī)時(shí)啟動(dòng)了!
安裝 MRTG :
- [root @tsai /root]# cd /usr/local/src
- [root @tsai src]# cp /root/mrtg-2.9.17.tar.gz .
- [root @tsai src]# tar -zxvf mrtg-2.9.17.tar.gz
- [root @tsai src]# cd mrtg-2.9.17
- [root @tsai mrtg-2.9.17]# ./configure --prefix=/usr/local/mrtg-2 \
- > --with-gd=/usr/include \
- > --with-gd-lib=/usr/lib \
- > --with-gd-inc=/usr/include \
- > --with-png=/usr/include \
- > --with-zlib=/usr/include
- [root @tsai mrtg-2.9.17]# make; make install
[root @tsai mrtg-2.9.17]# mkdir /usr/local/apache/htdocs/mrtg (請(qǐng)注意,這裡與你的 WWW 主頁(yè)的放置地點(diǎn)有關(guān),請(qǐng)依你的系統(tǒng)來(lái)設(shè)定,另外,由于我們需要設(shè)定 網(wǎng)路流量、CPU與RAM使用率,因此在 mrtg 中,可以再建立叁個(gè)子目錄,比較容易管理啦!)
- [root @tsai mrtg-2.9.17]# mkdir /usr/local/apache/htdocs/mrtg/net
- [root @tsai mrtg-2.9.17]# cp images/* /usr/local/apache/htdocs/mrtg/net (將一些影像檔拷貝到即將使用的目錄中去備用)
就樣就安裝妥當(dāng)了!再來(lái)就是開(kāi)始要設(shè)定 MRTG 的組態(tài)啰!
【編輯推薦】