MRTG是个很方便的软件,安装好后,不需要对系统进行改动,只需要编辑.cfg文件,并重新生成网页就可以了。下面我们就以监控系统进程数、用户会话数、TCP连接情况、内存使用情况、硬盘使用情况等来说明操作方法。接上一篇文,我们以监控server01为例,修改server01文件,在该文件中加入以下代码:
#
# System Processes Info 系统进程信息
#
Target[server.processes]: .1.3.6.1.2.1.25.1.6.0&.1.3.6.1.2.1.25.1.6.0:public@192.168.50.249
Title[server.processes]: Current Processes Running
PageTop[server.processes]: <H1>Current Processes Running</H1>
MaxBytes[server.processes]: 1000
ShortLegend[server.processes]: procs
YLegend[server.processes]: Current Processes Running
Legend1[server.processes]: Processes
LegendI[server.processes]: Running
LegendO[server.processes]:
Options[server.processes]: growright,nopercent,gauge
#
# User Sessions Info 用户会话信息
#
Target[server.users]: .1.3.6.1.2.1.25.1.5.0&.1.3.6.1.2.1.25.1.5.0:public@192.168.50.249
Title[server.users]: Current Users Sessions
PageTop[server.users]: <H1>Current Users Sessions</H1>
MaxBytes[server.users]: 10000
ShortLegend[server.users]: Sessions
YLegend[server.users]: Current Users Sessions
Legend1[server.users]: Users Sessions
LegendI[server.users]: Sessions
LegendO[server.users]:
Options[server.users]: growright,nopercent,gauge
#
# Established TCP Connections
#
Target[server.estabcons]: tcpCurrEstab.0&tcpCurrEstab.0:public@192.168.50.249
Title[server.estabcons]: Currently Established TCP Connections
PageTop[server.estabcons]: <H1>Established TCP Connections</H1>
MaxBytes[server.estabcons]: 10000000000
ShortLegend[server.estabcons]: c/s
YLegend[server.estabcons]: Connections
LegendI[server.estabcons]: In
LegendO[server.estabcons]:
Legend1[server.estabcons]: Established connections
Legend2[server.estabcons]:
Options[server.estabcons]: growright,nopercent,gauge
#
# New TCP Connection Monitoring 新的TCP连接情况
#
Target[server.newconns]: tcpPassiveOpens.0&tcpActiveOpens.0:public@192.168.50.249
Title[server.newconns]: Newly Created TCP Connections
PageTop[server.newconns]: <H1>New TCP Connections</H1>
MaxBytes[server.newconns]: 10000000000
ShortLegend[server.newconns]: c/s
YLegend[server.newconns]: Conns / Min
LegendI[server.newconns]: In
LegendO[server.newconns]: Out
Legend1[server.newconns]: New inbound connections
Legend2[server.newconns]: New outbound connections
Options[server.newconns]: growright,nopercent,perminute
#
# Memory Utilization 内存及虚拟内存使用情况
#
Target[server.memoryUsed]: .1.3.6.1.2.1.25.2.3.1.6.3&.1.3.6.1.2.1.25.2.3.1.6.4:public@192.168.50.249 / .1.3.6.1.2.1.25.2.3.1.5.3&.1.3.6.1.2.1.25.2.3.1.5.4:public@192.168.50.249 * 100
Title[server.memoryUsed]: Memory Used
PageTop[server.memoryUsed]: <H1>Memory Utilization</H1>
MaxBytes[server.memoryUsed]: 523444000
ShortLegend[server.memoryUsed]: %
YLegend[server.memoryUsed]: % Memory Used
Legend1[server.memoryUsed]: Vir in next minute
Legend2[server.memoryUsed]: Phy in next minute
Legend3[server.memoryUsed]: Maximal 5 Minute Vir
Legend4[server.memoryUsed]: Maximal 5 Minute Phy
LegendI[server.memoryUsed]: Vir
LegendO[server.memoryUsed]: Phy
Options[server.memoryUsed]: growright,nopercent,gauge
#
# Disk Utilization 硬盘使用情况
#
Target[server.storageUsed]: .1.3.6.1.2.1.25.2.3.1.6.1&.1.3.6.1.2.1.25.2.3.1.6.2:public@192.168.99.249 / .1.3.6.1.2.1.25.2.3.1.5.1&.1.3.6.1.2.1.25.2.3.1.5.1:public@192.168.50.249 * 100
Title[server.storageUsed]: Disk Used
PageTop[server.storageUsed]: <H1>Disk Utilization</H1>
MaxBytes[server.storageUsed]: 523444000
ShortLegend[server.storageUsed]: %
YLegend[server.storageUsed]: % Disk Used
Legend1[server.storageUsed]: C: in next minute
Legend2[server.storageUsed]: D: in next minute
Legend3[server.storageUsed]: Maximal 5 Minute C:
Legend4[server.storageUsed]: Maximal 5 Minute D:
LegendI[server.storageUsed]: C:
LegendO[server.storageUsed]: D:
Options[server.storageUsed]: growright,nopercent,gauge
保存server.cfg,使用命令Perl indexmaker --output=c:\inetpub\wwwroot\mrtg\server01\server01.html c:\inetpub\wwwroot\mrtg\server01\server01.cfg重新生成网页,再使用命令:start /D c:\mrtg\bin wperl mrtg --logging=server01log c:\inetpub\wwwroot\mrtg\server01\server01.cfg 重新生成服务器Server01的流量图,我们来看看效果:
通过这些图表,我们可以很容易的了解到服务器运行的情况。
我这里谈到的只是MRTG监控系统功能的一部分,它还可以监控HTTP访问量、FTP访问量等。设置的方法大同小异,大家只要掌握了正确的方法,对于一些细节的东西,只要稍作修改就可以了。这里最难的地方就是找MIB值了,只要知道MIB值就能很方便获取到数据,画出图形。对于MIB的获取,可以通过一些小软件来实现,比如GETIF-MIBS,mibbrowser等。软件的使用比较简单,这里就不再做说明,如下图是使用GETIF-MIBS获取进程的MIB值的方法:其它MIB值的获取方法类似。