From 552e2a036c79a6cd7042fc81c58d19f315410b73 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 1 Apr 2020 15:21:07 -0700 Subject: [PATCH] Use block size instead of apparent size in du https://stackoverflow.com/questions/5694741/why-is-the-output-of-du-often-so-different-from-du-b df uses superblock info to get consumed blocks/disk size. du with -b prints actual file size instead of the disk space used by the files. --- setup/start/collectd/du.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup/start/collectd/du.py b/setup/start/collectd/du.py index 4d10dd70d..3b34573be 100644 --- a/setup/start/collectd/du.py +++ b/setup/start/collectd/du.py @@ -6,7 +6,8 @@ PATHS = [] # { name, dir, exclude } INTERVAL = 60 * 60 * 12 # twice a day. change values in docker-graphite if you change this def du(pathinfo): - cmd = 'timeout 1800 du -Dsb "{}"'.format(pathinfo['dir']) + # -B1 makes du print block sizes and not apparent sizes (to match df which also uses block sizes) + cmd = 'timeout 1800 du -DsB1 "{}"'.format(pathinfo['dir']) if pathinfo['exclude'] != '': cmd += ' --exclude "{}"'.format(pathinfo['exclude'])