@cryptotaxi247 / netdata-1 / commits / 88559a49b

fix(proc.plugin): consider ZFS ARC as cache when collecting memory usage on Linux (#12847)

Ilya Mashchenko committed May 10, 2022 at 12:26 UTC 88559a49b3309755c15d29af793e8a8a5b3bc11d
4 files changed +15 -2
collectors/proc.plugin/plugin_proc.h
+1
@@ -48,6 +48,7 @@ extern int get_numa_node_count(void);
48
49 // metrics that need to be shared among data collectors
50 extern unsigned long long tcpext_TCPSynRetrans;
51 +extern unsigned long long zfs_arcstats_shrinkable_cache_size_bytes;
52
53 // netdev renames
54 extern void netdev_rename_device_add(
collectors/proc.plugin/proc_meminfo.c
+4
@@ -159,6 +159,10 @@ int do_proc_meminfo(int update_every, usec_t dt) {
159 // http://calimeroteknik.free.fr/blag/?article20/really-used-memory-on-gnu-linux
160 unsigned long long MemCached = Cached + SReclaimable - Shmem;
161 unsigned long long MemUsed = MemTotal - MemFree - MemCached - Buffers;
162 + // The Linux kernel doesn't report ZFS ARC usage as cache memory (the ARC is included in the total used system memory)
163 + MemCached += (zfs_arcstats_shrinkable_cache_size_bytes / 1024);
164 + MemUsed -= (zfs_arcstats_shrinkable_cache_size_bytes / 1024);
165 + MemAvailable += (zfs_arcstats_shrinkable_cache_size_bytes / 1024);
166
167 if(do_ram) {
168 {
collectors/proc.plugin/proc_spl_kstat_zfs.c
+8
@@ -11,6 +11,8 @@
11
12 extern struct arcstats arcstats;
13
14 +unsigned long long zfs_arcstats_shrinkable_cache_size_bytes = 0;
15 +
16 int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) {
17 (void)dt;
18
@@ -190,6 +192,12 @@ int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) {
192 if(unlikely(arl_check(arl_base, key, value))) break;
193 }
194
195 + if (arcstats.size > arcstats.c_min) {
196 + zfs_arcstats_shrinkable_cache_size_bytes = arcstats.size - arcstats.c_min;
197 + } else {
198 + zfs_arcstats_shrinkable_cache_size_bytes = 0;
199 + }
200 +
201 if(unlikely(arcstats.l2exist == -1))
202 arcstats.l2exist = 0;
203
health/health.d/ram.conf
+2 -2
@@ -6,7 +6,7 @@
6 class: Utilization
7 type: System
8 component: Memory
9 - os: linux freebsd
9 + os: freebsd
10 hosts: *
11 calc: ($zfs.arc_size.arcsz = nan)?(0):($zfs.arc_size.arcsz - $zfs.arc_size.min)
12 every: 10s
@@ -20,7 +20,7 @@ component: Memory
20 component: Memory
21 os: linux
22 hosts: *
23 - calc: ($used - $used_ram_to_ignore) * 100 / ($used + $cached + $free + $buffers)
23 + calc: $used * 100 / ($used + $cached + $free + $buffers)
24 units: %
25 every: 10s
26 warn: $this > (($status >= $WARNING) ? (80) : (90))