SNMP support large filesystem > 16TB

如何让 SNMP 正确返回超过 16TB 的文件系统

需要 Net-SNMP >= 5.5

snmpd.conf中加入以下配置,realStorageUnits 0

详见 https://linux.die.net/man/5/snmpd.conf

realStorageUnits
controlls how the agent reports hrStorageAllocationUnits, hrStorageSize and hrStorageUsed in hrStorageTable. With this option set to ‘0’, the agent re-calculates these values for big storage drives with small allocation units so hrStorageAllocationUnits x hrStorageSize gives real size of the storage.
Example:
Linux xfs 16TB filesystem with 4096 bytes large blocks will be reported as hrStorageAllocationUnits = 8192 and hrStorageSize = 2147483647, so 8192 x 2147483647 gives real size of the filesystem (=16 TB).

Setting this directive to ‘1’ (=default) turns off this calculation and the agent reports real hrStorageAllocationUnits, but it might report wrong hrStorageSize for big drives because the value won’t fit into Integer32. In this case, hrStorageAllocationUnits x hrStorageSize won’t give real size of the storage.

总就来说就是,默认情况下 SNMP 的 hrStorageAllocationUnits 是真实的 Block size,常见为 4096 bytes

1
2
3
4
5
6
[root@pan ~]# stat -f .
File: "."
ID: 4bbdbd4b4b7c6438 Namelen: 255 Type: ext2/ext3
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 12868767 Free: 11452648 Available: 10797288
Inodes: Total: 3276800 Free: 3211062

于是 hrStorageSize 就会超过 Integer32 的最大值