数据来自中定义的默认MIB-II数据采集配置
${OPENNMS_HOME}/etc/datacollection/mib2.xml
。
<resourceType name="hrStorageIndex" label="Storage (SNMP MIB-2 Host Resources)" resourceLabel="${hrStorageDescr}">
<persistenceSelectorStrategy class="org.opennms.netmgt.collection.support.PersistAllSelectorStrategy"/>
<storageStrategy class="org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy">
<parameter key="sibling-column-name" value="hrStorageDescr"/>
<parameter key="replace-first" value="s/^-$/_root_fs/"/>
<parameter key="replace-all" value="s/^-//"/>
<parameter key="replace-all" value="s/\s//"/>
<parameter key="replace-all" value="s/:\\.*//"/>
</storageStrategy>
</resourceType>
资源类型定义告诉SNMP收集器如何处理多个磁盘实例。
以下部分告诉SNMP收集器,对于每个选定的磁盘实例,在系统中查询和保留哪些OID:
<group name="mib2-host-resources-storage" ifType="all">
<mibObj oid=".1.3.6.1.2.1.25.2.3.1.2" instance="hrStorageIndex" alias="hrStorageType" type="string"/>
<mibObj oid=".1.3.6.1.2.1.25.2.3.1.3" instance="hrStorageIndex" alias="hrStorageDescr" type="string"/>
<mibObj oid=".1.3.6.1.2.1.25.2.3.1.4" instance="hrStorageIndex" alias="hrStorageAllocUnits" type="gauge"/>
<mibObj oid=".1.3.6.1.2.1.25.2.3.1.5" instance="hrStorageIndex" alias="hrStorageSize" type="gauge"/>
<mibObj oid=".1.3.6.1.2.1.25.2.3.1.6" instance="hrStorageIndex" alias="hrStorageUsed" type="gauge"/>
</group>
我要调查的第一件事是,使用
snmpwalk
上面OID上的命令行工具。
默认情况下,接收到的值会保存在RRDTool中,而获取百分比的计算是在RRD图形模板中完成的,您可以在
${OPENNMS_HOME}/etc/snmp-graph.properties.d/mib2-graph.properties
。
完整的RRD模板定义如下所示:
report.mib2.storage.usage.name=Storage Utilization (MIB-2 Host Resources)
report.mib2.storage.usage.columns=hrStorageSize, hrStorageUsed, hrStorageAllocUnits
report.mib2.storage.usage.propertiesValues=hrStorageDescr
report.mib2.storage.usage.type=hrStorageIndex
report.mib2.storage.usage.command=--title="Storage Utilization on {hrStorageDescr}" \
--vertical-label="Percentage (%)" \
--base=1024 \
--lower-limit 0 \
--upper-limit 105 \
DEF:total={rrd1}:hrStorageSize:AVERAGE \
DEF:used={rrd2}:hrStorageUsed:AVERAGE \
DEF:units={rrd3}:hrStorageAllocUnits:AVERAGE \
CDEF:totalBytes=total,units,* \
CDEF:usedBytes=used,units,* \
CDEF:usedPart=usedBytes,totalBytes,/ \
CDEF:dpercent=usedPart,100,* \
CDEF:dpercent10=0,dpercent,GT,0,dpercent,IF \
CDEF:dpercent20=10,dpercent,GT,0,dpercent,IF \
CDEF:dpercent30=20,dpercent,GT,0,dpercent,IF \
CDEF:dpercent40=30,dpercent,GT,0,dpercent,IF \
CDEF:dpercent50=40,dpercent,GT,0,dpercent,IF \
CDEF:dpercent60=50,dpercent,GT,0,dpercent,IF \
CDEF:dpercent70=60,dpercent,GT,0,dpercent,IF \
CDEF:dpercent80=70,dpercent,GT,0,dpercent,IF \
CDEF:dpercent90=80,dpercent,GT,0,dpercent,IF \
CDEF:dpercent100=90,dpercent,GT,0,dpercent,IF \
COMMENT:"Storage used in (%)\\n" \
AREA:dpercent10#5ca53f:"0-10% " \
AREA:dpercent20#75b731:"11-20%" \
AREA:dpercent30#90c22f:"21-30%" \
AREA:dpercent40#b8d029:"31-40%" \
AREA:dpercent50#e4e11e:"41-50%" \
COMMENT:"\\n" \
AREA:dpercent60#fee610:"51-60%" \
AREA:dpercent70#f4bd1b:"61-70%" \
AREA:dpercent80#eaa322:"71-80%" \
AREA:dpercent90#de6822:"81-90%" \
AREA:dpercent100#d94c20:"91-100%\\n" \
COMMENT:"\\n" \
HRULE:100#d94c20 \
COMMENT:"\\n" \
LINE1:dpercent#46683b:"Storage used in (%)" \
GPRINT:dpercent:AVERAGE:"Avg\\: %7.2lf%s" \
GPRINT:dpercent:MIN:"Min\\: %7.2lf%s" \
GPRINT:dpercent:MAX:"Max\\: %7.2lf%s\\n" \
COMMENT:"\\n" \
COMMENT:"Used Bytes\\: \\n" \
GPRINT:usedBytes:AVERAGE:"Avg\\: %7.2lf%s" \
GPRINT:usedBytes:MIN:"Min\\: %7.2lf%s" \
GPRINT:usedBytes:MAX:"Max\\: %7.2lf%s\\n" \
COMMENT:"\\n" \
GPRINT:totalBytes:AVERAGE:"Total Bytes\\: %7.2lf%s"
获取百分比最重要的部分是在此处进行的计算:
DEF:total={rrd1}:hrStorageSize:AVERAGE \
DEF:used={rrd2}:hrStorageUsed:AVERAGE \
DEF:units={rrd3}:hrStorageAllocUnits:AVERAGE \
CDEF:totalBytes=total,units,* \
CDEF:usedBytes=used,units,* \
CDEF:usedPart=usedBytes,totalBytes,/ \
CDEF:dpercent=usedPart,100,* \
它使用特定于RRDTool的
reverse polish notation
从“已用字节”和“总字节”计算利用率(以百分比为单位)。正如您所看到的,需要根据SNMP代理的单位大小(以字节为单位)以及磁盘上总共有多少个单位和使用的单位来计算已用字节数和总字节数。
您可以验证设备中的SNMP代理是否提供了合理的值,并且您可以自己重新计算这些值。
我希望这有助于调试您的问题。