From: Weiping Zhang Date: Mon, 17 May 2021 07:59:50 +0000 (+0800) Subject: Do not account reclaimable slab as used X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77e2fcd91e270be826ab0a701f5929c26b9ce2c8;p=thirdparty%2Fcollectd.git Do not account reclaimable slab as used ChangeLog: memory plugin: do not account reclaimable slab as used. Align this counter with free(1). https://gitlab.com/procps-ng/procps/-/blob/v3.3.17/proc/sysinfo.c#L789 Signed-off-by: Weiping Zhang --- diff --git a/src/memory.c b/src/memory.c index bc9a283bc..1adbdf80c 100644 --- a/src/memory.c +++ b/src/memory.c @@ -379,8 +379,12 @@ static int memory_read_internal(value_list_t *vl) { if (mem_total < (mem_free + mem_buffered + mem_cached + mem_slab_total)) return -1; - mem_used = - mem_total - (mem_free + mem_buffered + mem_cached + mem_slab_total); + if (detailed_slab_info) + mem_used = mem_total - + (mem_free + mem_buffered + mem_cached + mem_slab_reclaimable); + else + mem_used = + mem_total - (mem_free + mem_buffered + mem_cached + mem_slab_total); /* SReclaimable and SUnreclaim were introduced in kernel 2.6.19 * They sum up to the value of Slab, which is available on older & newer