[网络监控]MRTG的安装使用

admin 发表于 Linux, WEB, 网络技术 分类,标签: , ,
0

 23_r1_c1

MRTG是一个古老的网络监控程序,很多的网络都是有它监控的,比较著名的例子就是教育网北邮地区网流量图http://www.buptnet.edu.cn/mrtg/大家在这个图中可以看到网络的实时流量。

下面我们就来安装一下。

软件名称MRTG(The Multi Router Traffic Grapher )
官方网站http://oss.oetiker.ch/mrtg/
下载地址http://oss.oetiker.ch/mrtg/pub/?M=D

安装过程

1.需要安装的软件

gd gd-devel libpng libpng-devel libpng10 libpng10-devel perl zlib zlib-devel httpd gcc net-snmp mrtg

2.用yum或者源码包装好后,开始配置snmp

#vi /etc/snmp/snmpd.conf
把第89行前面的注释符号#去掉,变成 view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
在62行进行修改:将access notConfigGroup “” any noauth exact systemview none none
改为access notConfigGroup “” any noauth exact mib2 none none
启动http服务和snmp服务:
# service httpd start
#service snmpd start

3.开始安装MRTG

# tar -zxvf mrtg-2.11.1.tar.tar -C /usr/local/src/
【解压到/usr/local/src,其实放哪无所谓的】
#cd /usr/local/src/mrtg-2.11.1/
#./configure –prefix=/usr/local/mrtg
#make && make install

4.配置MRTG

在Apache的网页目录下建一个文件夹mrtg及其子文件夹images
#mkdir /var/www/html/mrtg
#mkdir /var/www/html/mrtg/images
把源码包中的images里面的所有文件都复制过来
# cd /usr/local/src/mrtg-2.11.1/
#cp ./images/* /var/www/html/mrtg/images

mrtg附带有一个cfgmaker工具,他会帮助你编写配置文件,并自动生成配置文件。在bin子目录下可以看到该脚本
#/usr/local/mrtg/bin/cfgmaker public@192.168.1.50 –global “workdir: /var/www/html/mrtg “  –output=/var/www/html/mrtg/lxy.cfg
【192.168.1.50为被监控的主机,public为SNMP的团体名】

修改配置文件
#vi /var/www/html/mrtg/lxy.cfg
将#Options[_]: growright, bits前面的#去掉,靠左对齐并修改为Options[_]: growright, bytes,提示“bytes”是unknown,原来不可以像windows下使用bytes,还换回原来的bits。在最后加上Language: GB2312,然后wq保存。

5.生成图像

#  env LANG=C /usr/local/mrtg/bin/mrtg /var/www/html/mrtg/lxy.cfg
如果有警告错,多运行几次次,警告错不再出现就ok了。

6.制作首页

# /usr/local/mrtg/bin/indexmaker –output=/var/www/html/mrtg/index.html –title=”标题” /var/www/html/mrtg/lxy.cfg

7.其他设定

设定5分钟运行一次:#crontab -e编辑模式输入*/5 * * * * /root/mrtgbin/mrtg /root/mrtg/lxy.cfg保存

使用http://192.168.1.30/mrtg,你应该就可以看到网络使用情况的曲线了。

参考资料http://crazylinux.blog.51cto.com/259244/159571

后记:

1.关于中文乱码:cfg文件最后加上Language: GB2312,如果还不行apache配置文件中的AddDefaultCharset utf-8改成gb2312

2.关于首页,这个index.html拿到Dreamweaver下自行编辑就行,添加设备仿照上面的来就行。


发表我的评论

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word