Skip to content

Commit

Permalink
Windows storage metrics (netdata#18810)
Browse files Browse the repository at this point in the history
* added disk.ops

* claiming should wait for node id and status ONLINE only

* fix compilation on linux

* fix ops on windows

* added disk.util

* disk.busy

* disk.iotime

* disk.qops

* added cleanup to windows disk metrics

* updated cmake

* remove duplicate cleanup

* undo identation

* do not repeateadly try to find non-existing metrics

* log once the metrics perflib gives up
  • Loading branch information
ktsaou authored Oct 19, 2024
1 parent a78e8e1 commit 7d8da98
Show file tree
Hide file tree
Showing 12 changed files with 530 additions and 225 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,12 @@ endif()

set(INTERNAL_COLLECTORS_FILES
src/collectors/common-contexts/common-contexts.h
src/collectors/common-contexts/disk-busy.h
src/collectors/common-contexts/disk-io.h
src/collectors/common-contexts/disk-iotime.h
src/collectors/common-contexts/disk-ops.h
src/collectors/common-contexts/disk-qops.h
src/collectors/common-contexts/disk-util.h
src/collectors/common-contexts/system-io.h
src/collectors/common-contexts/system-interrupts.h
src/collectors/common-contexts/system-processes.h
Expand Down
5 changes: 5 additions & 0 deletions src/collectors/common-contexts/common-contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ typedef void (*instance_labels_cb_t)(RRDSET *st, void *data);
#include "mem-pgfaults.h"
#include "mem-available.h"
#include "disk-io.h"
#include "disk-ops.h"
#include "disk-qops.h"
#include "disk-util.h"
#include "disk-busy.h"
#include "disk-iotime.h"

#endif //NETDATA_COMMON_CONTEXTS_H
43 changes: 43 additions & 0 deletions src/collectors/common-contexts/disk-busy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_DISK_BUSY_H
#define NETDATA_DISK_BUSY_H

#include "common-contexts.h"

typedef struct {
RRDSET *st_busy;
RRDDIM *rd_busy;
} ND_DISK_BUSY;

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) {
if(unlikely(!d->st_busy)) {
d->st_busy = rrdset_create_localhost(
"disk_busy"
, id
, name
, "utilization"
, "disk.busy"
, "Disk Busy Time"
, "milliseconds"
, _COMMON_PLUGIN_NAME
, _COMMON_PLUGIN_MODULE_NAME
, NETDATA_CHART_PRIO_DISK_BUSY
, update_every
, RRDSET_TYPE_AREA
);

rrdset_flag_set(d->st_busy, RRDSET_FLAG_DETAIL);

d->rd_busy = rrddim_add(d->st_busy, "busy", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);

if(cb)
cb(d->st_busy, 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_busy, d->rd_busy, (collected_number)busy_ms);
rrdset_done(d->st_busy);
}

#endif //NETDATA_DISK_BUSY_H
46 changes: 46 additions & 0 deletions src/collectors/common-contexts/disk-iotime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_DISK_IOTIME_H
#define NETDATA_DISK_IOTIME_H

#include "common-contexts.h"

typedef struct {
RRDSET *st_iotime;
RRDDIM *rd_reads_ms;
RRDDIM *rd_writes_ms;
} ND_DISK_IOTIME;

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) {
if(unlikely(!d->st_iotime)) {
d->st_iotime = rrdset_create_localhost(
"disk_iotime"
, id
, name
, "utilization"
, "disk.iotime"
, "Disk Total I/O Time"
, "milliseconds/s"
, _COMMON_PLUGIN_NAME
, _COMMON_PLUGIN_MODULE_NAME
, NETDATA_CHART_PRIO_DISK_IOTIME
, update_every
, RRDSET_TYPE_AREA
);

rrdset_flag_set(d->st_iotime, RRDSET_FLAG_DETAIL);

d->rd_reads_ms = rrddim_add(d->st_iotime, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_writes_ms = rrddim_add(d->st_iotime, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);

if(cb)
cb(d->st_iotime, 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_iotime, d->rd_reads_ms, (collected_number)reads_ms);
rrddim_set_by_pointer(d->st_iotime, d->rd_writes_ms, (collected_number)writes_ms);
rrdset_done(d->st_iotime);
}

#endif //NETDATA_DISK_IOTIME_H
44 changes: 44 additions & 0 deletions src/collectors/common-contexts/disk-ops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_DISK_OPS_H
#define NETDATA_DISK_OPS_H

#include "common-contexts.h"

typedef struct {
RRDSET *st_ops;
RRDDIM *rd_ops_reads;
RRDDIM *rd_ops_writes;
} ND_DISK_OPS;

static inline void common_disk_ops(ND_DISK_OPS *d, const char *id, const char *name, uint64_t ops_read, uint64_t ops_write, int update_every, instance_labels_cb_t cb, void *data) {
if(unlikely(!d->st_ops)) {
d->st_ops = rrdset_create_localhost(
"disk_ops"
, id
, name
, "ops"
, "disk.ops"
, "Disk Completed I/O Operations"
, "operations/s"
, _COMMON_PLUGIN_NAME
, _COMMON_PLUGIN_MODULE_NAME
, NETDATA_CHART_PRIO_DISK_OPS
, update_every
, RRDSET_TYPE_LINE
);

d->rd_ops_reads = rrddim_add(d->st_ops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_ops_writes = rrddim_add(d->st_ops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);

if(cb)
cb(d->st_ops, 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_ops, d->rd_ops_reads, (collected_number)ops_read);
rrddim_set_by_pointer(d->st_ops, d->rd_ops_writes, (collected_number)ops_write);
rrdset_done(d->st_ops);
}

#endif //NETDATA_DISK_OPS_H
41 changes: 41 additions & 0 deletions src/collectors/common-contexts/disk-qops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_DISK_QOPS_H
#define NETDATA_DISK_QOPS_H

#include "common-contexts.h"

typedef struct {
RRDSET *st_qops;
RRDDIM *rd_qops;
} ND_DISK_QOPS;

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) {
if(unlikely(!d->st_qops)) {
d->st_qops = rrdset_create_localhost(
"disk_qops"
, id
, name
, "ops"
, "disk.qops"
, "Disk Current I/O Operations"
, "operations"
, _COMMON_PLUGIN_NAME
, _COMMON_PLUGIN_MODULE_NAME
, NETDATA_CHART_PRIO_DISK_QOPS
, update_every
, RRDSET_TYPE_LINE
);

d->rd_qops = rrddim_add(d->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);

if(cb)
cb(d->st_qops, 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_qops, d->rd_qops, (collected_number)queued_ops);
rrdset_done(d->st_qops);
}

#endif //NETDATA_DISK_QOPS_H
43 changes: 43 additions & 0 deletions src/collectors/common-contexts/disk-util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_DISK_UTIL_H
#define NETDATA_DISK_UTIL_H

#include "common-contexts.h"

typedef struct {
RRDSET *st_util;
RRDDIM *rd_util;
} ND_DISK_UTIL;

static inline void common_disk_util(ND_DISK_UTIL *d, const char *id, const char *name, uint64_t percent, int update_every, instance_labels_cb_t cb, void *data) {
if(unlikely(!d->st_util)) {
d->st_util = rrdset_create_localhost(
"disk_util"
, id
, name
, "utilization"
, "disk.util"
, "Disk Utilization Time"
, "% of time working"
, _COMMON_PLUGIN_NAME
, _COMMON_PLUGIN_MODULE_NAME
, NETDATA_CHART_PRIO_DISK_UTIL
, update_every
, RRDSET_TYPE_AREA
);

rrdset_flag_set(d->st_util, RRDSET_FLAG_DETAIL);

d->rd_util = rrddim_add(d->st_util, "utilization", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);

if(cb)
cb(d->st_util, 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_util, d->rd_util, (collected_number)percent);
rrdset_done(d->st_util);
}

#endif //NETDATA_DISK_UTIL_H
Loading

0 comments on commit 7d8da98

Please sign in to comment.