| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_DISK_AWAIT_H |
| 4 | #define NETDATA_DISK_AWAIT_H |
| 5 | |
| 6 | #include "common-contexts.h" |
| 7 | |
| 8 | typedef struct { |
| 9 | RRDSET *st_await; |
| 10 | RRDDIM *rd_await_reads; |
| 11 | RRDDIM *rd_await_writes; |
| 12 | } ND_DISK_AWAIT; |
| 13 | |
| 14 | static inline void common_disk_await(ND_DISK_AWAIT *d, const char *id, const char *name, double read_avg_ms, double write_avg_ms, int update_every, instance_labels_cb_t cb, void *data) { |
| 15 | if(unlikely(!d->st_await)) { |
| 16 | d->st_await = rrdset_create_localhost( |
| 17 | "disk_await" |
| 18 | , id |
| 19 | , name |
| 20 | , "latency" |
| 21 | , "disk.await" |
| 22 | , "Average Completed I/O Operation Time" |
| 23 | , "milliseconds/operation" |
| 24 | , _COMMON_PLUGIN_NAME |
| 25 | , _COMMON_PLUGIN_MODULE_NAME |
| 26 | , NETDATA_CHART_PRIO_DISK_AWAIT |
| 27 | , update_every |
| 28 | , RRDSET_TYPE_LINE |
| 29 | ); |
| 30 | |
| 31 | d->rd_await_reads = rrddim_add(d->st_await, "reads", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); |
| 32 | d->rd_await_writes = rrddim_add(d->st_await, "writes", NULL, -1, 1000, RRD_ALGORITHM_ABSOLUTE); |
| 33 | |
| 34 | if(cb) |
| 35 | cb(d->st_await, 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_await, d->rd_await_reads, (collected_number)(read_avg_ms * 1000.0)); |
| 40 | rrddim_set_by_pointer(d->st_await, d->rd_await_writes, (collected_number)(write_avg_ms * 1000.0)); |
| 41 | rrdset_done(d->st_await); |
| 42 | } |
| 43 | |
| 44 | #endif //NETDATA_DISK_AWAIT_H |