- 论坛徽章:
- 0
|
作者:kenthy
基于Ubuntu6.06的MRTG网络流量分析统计
2007.01.04 12:00 kenthy#qingdaonews.com
系统环境: ubuntu 6.06 [ kernel 2.6.15-26-686 ]
软件环境:
gcc 4.0.3-1ubuntu5
perl 5.8.7-10ubuntu
apache 2.2.0
相关软件:
libpng12-0_1.2.8rel-5ubuntu0.1_i386.deb
gdb_6.4-1ubuntu5.1_i386.deb
zlib1g_1.2.3-6ubuntu4.i386.deb
snmpd_5.2.1.2-4ubuntu2_i386.deb
mrtg_2.12.2-1_i386.deb
sysstat_6.0.2-1_i386.deb
配置过程:
1. 配置Apache网站服务器 [ DocumentRoot /opt/apache2/htdocs ]
#mkdir /opt/apache2/htdocs/mrtg
#mkdir /opt/mrtg
#mkdir /var/lock/mrtg
#/usr/sbin/apachectl start
2. 配置snmpd
1> 编辑/etc/snmp/snmpd.conf ,添加相应行或打开/关闭注释
#com2sec paranoid default public
com2sec readonly default public
#com2sec readwrite default private
view mib2 included .iso.org.dod.internet.mgmt.mib-2.system fc
access notConfigGroup "" any noauth exact mib2 none none
2> 启动snmpd服务
#ln -s /etc/init.d/snmpd /etc/rc2.d/S20snmpd
#/etc/init.d/snmpd start
3. 配置mrtg
1> 使用/usr/bin/cfgmaker工具创建/etc/mrtg.cfg初始化配置文件
#cfgmaker --global 'WorkDir:/opt/apache2/htdocs/mrtg' --global 'Options[_]:growright,bits' --global 'Language:Chinese' --ifref=ip
public@192.168.2.1
> /etc/mrtg.cfg
2> 增加CPU负载监控
a> 建立脚本
#cat > /opt/mrtg/mrtg.cpu 增加执行权限
#chmod 755 /opt/mrtg/mrtg.cpu
c> 追加配置信息到/etc/mrtg.cfg
#cat >> /etc/mrtg.cfg CPU Loading Statistic
EOF
3> 增加内存使用状况监控
a> 建立脚本
#cat > /opt/mrtg/mrtg.ram 增加执行权限
#chmod 755 /opt/mrtg/mrtg.www
c> 追加配置信息到/etc/mrtg.cfg
#cat >> /etc/mrtg.cfg Memory Useage Statistic
EOF
4> 增加网站连接负载监控
a> 建立脚本
#cat > /opt/mrtg/mrtg.www 增加执行权限
#chmod 755 /opt/mrtg/mrtg.www
c> 追加配置信息到/etc/mrtg.cfg
#cat >> /etc/mrtg.cfg WWW Connect Statistic
EOF
4. 运行mrtg建立网络流量/CPU负载/内存使用状况/网站连接负载等统计信息页面
1> 配置计划任务,每5分钟作一次数据分析
#crontab -e
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
#ln -s /etc/init.d/cron /etc/rc2.d/S89cron
2> 立即执行数据分析
#env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
3> 创建网页索引文件
#indexmaker /etc/mrtg.cfg > /opt/apache2/htdocs/mrtg/index.html
4> 访问
http://localhost/mrtg/
即可看到各统计信息画面
##############################################
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/24390/showart_365811.html |
|