构建MRTG监控中心
下面介绍如何在Linux上构建一个MRTG监控中心。
MRTG需要先安装Apache
一、MRTG启用了此服务
1.请确保你的系统安装了以下软件包
net-snmp-libs-5.1.2-11.EL4.10
net-snmp-5.1.2-11.EL4.10
net-snmp-utils-5.1.2-11.EL4.10
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
2.修改/etc/snmp/snmpd.conf
去掉如下一行的注释
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
- 1.
- 2.
在大约55行处添加如下一行
view systemview included .1.3.6.1.2.1.2
- 1.
- 2.
把如下行
access notConfigGroup "" any noauth exact systemview none none
- 1.
- 2.
改作:
access notConfigGroup "" any noauth exact mib2 none none
- 1.
- 2.
3.启用snmpd服务
#service snmpd start
#chkconfig --levle 2345 snmpd on
- 1.
- 2.
- 3.
- 4.
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
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
二、MRTG生成供浏览图像需要httpd服务的支持,同时也需要gd、libpng和zlib三个软件包的支持,而gd的正常运行也需要其
它的几个软件.
三:安装MRTG
下载
# tar zxvf mrtg-2.16.2.tar.tar
# cd mrtg-2.16.2
# ./configure --prefix=/usr/local/mrtg
# make
# make install
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
四:配置MRTG
生成配置文件:
# mkdir /etc/mrtg
# /usr/local/mrtg/cfgmaker public@localhost > /etc/mrtg/mrtg.cfg
- 1.
- 2.
- 3.
- 4.
编辑/etc/mrtg/mrtg.cfg
将
#WorkDir:/home/http/mrtg
- 1.
- 2.
去掉注释并改为
WorkDir: /usr/local/www/htdocs/mrtg (此处是你的httpd默认的主目录)
去掉如下行的注释
# Options[_]: growright, bits
- 1.
- 2.
添加如下行,实现网页中的中文字符显示
Language:gb2312
生成MRTG网页主页面文件
# /usr/local/mrtg/bin/indexmaker /etc/mrtg/mrtg.cfg --output=/usr/local/www/htdocs/mrtg/index.html --
title="My MRTG"
- 1.
- 2.
- 3.
- 4.
4.启动MRTG
# env LANG=C /usr/local/mrtg/bin/mrtg /etc/mrtg/mrtg.cfg
- 1.
- 2.
这个命令会输出一些错误信息,一般可以安全忽略,连续执行三次此命令即可。
5.MRTG生成的web页面是静态的,为了能让其不断的刷新,需要将以上命令添加进crontab
#crontab -e
- 1.
- 2.
添加如下一行
*/3 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /etc/mrtg/mrtg.cfg
- 1.
- 2.
【编辑推荐】