首页 > 代码库 > 使用SNMP抓取远程服务器磁盘容量信息有误

使用SNMP抓取远程服务器磁盘容量信息有误

公司服务器硬盘是44T,使用snmpwalk抓出来才2T,见下面红色字体


root@CTL-BJ-BJYZ-SER-09:# snmpwalk -v 2c -c ********  .1.3.6.1.4.1.2021.9.1.6

iso.3.6.1.4.1.2021.9.1.6.1 = INTEGER: 226311584

iso.3.6.1.4.1.2021.9.1.6.2 = INTEGER: 0

iso.3.6.1.4.1.2021.9.1.6.3 = INTEGER: 0

iso.3.6.1.4.1.2021.9.1.6.4 = INTEGER: 10240

iso.3.6.1.4.1.2021.9.1.6.5 = INTEGER: 0

iso.3.6.1.4.1.2021.9.1.6.6 = INTEGER: 6608132

iso.3.6.1.4.1.2021.9.1.6.7 = INTEGER: 5120

iso.3.6.1.4.1.2021.9.1.6.8 = INTEGER: 25716020

iso.3.6.1.4.1.2021.9.1.6.9 = INTEGER: 2147483647


使用df -Hl 查看如下:


Filesystem                           Size  Used Avail Use% Mounted on

/dev/sdb                             44T   13G   42T   1% /data



通过查询相关资料,当磁盘大于16T时候,会出现此问题。


snmp在制作MIB库时,表的索引项是Integer32类型的,这就造成了错误。

2147483647 = 2^31 (the maximum limit of a signed 32 bit integer (2147483647)),超出此值都会显示为 2147483647 ,SMI定义了一定数量的OID返回的数据类型。其中就有Integer整型,Signed 32bit Integer (values between -2147483648 and 2147483647). 有符号32位整数(值范围: -2147483648 - +2147483648)

 

此BUGRedhat已经有说明,参见:https://bugzilla.redhat.com/show_bug.cgi?id=654384  


文中说的很详细:In new Net-SNMP release it does not wrap at 2^31 but sticks to it if the real value is higher, i.e. reports 2147483647 for all devices bigger than 2 billion of allocation unit (instead of reporting ‘size modulo 2^21‘).


Redhat已经修复此bug,如下:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/5.7_Technical_Notes/net-snmp.html#RHBA-2011-1076


描述如下:


BZ#654384

Previously, the snmpd daemon strictly implemented RFC 2780. However, this specification no longer scales well with modern big storage devices with small allocation units, and consequently, snmpd reported a wrong value of the HOST-RESOURCES-MIB::hrStorageSize object when working with a large file system (larger than 16TB), because the accurate value would not fit into Integer32 as specified in the RFC. To address this issue, this update adds a new option to the /etc/snmp/snmpd.conf configuration file, realStorageUnits. By changing the value of this option to 0, users can now enable recalculating all values in hrStorageTable to ensure that the multiplication of hrStorageSize and hrStorageAllocationUnits always produces an accurate device size. On the other hand, the values of hrStorageAllocationUnits are artificial and do not represent the real size of the allocation unit on the storage device.

 


本文出自 “我的《奋斗》” 博客,请务必保留此出处http://wangmukun.blog.51cto.com/651644/1560333

使用SNMP抓取远程服务器磁盘容量信息有误