master
h 38 lines 1.18 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_SYSTEM_IO_H
4 #define NETDATA_SYSTEM_IO_H
5
6 #include "common-contexts.h"
7
8 static inline void common_system_io(uint64_t read_bytes, uint64_t write_bytes, int update_every) {
9 static RRDSET *st_io = NULL;
10 static RRDDIM *rd_in = NULL, *rd_out = NULL;
11
12 if(unlikely(!st_io)) {
13 st_io = rrdset_create_localhost(
14 "system"
15 , "io"
16 , NULL
17 , "disk"
18 , NULL
19 , "Disk I/O"
20 , "KiB/s"
21 , _COMMON_PLUGIN_NAME
22 , _COMMON_PLUGIN_MODULE_NAME
23 , NETDATA_CHART_PRIO_SYSTEM_IO
24 , update_every
25 , RRDSET_TYPE_AREA
26 );
27
28 rd_in = rrddim_add(st_io, "in", "reads", 1, 1024, RRD_ALGORITHM_INCREMENTAL);
29 rd_out = rrddim_add(st_io, "out", "writes", -1, 1024, RRD_ALGORITHM_INCREMENTAL);
30 }
31
32 // this always have to be in base units, so that exporting sends base units to other time-series db
33 rrddim_set_by_pointer(st_io, rd_in, (collected_number)read_bytes);
34 rrddim_set_by_pointer(st_io, rd_out, (collected_number)write_bytes);
35 rrdset_done(st_io);
36 }
37
38 #endif //NETDATA_SYSTEM_IO_H