From 83ba6762cc43d9db581b979bb5e3445669e46cc2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 25 Nov 2024 18:33:56 +0100 Subject: Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145). Signed-off-by: Daniel Baumann --- src/collectors/common-contexts/disk-svctm.h | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/collectors/common-contexts/disk-svctm.h (limited to 'src/collectors/common-contexts/disk-svctm.h') diff --git a/src/collectors/common-contexts/disk-svctm.h b/src/collectors/common-contexts/disk-svctm.h new file mode 100644 index 000000000..f1d07c150 --- /dev/null +++ b/src/collectors/common-contexts/disk-svctm.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef NETDATA_DISK_SVCTM_H +#define NETDATA_DISK_SVCTM_H + +#include "common-contexts.h" + +typedef struct { + RRDSET *st_svctm; + RRDDIM *rd_svctm; +} ND_DISK_SVCTM; + +static inline void common_disk_svctm(ND_DISK_SVCTM *d, const char *id, const char *name, double svctm_ms, int update_every, instance_labels_cb_t cb, void *data) { + if(unlikely(!d->st_svctm)) { + d->st_svctm = rrdset_create_localhost( + "disk_svctm" + , id + , name + , "latency" + , "disk.svctm" + , "Average Service Time" + , "milliseconds/operation" + , _COMMON_PLUGIN_NAME + , _COMMON_PLUGIN_MODULE_NAME + , NETDATA_CHART_PRIO_DISK_SVCTM + , update_every + , RRDSET_TYPE_LINE + ); + + d->rd_svctm = rrddim_add(d->st_svctm, "svctm", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE); + + if(cb) + cb(d->st_svctm, data); + } + + // this always have to be in base units, so that exporting sends base units to other time-series db + rrddim_set_by_pointer(d->st_svctm, d->rd_svctm, (collected_number)(svctm_ms * 1000.0)); + rrdset_done(d->st_svctm); +} + +#endif //NETDATA_DISK_SVCTM_H -- cgit v1.2.3