diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2022-06-16 16:38:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-16 16:38:51 +0300 |
commit | 131e5f5f6e5822a1fd8107c228f1a9a49f08e847 (patch) | |
tree | f44a0ef13b3a6898639144d07187b16a8707f9f8 /collectors | |
parent | c39ebcb87d21948931096b742cb07ecdae381c88 (diff) |
Add mem.available chart to FreeBSD (#13140)
Diffstat (limited to 'collectors')
-rw-r--r-- | collectors/freebsd.plugin/freebsd_sysctl.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/collectors/freebsd.plugin/freebsd_sysctl.c b/collectors/freebsd.plugin/freebsd_sysctl.c index c43743c35e..2583d7d18c 100644 --- a/collectors/freebsd.plugin/freebsd_sysctl.c +++ b/collectors/freebsd.plugin/freebsd_sysctl.c @@ -1005,9 +1005,9 @@ int do_system_ram(int update_every, usec_t dt) { // -------------------------------------------------------------------- - static RRDSET *st = NULL; + static RRDSET *st = NULL, *st_mem_available = NULL; static RRDDIM *rd_free = NULL, *rd_active = NULL, *rd_inactive = NULL, *rd_wired = NULL, - *rd_cache = NULL, *rd_buffers = NULL; + *rd_cache = NULL, *rd_buffers = NULL, *rd_avail = NULL; #if defined(NETDATA_COLLECT_LAUNDRY) static RRDDIM *rd_laundry = NULL; @@ -1055,6 +1055,34 @@ int do_system_ram(int update_every, usec_t dt) { #endif rrddim_set_by_pointer(st, rd_buffers, vfs_bufspace_count); rrdset_done(st); + + if (unlikely(!st_mem_available)) { + st_mem_available = rrdset_create_localhost( + "mem", + "available", + NULL, + "system", + NULL, + "Available RAM for applications", + "MiB", + "freebsd.plugin", + "system.ram", + NETDATA_CHART_PRIO_MEM_SYSTEM_AVAILABLE, + update_every, + RRDSET_TYPE_AREA + ); + + rd_avail = rrddim_add(st_mem_available, "MemAvailable", "avail", system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE); + } + else rrdset_next(st_mem_available); + +#if __FreeBSD_version < 1200016 + 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)); +#else + 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); +#endif + + rrdset_done(st_mem_available); } return 0; |