From c1baf358c3f07820f48adc40bae5622806d4556e Mon Sep 17 00:00:00 2001 From: starinacool Date: Wed, 8 Nov 2023 13:32:46 +0700 Subject: [PATCH] Shared memory does not included in Cached memory on Linux. --- plugins/node.d.linux/memory | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/node.d.linux/memory b/plugins/node.d.linux/memory index 85f526125f..13b406eafb 100755 --- a/plugins/node.d.linux/memory +++ b/plugins/node.d.linux/memory @@ -288,6 +288,7 @@ $mems{'Percpu'} ||= 0; $mems{'SwapCached'} ||= 0; $mems{'SwapFree'} ||= 0; $mems{'SwapTotal'} ||= 0; +$mems{'Shmem'} ||= 0; print "apps.value ", $mems{'MemTotal'} -$mems{'MemFree'} @@ -297,11 +298,12 @@ print "apps.value ", $mems{'MemTotal'} -$mems{'PageTables'} -$mems{'Percpu'} -$mems{'SwapCached'} + -$mems{'Shmem'} ,"\n"; print "free.value ", $mems{'MemFree'}, "\n"; print "buffers.value ", $mems{'Buffers'}, "\n"; -print "cached.value ", $mems{'Cached'} - (defined($mems{'Shmem'}) ? $mems{'Shmem'} : 0), "\n"; +print "cached.value ", $mems{'Cached'}, "\n"; print "swap.value ", $mems{'SwapTotal'} - $mems{'SwapFree'}, "\n"; print "shmem.value ", $mems{'Shmem'}, "\n"