On Thu, Mar 9, 2017 at 10:02 PM, Joel Knight <knight.j...@gmail.com> wrote: > Hi. > > snmpd(8) uses unsigned ints internally to represent the size and used > space of a file system. The HOST-RESOURCES-MIB defines the valid > values for those OIDs as 0..2147483647. With sufficiently large file > systems, this can cause negative numbers to be returned for the size > and used space OIDs. > > .1.3.6.1.2.1.25.2.3.1.5.36=-1573167768
Hi. Just wanted to bump this again and see if anyone that cares about snmp could take a look? Looking for oks and someone who wouldn't mind committing it. > At sthen's suggestion, do what net-snmp does and fiddle with the > values to prevent wrapping. Yes this mucks with the actual values of > size, used space, and block size, but it allows snmpd to convey the > proper size and used space of the file system which is what most > everybody is really interested in. > > In case gmail hoses this diff, it's also here: > https://www.packetmischief.ca/files/patches/snmpd.hrstorage2.diff
Index: usr.sbin/snmpd/mib.c =================================================================== RCS file: /data/cvs-mirror/OpenBSD/src/usr.sbin/snmpd/mib.c,v retrieving revision 1.80 diff -p -u -r1.80 mib.c --- usr.sbin/snmpd/mib.c 17 Nov 2015 12:30:23 -0000 1.80 +++ usr.sbin/snmpd/mib.c 19 Feb 2017 20:01:46 -0000 @@ -643,6 +643,14 @@ mib_hrstorage(struct oid *oid, struct be units = mnt->f_bsize; size = mnt->f_blocks; used = mnt->f_blocks - mnt->f_bfree; + + /* for large filesystems, do not overflow hrStorageSize */ + while (size > INT32_MAX) { + size = size >> 1; + units = units << 1; + used = used >> 1; + } + sop = &so[3]; break; }