master
h 44 lines 1.5 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_DISK_IOTIME_H
4 #define NETDATA_DISK_IOTIME_H
5
6 #include "common-contexts.h"
7
8 typedef struct {
9 RRDSET *st_iotime;
10 RRDDIM *rd_reads_ms;
11 RRDDIM *rd_writes_ms;
12 } ND_DISK_IOTIME;
13
14 static inline void common_disk_iotime(ND_DISK_IOTIME *d, const char *id, const char *name, uint64_t reads_ms, uint64_t writes_ms, int update_every, instance_labels_cb_t cb, void *data) {
15 if(unlikely(!d->st_iotime)) {
16 d->st_iotime = rrdset_create_localhost(
17 "disk_iotime"
18 , id
19 , name
20 , "utilization"
21 , "disk.iotime"
22 , "Disk Total I/O Time"
23 , "milliseconds/s"
24 , _COMMON_PLUGIN_NAME
25 , _COMMON_PLUGIN_MODULE_NAME
26 , NETDATA_CHART_PRIO_DISK_IOTIME
27 , update_every
28 , RRDSET_TYPE_AREA
29 );
30
31 d->rd_reads_ms = rrddim_add(d->st_iotime, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
32 d->rd_writes_ms = rrddim_add(d->st_iotime, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
33
34 if(cb)
35 cb(d->st_iotime, data);
36 }
37
38 // this always have to be in base units, so that exporting sends base units to other time-series db
39 rrddim_set_by_pointer(d->st_iotime, d->rd_reads_ms, (collected_number)reads_ms);
40 rrddim_set_by_pointer(d->st_iotime, d->rd_writes_ms, (collected_number)writes_ms);
41 rrdset_done(d->st_iotime);
42 }
43
44 #endif //NETDATA_DISK_IOTIME_H