| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_DISK_QOPS_H |
| 4 | #define NETDATA_DISK_QOPS_H |
| 5 | |
| 6 | #include "common-contexts.h" |
| 7 | |
| 8 | typedef struct { |
| 9 | RRDSET *st_qops; |
| 10 | RRDDIM *rd_qops; |
| 11 | } ND_DISK_QOPS; |
| 12 | |
| 13 | static inline void common_disk_qops(ND_DISK_QOPS *d, const char *id, const char *name, uint64_t queued_ops, int update_every, instance_labels_cb_t cb, void *data) { |
| 14 | if(unlikely(!d->st_qops)) { |
| 15 | d->st_qops = rrdset_create_localhost( |
| 16 | "disk_qops" |
| 17 | , id |
| 18 | , name |
| 19 | , "ops" |
| 20 | , "disk.qops" |
| 21 | , "Disk Current I/O Operations" |
| 22 | , "operations" |
| 23 | , _COMMON_PLUGIN_NAME |
| 24 | , _COMMON_PLUGIN_MODULE_NAME |
| 25 | , NETDATA_CHART_PRIO_DISK_QOPS |
| 26 | , update_every |
| 27 | , RRDSET_TYPE_LINE |
| 28 | ); |
| 29 | |
| 30 | d->rd_qops = rrddim_add(d->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); |
| 31 | |
| 32 | if(cb) |
| 33 | cb(d->st_qops, 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_qops, d->rd_qops, (collected_number)queued_ops); |
| 38 | rrdset_done(d->st_qops); |
| 39 | } |
| 40 | |
| 41 | #endif //NETDATA_DISK_QOPS_H |