Fixes invalid interfs space used on BSD-based systems

Fixes #3591
This commit is contained in:
Simone Mainardi 2020-03-20 16:01:23 +01:00
parent b551bb3e7a
commit 1fe0e0dea8

View file

@ -3297,12 +3297,14 @@ function getFolderSize(path, timeout)
du_cmd = string.format("timeout %u%s %s", MAX_TIMEOUT, "s", du_cmd)
end
local line = os_utils.execWithOutput(du_cmd)
-- use POSIXLY_CORRECT=1 to guarantee results is returned in 512-byte blocks
-- both on BSD and Linux
local line = os_utils.execWithOutput(string.format("POSIXLY_CORRECT=1 %s", du_cmd))
local values = split(line, '\t')
if #values >= 1 then
local used = tonumber(values[1])
if used ~= nil then
size = math.ceil(used*1024)
size = math.ceil(used * 512)
-- Cache disk utilization
ntop.setHashCache("ntopng.cache.folder_size", path, now..","..size)