@cryptotaxi247 / netdata-1 / commits / 787c75145

Consider ZFS ARC shrinkable as cache on FreeBSD (#12879)

Vladimir Kobal committed May 11, 2022 at 18:02 UTC 787c751455b1ca731cdad63d5dcd4fd9cf5bb4ff
4 files changed +19 -20
collectors/freebsd.plugin/freebsd_kstat_zfs.c
+8
@@ -5,6 +5,8 @@
5
6 extern struct arcstats arcstats;
7
8 +unsigned long long zfs_arcstats_shrinkable_cache_size_bytes = 0;
9 +
10 // --------------------------------------------------------------------------------------------------------------------
11 // kstat.zfs.misc.arcstats
12
@@ -213,6 +215,12 @@ int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
215 // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_need_free", mibs.arc_need_free, arcstats.arc_need_free);
216 // missing mib: GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.arc_sys_free", mibs.arc_sys_free, arcstats.arc_sys_free);
217
218 + if (arcstats.size > arcstats.c_min) {
219 + zfs_arcstats_shrinkable_cache_size_bytes = arcstats.size - arcstats.c_min;
220 + } else {
221 + zfs_arcstats_shrinkable_cache_size_bytes = 0;
222 + }
223 +
224 generate_charts_arcstats("freebsd.plugin", "zfs", show_zero_charts, update_every);
225 generate_charts_arc_summary("freebsd.plugin", "zfs", show_zero_charts, update_every);
226
collectors/freebsd.plugin/freebsd_sysctl.c
+6 -6
@@ -1026,10 +1026,8 @@ int do_system_ram(int update_every, usec_t dt) {
1026 rd_free = rrddim_add(st, "free", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1027 rd_active = rrddim_add(st, "active", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1028 rd_inactive = rrddim_add(st, "inactive", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1029 - rd_wired = rrddim_add(st, "wired", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1030 -#if __FreeBSD_version < 1200016
1031 - rd_cache = rrddim_add(st, "cache", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1032 -#endif
1029 + rd_wired = rrddim_add(st, "wired", NULL, 1, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1030 + rd_cache = rrddim_add(st, "cache", NULL, 1, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1031 #if defined(NETDATA_COLLECT_LAUNDRY)
1032 rd_laundry = rrddim_add(st, "laundry", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1033 #endif
@@ -1040,9 +1038,11 @@ int do_system_ram(int update_every, usec_t dt) {
1038 rrddim_set_by_pointer(st, rd_free, vmmeter_data.v_free_count);
1039 rrddim_set_by_pointer(st, rd_active, vmmeter_data.v_active_count);
1040 rrddim_set_by_pointer(st, rd_inactive, vmmeter_data.v_inactive_count);
1043 - rrddim_set_by_pointer(st, rd_wired, vmmeter_data.v_wire_count);
1041 + rrddim_set_by_pointer(st, rd_wired, vmmeter_data.v_wire_count * system_pagesize - zfs_arcstats_shrinkable_cache_size_bytes);
1042 #if __FreeBSD_version < 1200016
1045 - rrddim_set_by_pointer(st, rd_cache, vmmeter_data.v_cache_count);
1043 + rrddim_set_by_pointer(st, rd_cache, vmmeter_data.v_cache_count * system_pagesize + zfs_arcstats_shrinkable_cache_size_bytes);
1044 +#else
1045 + rrddim_set_by_pointer(st, rd_cache, zfs_arcstats_shrinkable_cache_size_bytes);
1046 #endif
1047 #if defined(NETDATA_COLLECT_LAUNDRY)
1048 rrddim_set_by_pointer(st, rd_laundry, vmmeter_data.v_laundry_count);
collectors/freebsd.plugin/plugin_freebsd.h
+3
@@ -49,4 +49,7 @@ extern int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt);
49 extern int do_kstat_zfs_misc_zio_trim(int update_every, usec_t dt);
50 extern int do_ipfw(int update_every, usec_t dt);
51
52 +// metrics that need to be shared among data collectors
53 +extern unsigned long long zfs_arcstats_shrinkable_cache_size_bytes;
54 +
55 #endif /* NETDATA_PLUGIN_FREEBSD_H */
health/health.d/ram.conf
+2 -14
@@ -1,18 +1,6 @@
1
2 # you can disable an alarm notification by setting the 'to' line to: silent
3
4 - alarm: used_ram_to_ignore
5 - on: system.ram
6 - class: Utilization
7 - type: System
8 -component: Memory
9 - os: freebsd
10 - hosts: *
11 - calc: ($zfs.arc_size.arcsz = nan)?(0):($zfs.arc_size.arcsz - $zfs.arc_size.min)
12 - every: 10s
13 - info: amount of memory reported as used, \
14 - but it is actually capable for resizing itself based on the system needs (eg. ZFS ARC)
15 -
4 alarm: ram_in_use
5 on: system.ram
6 class: Utilization
@@ -66,7 +54,7 @@ host labels: _is_k8s_node = false
54 component: Memory
55 os: freebsd
56 hosts: *
69 - calc: ($active + $wired + $laundry + $buffers - $used_ram_to_ignore) * 100 / ($active + $wired + $laundry + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
57 + calc: ($active + $wired + $laundry + $buffers) * 100 / ($active + $wired + $laundry + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
58 units: %
59 every: 10s
60 warn: $this > (($status >= $WARNING) ? (80) : (90))
@@ -82,7 +70,7 @@ component: Memory
70 component: Memory
71 os: freebsd
72 hosts: *
85 - calc: ($free + $inactive + $used_ram_to_ignore) * 100 / ($free + $active + $inactive + $wired + $cache + $laundry + $buffers)
73 + calc: ($free + $inactive + $cache) * 100 / ($free + $active + $inactive + $wired + $cache + $laundry + $buffers)
74 units: %
75 every: 10s
76 warn: $this < (($status >= $WARNING) ? (15) : (10))