snmpwalk hrstorage reports incorrect sizes
This document (000020961) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 15 SP3
Situation
For example:
# /bin/df -Th
# (this output has been trimmed)
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 362M 38M 325M 11% /run
/dev/mapper/system-root btrfs 1.0G 480M 354M 58% /
/dev/mapper/system-home btrfs 43G 34G 9.4G 78% /home
Below, the root file system ("/") reports correctly within snmpwalk output, as the "Size" and "Used" values, when multiplied by the Unit (4096), is the same size as reported in "df". For example, Size 262144 x 4096 = 1073741824, aka 1 GB:
HOST-RESOURCES-MIB::hrStorageIndex.31 = INTEGER: 31
HOST-RESOURCES-MIB::hrStorageType.31 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /
HOST-RESOURCES-MIB::hrStorageAllocationUnits.31 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageSize.31 = INTEGER: 262144
HOST-RESOURCES-MIB::hrStorageUsed.31 = INTEGER: 122888
However, the /home file system (and possibly others) report incorrect values:
HOST-RESOURCES-MIB::hrStorageIndex.78 = INTEGER: 78
HOST-RESOURCES-MIB::hrStorageType.78 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageDescr.78 = STRING: /home
HOST-RESOURCES-MIB::hrStorageAllocationUnits.78 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageSize.78 = INTEGER: 92575
HOST-RESOURCES-MIB::hrStorageUsed.78 = INTEGER: 9558
If those values are calculated together, the result (for example 92575 x 4096 = 379,187,200 = approx 362 MB) is incorrect for that file system. Incidentally, that size value actually belongs to the tmpfs file system mounted at /run, instead.
Resolution
Alternatively, the problem can be manually corrected with these steps:
1. Execute: systemctl edit snmpd
That will create /etc/systemd/system/snmpd.service.d/override.conf and bring it up in an editor.
2. Insert into that file:
[Service]
ProtectHome=false
3. After saving and exiting that file, execute:
systemctl daemon-reload
systemctl restart snmpd
Cause
From the changelog of net-snmp 5.9.3-150300.15.8.1 (trimmed):
* Mon Jan 09 2023
- Hardening systemd services setting "ProtectHome=true" caused home directory
size and allocation to be listed incorrectly (bsc#1206044).
add:
* net-snmp-5.9.3-harden_snmpd.service.patch
delete:
* net-snmp-5.9.1-harden_snmpd.service.patch
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020961
- Creation Date: 31-Jan-2023
- Modified Date:31-Jan-2023
-
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com