分类:
2008-06-11 10:49:07
先安装apache
#apt-get install apache
or
#apt-get install apache2
因为mrtg要依赖于 SNMP服务,所以要安装snmpd
# apt-get install snmpd
默认snmpd服务是不对外开放的所以要编辑一下配置文件
# vi /etc/snmp/snmpd.conf
将
# sec.name source community
com2sec paranoid default public
#com2sec readonly default public
#com2sec readwrite default private
改成
# sec.name source community
#com2sec paranoid default public
com2sec readonly default mypublic
#com2sec readwrite default private
重启服务
# /etc/init.d/snmpd restart
这样就可以用mypublic来访问snmpd服务了
下面就可以开始装mrtg了
# apt-get install mrtg
mrtg会自动添加到cron服务中每5分钟运行一次
现在开始配置mrtg了
$ cfgmaker --global "WorkDir: /var/www/mrtg" \
--global "Options[_]: growright,bits" \
--ifref=ip mypublic @127.0.0.1 > mrtg.cfg
如果前面配置的正确cfgmaker就可以正确的生成一个mrtg.cfg文件了
去掉注释
-------------------------------------------------------------------
传说中的分割线
------------------------------------------------------------------
mrtg can use more the snmp especially own scripts or just the output of commands. as a starting point here are my config stanzas for CPU&co (all found somewhere on the net and adapted):
# Memory Utilization
# -------------------
Target[guinan_memory]: `free | awk '/buffers\/cache/ {print $3; print $4}'`
Options[guinan_memory]: nopercent,gauge,noinfo,growright, unknaszero
Title[guinan_memory]: Memory Utilization
PageTop[guinan_memory]: Memory Utilization on guinan
MaxBytes[guinan_memory]: 385476
kMG[guinan_memory]: k,M,G,T,P,X
YLegend[guinan_memory]: RAM Utilization
ShortLegend[guinan_memory]:
Legend1[guinan_memory]: Free guinan_memory
Legend2[guinan_memory]: Used guinan_memory
Legend3[guinan_memory]: Maximum free guinan_memory
Legend4[guinan_memory]: Maximum used guinan_memory
LegendI[guinan_memory]: Free mem
LegendO[guinan_memory]: Used mem
WithPeak[guinan_memory]: ymw
Unscaled[guinan_memory]: dwmy
Directory[guinan_memory]: system
# cpu-time
Target[guinan-cpu_time]: `/usr/bin/awk '/cpu /{OFMT="%d"; print $2+$3; print $2+$3+$4; print $5/100/
60/60/24 " days"; print "guinan"}'Processor stats
MaxBytes[guinan-cpu_time]: 100
Options[guinan-cpu_time]: growright,nopercent
LegendI[guinan-cpu_time]: user:
LegendO[guinan-cpu_time]: total:
Ylegend[guinan-cpu_time]: %
ShortLegend[guinan-cpu_time]: %
Legend1[guinan-cpu_time]: Time spent in user mode
Legend2[guinan-cpu_time]: Time spent in user mode + time spent in system mode
Legend3[guinan-cpu_time]: Maximum occurance of time spent in user mode
Legend4[guinan-cpu_time]: Maximum occurance of (time spent in user mode + time spent in system mode)
Unscaled[guinan-cpu_time]: dwmy
Directory[guinan-cpu_time]: system
# users
Target[guinan-users]: `who | wc -l | awk '{OFMT="%d"; print $1; print "0"}'`
Title[guinan-users]: Logged in users on guinan
PageTop[guinan-users]: Logged in users on guinan
MaxBytes[guinan-users]: 10
Options[guinan-users]: growright,nopercent,gauge
LegendI[guinan-users]: users:
LegendO[guinan-users]:
Ylegend[guinan-users]: count
ShortLegend[guinan-users]: user(s)
Legend1[guinan-users]: Number of logged in users
spent in system mode)
Directory[guinan-users]: system
# space on hda1
Target[guinan-hda1]: `df -l | awk '/hda1/ {OFMT="%d"; print $3*1024; print $4*1024}'`
Title[guinan-hda1]: Disk usage: /dev/hda1 on guinan
PageTop[guinan-hda1]: Disk usage: /dev/hda1 on guinan (/)
MaxBytes[guinan-hda1]: 8217464832
Options[guinan-hda1]: growright,gauge
LegendI[guinan-hda1]: used:
LegendO[guinan-hda1]: available:
Ylegend[guinan-hda1]: byte
ShortLegend[guinan-hda1]: byte
Legend1[guinan-hda1]: Used space
Legend2[guinan-hda1]: Available space
Legend3[guinan-hda1]: Maximum used space
Legend4[guinan-hda1]: Maximum available space
Unscaled[guinan-hda1]: dwmy
Directory[guinan-hda1]: system
-------------------------------------------------------------------
传说中的分割线
------------------------------------------------------------------
【参考】