@cryptotaxi247 / netdata-1 / commits / 131e5f5f6

Add mem.available chart to FreeBSD (#13140)

Emmanuel Vasilakis committed Jun 16, 2022 at 16:38 UTC 131e5f5f6e5822a1fd8107c228f1a9a49f08e847
3 files changed +39 -6
collectors/freebsd.plugin/freebsd_sysctl.c
+30 -2
@@ -1005,9 +1005,9 @@ int do_system_ram(int update_every, usec_t dt) {
1005
1006 // --------------------------------------------------------------------
1007
1008 - static RRDSET *st = NULL;
1008 + static RRDSET *st = NULL, *st_mem_available = NULL;
1009 static RRDDIM *rd_free = NULL, *rd_active = NULL, *rd_inactive = NULL, *rd_wired = NULL,
1010 - *rd_cache = NULL, *rd_buffers = NULL;
1010 + *rd_cache = NULL, *rd_buffers = NULL, *rd_avail = NULL;
1011
1012 #if defined(NETDATA_COLLECT_LAUNDRY)
1013 static RRDDIM *rd_laundry = NULL;
@@ -1055,6 +1055,34 @@ int do_system_ram(int update_every, usec_t dt) {
1055 #endif
1056 rrddim_set_by_pointer(st, rd_buffers, vfs_bufspace_count);
1057 rrdset_done(st);
1058 +
1059 + if (unlikely(!st_mem_available)) {
1060 + st_mem_available = rrdset_create_localhost(
1061 + "mem",
1062 + "available",
1063 + NULL,
1064 + "system",
1065 + NULL,
1066 + "Available RAM for applications",
1067 + "MiB",
1068 + "freebsd.plugin",
1069 + "system.ram",
1070 + NETDATA_CHART_PRIO_MEM_SYSTEM_AVAILABLE,
1071 + update_every,
1072 + RRDSET_TYPE_AREA
1073 + );
1074 +
1075 + rd_avail = rrddim_add(st_mem_available, "MemAvailable", "avail", system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1076 + }
1077 + else rrdset_next(st_mem_available);
1078 +
1079 +#if __FreeBSD_version < 1200016
1080 + rrddim_set_by_pointer(st_mem_available, rd_avail, vmmeter_data.v_inactive_count + vmmeter_data.v_free_count + (vmmeter_data.v_cache_count * system_pagesize + zfs_arcstats_shrinkable_cache_size_bytes));
1081 +#else
1082 + rrddim_set_by_pointer(st_mem_available, rd_avail, vmmeter_data.v_inactive_count + vmmeter_data.v_free_count + zfs_arcstats_shrinkable_cache_size_bytes);
1083 +#endif
1084 +
1085 + rrdset_done(st_mem_available);
1086 }
1087
1088 return 0;
health/health.d/ram.conf
+3 -3
@@ -54,7 +54,7 @@ host labels: _is_k8s_node = false
54 component: Memory
55 os: freebsd
56 hosts: *
57 - calc: ($active + $wired + $laundry + $buffers) * 100 / ($active + $wired + $laundry + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
57 + calc: ($active + $wired + $laundry + $buffers) * 100 / ($active + $wired + $laundry + $buffers + $cache + $free + $inactive)
58 units: %
59 every: 10s
60 warn: $this > (($status >= $WARNING) ? (80) : (90))
@@ -64,13 +64,13 @@ component: Memory
64 to: sysadmin
65
66 alarm: ram_available
67 - on: system.ram
67 + on: mem.available
68 class: Utilization
69 type: System
70 component: Memory
71 os: freebsd
72 hosts: *
73 - calc: ($free + $inactive + $cache) * 100 / ($free + $active + $inactive + $wired + $cache + $laundry + $buffers)
73 + calc: $avail * 100 / ($system.ram.free + $system.ram.active + $system.ram.inactive + $system.ram.wired + $system.ram.cache + $system.ram.laundry + $system.ram.buffers)
74 units: %
75 every: 10s
76 warn: $this < (($status >= $WARNING) ? (15) : (10))
web/gui/dashboard_info.js
+6 -1
@@ -1734,7 +1734,12 @@ netdataDashboard.context = {
1734 },
1735
1736 'mem.available': {
1737 - info: 'Available Memory is estimated by the kernel, as the amount of RAM that can be used by userspace processes, without causing swapping.'
1737 + info: function (os) {
1738 + if (os === "freebsd")
1739 + return 'The amount of memory that can be used by user-space processes without causing swapping. Calculated as the sum of free, cached, and inactive memory.';
1740 + else
1741 + return 'Available Memory is estimated by the kernel, as the amount of RAM that can be used by userspace processes, without causing swapping.';
1742 + }
1743 },
1744
1745 'mem.writeback': {