enh(snmp_standard::mode::diskusage): add 'auto' to --space-reservation - #6352
Open
saeroshi wants to merge 1 commit into
Open
enh(snmp_standard::mode::diskusage): add 'auto' to --space-reservation#6352saeroshi wants to merge 1 commit into
saeroshi wants to merge 1 commit into
Conversation
--space-reservation only accepted a fixed percentage applied to every partition, which is wrong as soon as a host mixes filesystems with different reservations (ext4 with -m 5, ext4 with -m 0, xfs, tmpfs...). The UCD-SNMP-MIB already exposes dskAvail (f_bavail) next to dskTotal and dskUsed, so the real reservation of each partition can be measured with dskTotal - dskUsed - dskAvail (that is f_bfree - f_bavail). Add 'auto' to --space-reservation to use that computation. dskAvail OIDs are only requested when the option is set, so there is no extra SNMP traffic for existing users. This aligns the SNMP mode with os::linux::local::mode::storage, where Total = Used + Available since centreon#4978.
saeroshi
requested review from
bouda1,
lucie-tirand and
sechkem
and removed request for
a team
August 12, 2026 14:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Community contributors
Description
--space-reservationonly accepts a fixed percentage, applied identically to every partition. This is wrong as soon as a host mixes filesystems with different reservations, which is the common case: ext4 formatted with-m 5, ext4 with-m 0on data volumes, xfs, tmpfs, nfs...The UCD-SNMP-MIB already exposes
dskAvail(f_bavail) right next todskTotalanddskUsed, at the same index of the table this mode already walks. The real reservation of a partition is thereforedskTotal - dskUsed - dskAvail, which is exactlyf_bfree - f_bavail.This PR adds
autoto--space-reservationto use that measured value.dskAvailOIDs are requested only when the option is set, so there is no extra SNMP traffic for existing users.It aligns the SNMP mode with
os::linux::local::mode::storage, whereTotal = Used + Availablesince #4978.Three side effects worth mentioning:
--space-reservation=100currently exits UNKNOWN on "Illegal division by zero");0;includeAllDiskswas added to the spellcheck stopwords, as the POD spell check already failed on this file before this change.Related to #386, which asked for this exact feature in 2016 (including the
AUTOvalue) and was closed with "SNMP doesn't give the information about the root reservation". That is true for HOST-RESOURCES-MIB, but not for the dskTable this mode relies on.Type of change
How this pull request can be tested ?
No new fixture is required:
tests/os/linux/snmp/linux.snmpwalkalready containsdskAvail, with/on ext4 (5.12% reserved) and four tmpfs (0%).Test cases 27, 28 and 29 were added (auto on all partitions, auto on
/only, and rejection of an invalid value). Only/is affected byauto(7.04% -> 7.42%), the tmpfs partitions are left untouched, which is the point.Also checked against a real net-snmp agent (Debian 12,
includeAllDisks 10%), compared withdf:df=5=auto/(ext4,-m 5)/data(ext4,-m 0)automatchesdfon both partitions, which no single fixed percentage can do.Checklist