@cryptotaxi247 / netdata-1 / commits / 545d07eb7

Account "Laundry" pages as a separate RAM dimension on FreeBSD. (#4390)

Laundry pages are dirty pages queued for laundering. "Laundry" page type was introduces in FreeBSD CURRENT about two years ago and later this was backported to FreeBSD 11 branch.

Vlad Movchan committed Oct 16, 2018 at 15:31 UTC 545d07eb78222a80124e9187e88921013ee403ea
2 files changed +19 -5
collectors/freebsd.plugin/freebsd_sysctl.c
+17 -3
@@ -86,6 +86,10 @@ typedef struct __vmmeter vmmeter_t;
86 typedef struct vmmeter vmmeter_t;
87 #endif
88
89 +#if (__FreeBSD_version >= 1101516 && __FreeBSD_version < 1200000) || __FreeBSD_version >= 1200015
90 +#define NETDATA_COLLECT_LAUNDRY 1
91 +#endif
92 +
93 // --------------------------------------------------------------------------------------------------------------------
94 // FreeBSD plugin initialization
95
@@ -961,7 +965,8 @@ int do_vm_swap_info(int update_every, usec_t dt) {
965 int do_system_ram(int update_every, usec_t dt) {
966 (void)dt;
967 static int mib_active_count[4] = {0, 0, 0, 0}, mib_inactive_count[4] = {0, 0, 0, 0}, mib_wire_count[4] = {0, 0, 0, 0},
964 - mib_cache_count[4] = {0, 0, 0, 0}, mib_vfs_bufspace[2] = {0, 0}, mib_free_count[4] = {0, 0, 0, 0};
968 + mib_cache_count[4] = {0, 0, 0, 0}, mib_laundry_count[4] = {0, 0, 0, 0}, mib_vfs_bufspace[2] = {0, 0},
969 + mib_free_count[4] = {0, 0, 0, 0};
970 vmmeter_t vmmeter_data;
971 int vfs_bufspace_count;
972
@@ -970,6 +975,9 @@ int do_system_ram(int update_every, usec_t dt) {
975 GETSYSCTL_SIMPLE("vm.stats.vm.v_wire_count", mib_wire_count, vmmeter_data.v_wire_count) ||
976 #if __FreeBSD_version < 1200016
977 GETSYSCTL_SIMPLE("vm.stats.vm.v_cache_count", mib_cache_count, vmmeter_data.v_cache_count) ||
978 +#endif
979 +#if defined(NETDATA_COLLECT_LAUNDRY)
980 + GETSYSCTL_SIMPLE("vm.stats.vm.v_laundry_count", mib_laundry_count, vmmeter_data.v_laundry_count) ||
981 #endif
982 GETSYSCTL_SIMPLE("vfs.bufspace", mib_vfs_bufspace, vfs_bufspace_count) ||
983 GETSYSCTL_SIMPLE("vm.stats.vm.v_free_count", mib_free_count, vmmeter_data.v_free_count))) {
@@ -981,8 +989,8 @@ int do_system_ram(int update_every, usec_t dt) {
989 // --------------------------------------------------------------------
990
991 static RRDSET *st = NULL;
984 - static RRDDIM *rd_free = NULL, *rd_active = NULL, *rd_inactive = NULL,
985 - *rd_wired = NULL, *rd_cache = NULL, *rd_buffers = NULL;
992 + static RRDDIM *rd_free = NULL, *rd_active = NULL, *rd_inactive = NULL, *rd_wired = NULL,
993 + *rd_cache = NULL, *rd_laundry = NULL, *rd_buffers = NULL;
994
995 if (unlikely(!st)) {
996 st = rrdset_create_localhost(
@@ -1006,6 +1014,9 @@ int do_system_ram(int update_every, usec_t dt) {
1014 rd_wired = rrddim_add(st, "wired", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1015 #if __FreeBSD_version < 1200016
1016 rd_cache = rrddim_add(st, "cache", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1017 +#endif
1018 +#if defined(NETDATA_COLLECT_LAUNDRY)
1019 + rd_laundry = rrddim_add(st, "laundry", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1020 #endif
1021 rd_buffers = rrddim_add(st, "buffers", NULL, 1, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1022 }
@@ -1017,6 +1028,9 @@ int do_system_ram(int update_every, usec_t dt) {
1028 rrddim_set_by_pointer(st, rd_wired, vmmeter_data.v_wire_count);
1029 #if __FreeBSD_version < 1200016
1030 rrddim_set_by_pointer(st, rd_cache, vmmeter_data.v_cache_count);
1031 +#endif
1032 +#if defined(NETDATA_COLLECT_LAUNDRY)
1033 + rrddim_set_by_pointer(st, rd_laundry, vmmeter_data.v_laundry_count);
1034 #endif
1035 rrddim_set_by_pointer(st, rd_buffers, vfs_bufspace_count);
1036 rrdset_done(st);
health/health.d/ram.conf
+2 -2
@@ -41,7 +41,7 @@ alarm: ram_in_use
41 on: system.ram
42 os: freebsd
43 hosts: *
44 - calc: ($active + $wired + $buffers - $used_ram_to_ignore) * 100 / ($active + $wired + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
44 + calc: ($active + $wired + $laundry + $buffers - $used_ram_to_ignore) * 100 / ($active + $wired + $laundry + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
45 units: %
46 every: 10s
47 warn: $this > (($status >= $WARNING) ? (80) : (90))
@@ -54,7 +54,7 @@ delay: down 15m multiplier 1.5 max 1h
54 on: system.ram
55 os: freebsd
56 hosts: *
57 - calc: ($free + $inactive + $used_ram_to_ignore) * 100 / ($free + $active + $inactive + $wired + $cache + $buffers)
57 + calc: ($free + $inactive + $used_ram_to_ignore) * 100 / ($free + $active + $inactive + $wired + $cache + $laundry + $buffers)
58 units: %
59 every: 10s
60 warn: $this < (($status >= $WARNING) ? ( 5) : (10))