LibreNMS calculates free space on used, rather than available as reported by 'df'

Not sure if this is a configuration issue or a bug, but we found a discrepancy between LibreNMS’s free space calculation and the output of ‘df’.

It appears to me what’s happening here is LibreNMS is calculating the available disk space based on the used/total number, rather than the reported available space. This discrepancy gets larger and larger as the drive fills, ultimately leading to a ~5% discrepancy between what LibreNMS says is available, vs what the machine itself is reporting.

I checked several machines and found the same behavior across RHEL 5, RHEL 7, Ubuntu 14.04, and Fedora 26 (basically, all of our Linux boxen). FreeBSD does not have this problem.

I suspect it’s a matter of inode and file system structure overhead that is not calculated into the used value, but is taken into account in “available”

Is it feasible to have LibreNMS pull the reported available space from the machine rather than calculating it based on reported used space? It wasn’t immediately obvious to me from the output of the snmpwalk whether the available space is reported or not.


Component Version
LibreNMS 1.32-14-ga2b9342
DB Schema 210
PHP 7.0.23
MySQL 5.5.56-MariaDB
RRDTool 1.4.8

[OK] Database connection successful
[OK] Database schema correct

Pastebin of df output:

output of snmpwalk for that box (too big for pastebin):

LibreNMS disk reporting:

1 Like

can you the output of ./discovery.php -r -f -h HOSTNAME -d

Don’t mean to hijack the thread. But the way LibreNMS calculates the free space is entirely based on what snmpd reports back. So it’s accurate based on those numbers.

However, I don’t think it takes into consideration the reserved space like df does.

If you do a simple tune2fs -l /dev/sda1. Look for “Reserved block count:”. That’s the 5% you are missing.

You can disable this so snmp and df match. Just do a “tune2fs -m 0 /dev/sda1” and df should match snmpd 100%.