|
|
VictorYan指北系列之MRTG实用篇
主要内容:
*全局选项配置
*监控主机连续运行时间[运行天数]
*监控系统负载[1分钟+15分钟]
*监控CPU负载[用户+闲置]
*监控内存使用量[Mem+Swap]
*监控网络流量[流入+流出]
*监控硬盘空间[系统盘+数据盘]
*监控系统进程数[进程数]
*监控打开的TCP连接数[TCP连接数]
参考文章: http://howto.aphroland.de/HOWTO/MRTG/FrontPage
参考示例图:
以下是MRTG的配置文件/etc/mrtg/mrtg.cfg的内容:
#================================================================================
#
#注: 生成索引文件index.html
# indexmaker --title="MRTG系统监控[host.abc.com]" /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
#
#================================================================================
#================================================================================
#
#全局选项配置
#
#================================================================================
WorkDir: /var/www/mrtg
Language: gb2312
LoadMIBs:/usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt
#================================================================================
#
#监控主机连续运行时间[运行天数]
#
#注:不能从SNMP中直接取得数据,使用perl script采集数 (/etc/mrtg/bin/mrtg-upday.pl)
#
#================================================================================
Target[upday]: `/etc/mrtg/bin/mrtg-updays.pl`
Options[upday]: gauge,nopercent,growright
Directory[upday]: upday
MaxBytes[upday]: 1000
YLegend[upday]: Up Days
ShortLegend[upday]: 天
Legend1[upday]: 主机连续运行时间(天)
Legend2[upday]:
LegendI[upday]: 运行时间:
LegendO[upday]:
Title[upday]: 主机连续运行时间[运行天数]
PageTop[upday]: <h1>主机连续运行时间[运行天数]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>主机连续运行的时间(天)</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>1000天</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD> </TD></TR>
</TABLE>
#================================================================================
#
#监控系统负载[1分钟+15分钟]
#
#MIB: .iso.org.dod.internet.private.enterprises.ucdavis.laTable.laEntry.laLoadInt
#
#注:打开snmpd中的监控功能,在/etc/snmp/snmpd.conf中加入
# view systemview included 1.3.6.1.4.1.2021.10.1.5
#================================================================================
Target[load]: laLoadInt.1&laLoadInt.3:public@localhost
Options[load]: gauge,nopercent,growright
Directory[load]: load
MaxBytes[load]: 3000
YLegend[load]: System Load
ShortLegend[load]:
Legend1[load]: 最近 1分钟系统负载(x 100)
Legend2[load]: 最近15分钟系统负载(x 100)
LegendI[load]: 1分钟负载:
LegendO[load]: 15分钟负载:
Title[load]: 系统负载(x 100)[1分钟+15分钟]
PageTop[load]: <h1>系统负载(x 100)[1分钟+15分钟]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>系统负载(x 100)[1分钟+15分钟]</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>30 (x 100)</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD> </TD></TR>
</TABLE>
#================================================================================
#
#监控CPU负载[用户+闲置]
#
#MIB: .iso.org.dod.internet.private.enterprises.ucdavis.systemStats
#
#注:打开snmpd中的监控功能,在/etc/snmp/snmpd.conf中加入
# view systemview included .1.3.6.1.4.1.2021.11
#================================================================================
Target[cpu]: ssCpuRawUser.0&ssCpuRawIdle.0:public@localhost
Options[cpu]: nopercent,growright
Directory[cpu]: cpu
MaxBytes[cpu]: 100
Unscaled[cpu]: dwym
YLegend[cpu]: CPU Utilization
ShortLegend[cpu]: %;
Legend1[cpu]: CPU用户负载(%)
Legend2[cpu]: CPU闲置(%)
LegendI[cpu]: 用户:
LegendO[cpu]: 闲置:
Title[cpu]: CPU负载[用户+闲置]
PageTop[cpu]: <h1>CPU负载[用户+闲置]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>CPU负载[用户+闲置]</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>100</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD></TD></TR>
</TABLE>
#================================================================================
#
#监控内存使用量[Mem+Swap]
#
#MIB: .iso.org.dod.internet.mgmt.mib-2.host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed
#
#注:打开snmpd中的监控,在/etc/snmp/snmpd.conf中加入
# view systemview included .1.3.6.1.2.1.25.2.3.1.6
#================================================================================
Target[mem]: hrStorageUsed.2&hrStorageUsed.3:public@localhost:
Options[mem]: gauge,growright
Directory[mem]: mem
MaxBytes1[mem]: 514588
MaxBytes2[mem]: 1052184
Kmg[mem]: k,M,G,T,P
Kilo[mem]: 1024
Unscaled[mem]: dwym
YLegend[mem]: Bytes
ShortLegend[mem]: B
Legend1[mem]: 已用Mem (Bytes)
Legend2[mem]: 已用Swap(Bytes)
LegendI[mem]: 已用Mem :
LegendO[mem]: 已用Swap:
Title[mem]: 内存使用量[Mem+Swap]
PageTop[mem]: <h1>内存使用量[Mem+Swap]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>Memory和Swap的使用量(Bytes)</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>Mem=502M,Swap=1027M</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD> </TD></TR>
</TABLE>
#================================================================================
#
#监控网络流量[流入+流出]
#
#================================================================================
#eth0网络流量
Target[eth0]: 2:public@localhost:
Options[eth0]: growright
Directory[eth0]: eth0
MaxBytes[eth0]: 12500000
Kmg[eth0]: ,k,M,G,T,P
YLegend[eth0]: Bytes per Second
ShortLegend[eth0]: B/s
Legend1[eth0]: 每秒流入量 (单位 Bytes)
Legend2[eth0]: 每秒流出量 (单位 Bytes)
LegendI[eth0]: 流入:
LegendO[eth0]: 流出:
Title[eth0]: eth0网络流量[流入+流出]
PageTop[eth0]: <H1>eth0网络流量[流入+流出]</H1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>LAN网络接口eth0的网络流量(Bytes/s)</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>12.5 MBytes/s</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD>eth0 ip=192.168.8.254</TD></TR>
</TABLE>
#================================================================================
#
#监控硬盘空间[系统盘+数据盘]
#
#MIB: .iso.org.dod.internet.private.enterprises.ucdavis.dskTable.dskEntry.dskUsed
#
#注1:打开snmpd中的监控功能,在/etc/snmp/snmpd.conf中加入
# view systemview included .1.3.6.1.4.1.2021.9.1.8
#
#注2:打开snmpd中的系统盘和数据盘监控功能,在/etc/snmp/snmpd.conf中加入
# disk / 100000
# disk /mnt/data 500000
#
#================================================================================
Target[disk]: dskUsed.1&dskUsed.2:public@localhost
Options[disk]: gauge,growright
Directory[disk]: disk
MaxBytes1[disk]: 7763856
MaxBytes2[disk]: 39104712
Kmg[disk]: k,M,G,T,P
Kilo[disk]: 1024
Unscaled[disk]: dwym
YLegend[disk]: Bytes
ShortLegend[disk]: B
Legend1[disk]: 系统盘已用空间
Legend2[disk]: 数据盘已用空间
LegendI[disk]: 系统已用:
LegendO[disk]: 数据已用:
Title[disk]: 硬盘空间[系统盘+数据盘]
PageTop[disk]: <h1>硬盘空间[系统盘+数据盘]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>系统盘=/(/dev/hda1); 数据盘=/mnt/data(/dev/hda7)</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>系统盘=7.5GB; 数据盘=38GB</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD> </TD></TR>
</TABLE>
#================================================================================
#
#监控系统进程数[进程数]
#
#MIB: .iso.org.dod.internet.mgmt.mib-2.host.hrSystem.hrSystemProcesses
#
#注:打开snmpd中的系统进程数监控,在/etc/snmp/snmpd.conf中加入
# view systemview included .1.3.6.1.2.1.25.1.6
#================================================================================
Target[process]: hrSystemProcesses.0&hrSystemProcesses.0:public@localhost:
Options[process]: gauge,nopercent,growright
Directory[process]: process
MaxBytes[process]: 1000
YLegend[process]: Processes
ShortLegend[process]: 个
Legend1[process]: 系统进程数(个)
Legend2[process]:
LegendI[process]: 进程数:
LegendO[process]:
Title[process]: 系统进程数[进程数]
PageTop[process]: <h1>系统进程数[进程数]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>系统进程数(个)</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>1000个</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD> </TD></TR>
</TABLE>
#================================================================================
#
#监控打开的TCP连接数[TCP连接数]
#
#MIB: .iso.org.dod.internet.mgmt.mib-2.tcp.tcpCurrEstab
#
#注:打开snmpd中的监控功能,在/etc/snmp/snmpd.conf中加入
# view systemview included .1.3.6.1.2.1.6.9
#================================================================================
Target[tcpopen]: tcpCurrEstab.0&tcpCurrEstab.0:public@localhost:
Options[tcpopen]: gauge,nopercent,growright
Directory[tcpopen]: tcpopen
MaxBytes[tcpopen]: 1000
YLegend[tcpopen]: Tcp Connections
ShortLegend[tcpopen]: 个
Legend1[tcpopen]: 打开的TCP连接数(个)
Legend2[tcpopen]:
LegendI[tcpopen]: TCP连接数:
LegendO[tcpopen]:
Title[tcpopen]: TCP连接数[TCP连接数]
PageTop[tcpopen]: <h1>TCP连接数[TCP连接数]</h1>
<TABLE>
<TR><TD>系统 :</TD> <TD>host.abc.com</TD></TR>
<TR><TD>描述 :</TD> <TD>打开的TCP连接数(个)</TD></TR>
<TR><TD>位置 :</TD> <TD> Shanghai</TD></TR>
<TR><TD>最大值:</TD> <TD>1000个</TD></TR>
<TR><TD>管理员:</TD> <TD>user@abc.com</TD></TR>
<TR><TD>说明 :</TD> <TD> </TD></TR>
</TABLE> |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|