master
h 41 lines 1.22 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_DISK_BUSY_H
4 #define NETDATA_DISK_BUSY_H
5
6 #include "common-contexts.h"
7
8 typedef struct {
9 RRDSET *st_busy;
10 RRDDIM *rd_busy;
11 } ND_DISK_BUSY;
12
13 static inline void common_disk_busy(ND_DISK_BUSY *d, const char *id, const char *name, uint64_t busy_ms, int update_every, instance_labels_cb_t cb, void *data) {
14 if(unlikely(!d->st_busy)) {
15 d->st_busy = rrdset_create_localhost(
16 "disk_busy"
17 , id
18 , name
19 , "utilization"
20 , "disk.busy"
21 , "Disk Busy Time"
22 , "milliseconds"
23 , _COMMON_PLUGIN_NAME
24 , _COMMON_PLUGIN_MODULE_NAME
25 , NETDATA_CHART_PRIO_DISK_BUSY
26 , update_every
27 , RRDSET_TYPE_AREA
28 );
29
30 d->rd_busy = rrddim_add(d->st_busy, "busy", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
31
32 if(cb)
33 cb(d->st_busy, 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_busy, d->rd_busy, (collected_number)busy_ms);
38 rrdset_done(d->st_busy);
39 }
40
41 #endif //NETDATA_DISK_BUSY_H