master
h 35 lines 1.12 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_MEM_AVAILABLE_H
4 #define NETDATA_MEM_AVAILABLE_H
5 #include "common-contexts.h"
6
7 static inline void common_mem_available(uint64_t available_bytes, int update_every) {
8 static RRDSET *st_mem_available = NULL;
9 static RRDDIM *rd_avail = NULL;
10
11 if(unlikely(!st_mem_available)) {
12 st_mem_available = rrdset_create_localhost(
13 "mem"
14 , "available"
15 , NULL
16 , "overview"
17 , NULL
18 , "Available RAM for applications"
19 , "MiB"
20 , _COMMON_PLUGIN_NAME
21 , _COMMON_PLUGIN_MODULE_NAME
22 , NETDATA_CHART_PRIO_MEM_SYSTEM_AVAILABLE
23 , update_every
24 , RRDSET_TYPE_AREA
25 );
26
27 rd_avail = rrddim_add(st_mem_available, "avail", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
28 }
29
30 // this always have to be in base units, so that exporting sends base units to other time-series db
31 rrddim_set_by_pointer(st_mem_available, rd_avail, (collected_number)available_bytes);
32 rrdset_done(st_mem_available);
33 }
34
35 #endif //NETDATA_MEM_AVAILABLE_H