一、前期准备
(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本机操作步骤:
1、cfgmaker生成配置文件
/usr/local/mrtg/bin/cfgmaker public@192.168.1.250 public@192.168.1.251 --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(此处MRTG的WEB目录)
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
本文详细介绍MRTG网络监控工具的安装与配置过程,包括前期准备如SNMP服务配置、HTTP服务及必要软件包安装,以及MRTG的具体安装步骤。
280

被折叠的 条评论
为什么被折叠?



