- 安装支持软件包
yum –y install gcc perl gd libpng zlib net-snmp mrtg
配置snmpd
编辑/etc/snmp/snmpd.conf文件
备份snmpd.conf文件,新建空白snmpd.conf. 添加如下内容保存即可
com2sec notConfigUser localhost public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact all none none
view all included .1 80
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root - 修改完成后重启snmpd
service snmpd restart
chkconfig snmpd on - 配置mrtg
默认的mrtg配置文件保存在/etc/mrtg/mrtg.cfg
建议使用命令生成mrtg.cfg模板。
cfgmaker public@localhost --output /etc/mrtg.cfg - 修改/etc/mrtg.cfg文件
只需将WorkDir: 修改为访问路径即可
如:WorkDir: /var/www/mrtg
mkdir /var/www/mrtg - 生成mrtg首页
Indexmaker /etc/mrtg/cfg > /var/www/mrtg/index.html
赋权:chmod 777 /usr/bin/rateup - 使用mrtg绘制数据图表
env LANG=C /usr/bin/mrtg /etc/mrtg.cfg - 创建定时任务
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg - 修改/etc/httpd/conf.d/mrtg.conf (默认只运行本机访问)
Alias /mrtg /var/www/mrtg
<Location /mrtg>
Order deny,allow
Deny from none
Allow from all
Allow from ::1
# Allow from .example.com
</Location>重启apache访问http://your-ip/mrtg/即可
参考:http://my.oschina.net/jack230230/blog/150470 (包括CPU、内存监控)