天天看點

使用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

繼續閱讀