免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1165 | 回复: 0
打印 上一主题 下一主题

在FreeBSD平台下使用mrtg来监控cpu、内存、交换分区、TCP连接以及本机网卡流量 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-01 09:50 |只看该作者 |倒序浏览

介绍在FreeBSD平台下如何安装和使用mrtg来监控cpu、内存、交换分区、TCP连接以及本机网卡流量
1.安装
#安装apache2
cd /usr/ports/www/apache2
make install clean
#安装p5-SNMP
cd  /usr/ports/net-mgmt/p5-SNMP
make install clean
#安装mrtg
cd /usr/ports/net-mgmt/mrtg
make install clean
2.编写配置文件
LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
WorkDir: /usr/local/www/data/mrtg
Language: chinese
#monitoring User vs Idle CPU usage
Target[kontor.cpu]:ssCpuRawUser.0&ssCpuRawIdle.0:public@192.168.0.150
RouterUptime[kontor.cpu]:
public@192.168.0.150
MaxBytes[kontor.cpu]: 100
Title[kontor.cpu]: CPU LOAD
PageTop[kontor.cpu]: User CPU Load %
Unscaled[kontor.cpu]: ymwd
ShortLegend[kontor.cpu]: %
YLegend[kontor.cpu]: CPU Utilization
Legend1[kontor.cpu]: User CPU in % (Load)
Legend2[kontor.cpu]: Idle CPU in % (Load)
LegendI[kontor.cpu]:  User
LegendO[kontor.cpu]:  Idle
Options[kontor.cpu]: growright,nopercent
#monitoring User vs System CPU usage
Target[kontor.usrsys]:ssCpuRawUser.0&ssCpuRawSystem.0:public@192.168.0.150
RouterUptime[kontor.usrsys]:
public@192.168.0.150
MaxBytes[kontor.usrsys]: 100
Title[kontor.usrsys]: CPU LOAD
PageTop[kontor.usrsys]: CPU (user and system) Load %
Unscaled[kontor.usrsys]: ymwd
ShortLegend[kontor.usrsys]: %
YLegend[kontor.usrsys]: CPU Utilization
Legend1[kontor.usrsys]: User CPU in % (Load)
Legend2[kontor.usrsys]: System CPU in % (Load)
LegendI[kontor.usrsys]:  User
LegendO[kontor.usrsys]:  System
Options[kontor.usrsys]: growright,nopercent
#monitoring Active CPU usage
Target[kontor.cpusum]:ssCpuRawUser.0&ssCpuRawUser.0:public@192.168.0.150 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@192.168.0.150 + ssCpuRawNice.0&ssCpuRawNice.0:public@192.168.0.150
RouterUptime[kontor.cpusum]:
public@192.168.0.150
MaxBytes[kontor.cpusum]: 100
Title[kontor.cpusum]: CPU LOAD
PageTop[kontor.cpusum]: Active CPU Load %
Unscaled[kontor.cpusum]: ymwd
ShortLegend[kontor.cpusum]: %
YLegend[kontor.cpusum]: CPU Utilization
Legend1[kontor.cpusum]: Active CPU in % (Load)
LegendI[kontor.cpusum]:  Active
Options[kontor.cpusum]: growright,nopercent
#Monitoring TCP connections
Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@192.168.0.150
Options[tcpopen]: nopercent,growright,gauge,noinfo
Title[tcpopen]: Open TCP connections
PageTop[tcpopen]: Open TCP connections
MaxBytes[tcpopen]: 1000000
YLegend[tcpopen]: # conns
ShortLegend[tcpopen]: connections
LegendI[tcpopen]:  Connections:
Legend1[tcpopen]: Open TCP connections
#Monitoring Free Memory
Target[freemem]: .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@192.168.0.150
Options[freemem]: nopercent,growright,gauge,noinfo
Title[freemem]: Free Memory
PageTop[freemem]: Free Memory
MaxBytes[freemem]: 1000000
kMG[freemem]: k,M,G,T,P,X
YLegend[freemem]: bytes
ShortLegend[freemem]: bytes
LegendI[freemem]:  Free Memory:
Legend1[freemem]: Free memory, not including swap, in bytes
#monitoring localhost ethernet traffic
Target[192.168.0.150_1]: 1:public@192.168.0.150:
SetEnv[192.168.0.150_1]: MRTG_INT_IP="192.168.0.150" MRTG_INT_DESCR="lnc0"
MaxBytes[192.168.0.150_1]: 100000000
Title[192.168.0.150_1]: Traffic Analysis for 1
PageTop[192.168.0.150_1]: Traffic Analysis for 1
Options[192.168.0.150_1]: growright,bits
将上面的代码保存为/usr/local/www/data/mrtg/mrtg.cfg
3.然后执行下面的命令,一共要执行三才,前两次会报错不用管,知道第三次没错就OK了,如果第三次还提示错误情检查配置文件
/usr/local/bin/mrtg /usr/local/www/data/mrtg/mrtg.cfg
4.制作索引页面
/usr/local/bin/indexmaker --output=/usr/local/www/data/mrtg/index.html /usr/local/www/data/mrtg/mrtg.cfg
5.crontab -e 编辑计划任务,添加下面一条任务
*/5  *  *  *  *  /usr/local/bin/mrtg /usr/local/www/data/mrtg/mrtg.cfg
好了,现在就就可以通过浏览器访问
http://192.168.0.150/mrtg
来监控你的计算机了
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=413917
[
点击此处收藏本文
]   发表于 2005年07月05日 8:34 AM
-->


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/14826/showart_79669.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP