OpenNMS - 存储(SNMP MIB-2 主机资源)提供不正确的值
OpenNMS - Storage (SNMP MIB-2 Host Resources) giving incorrect values
我正在使用 OpenNMS Horizon 监控多个节点。对于给定的节点,它正在监视 "Storage (SNMP MIB-2 Host Resources) ",它会告知磁盘 space(使用率百分比)。对于节点的本地磁盘,我得到了正确的值。对于 SAN 文件系统磁盘,出现错误值(也是负值)。然而,对于少数 SAN 卷,它给出了正确的值。出现此错误的可能原因是什么?
数据来自${OPENNMS_HOME}/etc/datacollection/mib2.xml
中定义的默认MIB-II数据收集配置。
<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>
我要调查的第一件事是您使用上述 OID 上的 snmpwalk
命令行工具从设备的 SNMP 代理接收到的值是多少。
接收到的值默认保存在 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 从 "used bytes" 和 "total bytes" 计算利用率(以百分比表示)。如您所见,需要根据 SNMP 代理单元大小(以字节为单位)以及磁盘上总共有多少个单元来计算已用字节数和总字节数。
您可以验证设备的 SNMP 代理是否给出了合理的值,并且您可以自己重新计算这些值。
我希望这有助于调试您的问题。
我正在使用 OpenNMS Horizon 监控多个节点。对于给定的节点,它正在监视 "Storage (SNMP MIB-2 Host Resources) ",它会告知磁盘 space(使用率百分比)。对于节点的本地磁盘,我得到了正确的值。对于 SAN 文件系统磁盘,出现错误值(也是负值)。然而,对于少数 SAN 卷,它给出了正确的值。出现此错误的可能原因是什么?
数据来自${OPENNMS_HOME}/etc/datacollection/mib2.xml
中定义的默认MIB-II数据收集配置。
<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>
我要调查的第一件事是您使用上述 OID 上的 snmpwalk
命令行工具从设备的 SNMP 代理接收到的值是多少。
接收到的值默认保存在 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 从 "used bytes" 和 "total bytes" 计算利用率(以百分比表示)。如您所见,需要根据 SNMP 代理单元大小(以字节为单位)以及磁盘上总共有多少个单元来计算已用字节数和总字节数。
您可以验证设备的 SNMP 代理是否给出了合理的值,并且您可以自己重新计算这些值。
我希望这有助于调试您的问题。