master
h 41 lines 1.24 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_DISK_UTIL_H
4 #define NETDATA_DISK_UTIL_H
5
6 #include "common-contexts.h"
7
8 typedef struct {
9 RRDSET *st_util;
10 RRDDIM *rd_util;
11 } ND_DISK_UTIL;
12
13 static inline void common_disk_util(ND_DISK_UTIL *d, const char *id, const char *name, uint64_t percent, int update_every, instance_labels_cb_t cb, void *data) {
14 if(unlikely(!d->st_util)) {
15 d->st_util = rrdset_create_localhost(
16 "disk_util"
17 , id
18 , name
19 , "utilization"
20 , "disk.util"
21 , "Disk Utilization Time"
22 , "% of time working"
23 , _COMMON_PLUGIN_NAME
24 , _COMMON_PLUGIN_MODULE_NAME
25 , NETDATA_CHART_PRIO_DISK_UTIL
26 , update_every
27 , RRDSET_TYPE_AREA
28 );
29
30 d->rd_util = rrddim_add(d->st_util, "utilization", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
31
32 if(cb)
33 cb(d->st_util, data);
34 }
35
36 // this always have to be in base units, so that exporting sends base units to other time-series db
37 rrddim_set_by_pointer(d->st_util, d->rd_util, (collected_number)percent);
38 rrdset_done(d->st_util);
39 }
40
41 #endif //NETDATA_DISK_UTIL_H