一、 MRTG生成供浏览图像需要httpd服务的支持,同时也需要gd、libpng和zlib三个软件包的支持,而gd的正常运行也需要其它的几个软件,下面一并安装它们
标红的字是网上说的,但我没有那样做
1.安装zlib-1.2.6
#tar zxvf zlib-1.2.6.tar.gz
#cd zlib-1.2.6
#./configure --prefix=/usr/local/zlib
#make
#make install
2.安装httpd-2.2.15
#tar zxvf httpd-2.2.15.tar.gz
#cd httpd-2.2.15
#./configure --prefix=/usr/local/apache2 --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.146
#tar zxvf libpng-1.2.16.tar.gz
# cd libpng-1.2.16
# 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 -zjxf freetype-2.1.10.tar.bz2
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
# make;make install
5.安装jpegsrc.v7b
jpeg默认不会自建目录,因此需手动建立目录:
# mkdir -pv /usr/local/jpeg6/{,bin,lib,include,man/{,man1},man1}
安装
#tar zxvf jpegsrc.v7.tar.gz
# ./configure --prefix=/usr/local/jpeg7/ --enable-shared --enable-static
# make
# make install
# make install-lib
6.安装libxml2-2.6.20
# tar -zxf libxml2-2.6.20.tar.gz
# cd libxml2-2.6.20
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make; make install
#cp xml2-config /usr/bin
7.安装GD-2.0.35库
# tar -zvxf gd-2.0.35.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg7/ \
--with-png=/usr/local/libpng/ \
--with-zlib=/usr/local/zlib/ \
--with-freetype=/usr/local/freetype/
# make
# make install
二、MRTG的安装
1.下载mrtg,目前最新版本为mrtg-2.17.4
http://oss.oetiker.ch/mrtg/pub/mrtg-2.17.4.tar.gz
2.安装mrtg-2.17.4
#tar zxvf mrtg-2.17.4.tar.gz
# cd mrtg-2.17.4
# ./configure --prefix=/usr/local/mrtg --sysconfdir=/etc/mrtg
--with-gd=/usr/local/gd2/include
--with-gd-lib=/usr/local/gd2/lib
--with-gd-inc=/usr/local/gd2/include
--with-png=/usr/local/libpng/include
--with-png-lib=/usr/local/libpng/lib
--with-png-inc=/usr/local/libpng/include
--with-zlib=/usr/local/zlib/include
--with-zlib-lib=/usr/local/zlib/lib
--with-zlib-inc=/usr/local/zlib/include
# make
# make install
三、配置MRTG
[root@localhost bin]# cd /usr/local/mrtg/bin
[root@localhost bin]# ./cfgmaker --global 'WorkDir: /usr/local/apache2/htdocs' --global 'Options[_]: bits,growright' --global 'Language: GB2312' --output /usr/local/apache2/htdocs/mrtg.cfg
[root@localhost bin]# /bin/env LANG=en_US ./mrtg /usr/local/apache2/htdocs/mrtg.cfg
[root@localhost bin]# ./indexmaker --output="/usr/local/apache2/htdocs/index.html" --title="Taffic Monitor Center" /usr/local/apache2/htdocs/mrtg.cfg
ERROR: unable to open config file: /usr/local/apache2/htdocs/cfg/mrtg.cfg
[root@localhost bin]# ./indexmaker --output="/usr/local/apache2/htdocs/index.html" --title="Taffic Monitor Center" /usr/local/apache2/htdocs/mrtg.cfg
add other servers:
[root@localhost bin]# ./cfgmaker [email protected]>> /usr/local/apache2/htdocs/mrtg.cfg
[root@localhost bin]# ./indexmaker --output="/usr/local/apache2/htdocs/index.html" --title="Taffic Monitor Center" /usr/local/apache2/htdocs/mrtg.cfg
[root@localhost bin]# /bin/env LANG=en_US ./mrtg /usr/local/apache2/htdocs/mrtg.cfg
生成mrtg.cfg文件,用于存放mrtg配置信息
[root@localhostbin]#/usr/local/mrtg/bin/cfgmaker ——output /usr/local/apache/htdocs/mrtg.cfg [email protected] (public为SNMP团体名称,ip为被监控的设备。)
修改mrtg.cfg文件参数
[root@localhostbin]# vi /usr/local/apache/htdocs/mrtg.cfg
把#去掉 把Workdir后的路径改成/usr/local/apache/htdocs :指定mrtg的工作目录
把#Options[_]: growright, bits :前面的#去掉
在加入一行Language:Chinese :使mrtg支持中文
[root@localhostbin]#env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg.cfg :多执行几遍,直到不出现信息,生成页面文件,让数据自动刷新
crontab -e
四、被监控机
一、MRTG需要以SNMP服务为基础,所以请确保你的系统已经启用了此服务
1.请确保你的系统安装了以下软件包
net-snmp-5.0.6-17
net-snmp-devel-5.0.6-17
net-snmp-utils-5.0.6-17
2.修改/etc/snmp/snmpd.conf
去掉如下一行的注释
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
在大约55行处添加如下一行
view systemview included .1.3.6.1.2.1.2
把如下行
access notConfigGroup "" any noauth exact systemview none none
改作:
access notConfigGroup "" any noauth exact mib2 none none
3.启用snmpd服务
#service snmpd start
#chkconfig --levle 2345 snmpd on
4.查看端口的开启状况
# 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