监测Linux上面的流量MRTG-安装MRTG
本文讲述的是监测Linux上面的流量MRTG:前言、安装MRTG准备工作、安装MRTG
监测网路卡流量、mrtg.cfg参数的含义、监测CPU负载量
开始安装 MRTG
由于 MRTG 是透过 SNMP 通讯协定来要求资料,因此你的 Linux 上面需要先安装相关的软体,通常我们都是安装 ucd-snmp 这套软体的,那就来安装吧!
下载 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
- .......(过程我就省略了)
- ************** 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 (这裡可以随便输入,不正确也没关係)
- 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
上面输入的资讯,在进行 MRTG 的製图时,会显示在图表上面,不过,这也是可以改的资讯,所以,如果不小心输入错误也没关係的。这样就将 ucd-snmp 安装妥当了!
启动 ucd-snmp :
直接在 shell 下面打上 /usr/local/snmp/sbin/snmpd 即可!或者直接加在 /etc/rc.d/rc.local 当中,就可以自动开机时启动了!
安装 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 (请注意,这裡与你的 WWW 主页的放置地点有关,请依你的系统来设定,另外,由于我们需要设定 网路流量、CPU与RAM使用率,因此在 mrtg 中,可以再建立叁个子目录,比较容易管理啦!)
- [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 (将一些影像档拷贝到即将使用的目录中去备用)
就样就安装妥当了!再来就是开始要设定 MRTG 的组态啰!
【编辑推荐】