Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions plugins/in_node_exporter_metrics/ne_diskstats_darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ struct dt_metric {
static void metric_cache_set(struct flb_ne *ctx, void *metric, double factor, int *offset)
{
int id;
struct dt_metric *m;
struct dt_metric **cache;
struct dt_metric *cache;

id = *offset;

cache = (struct dt_metric **) ctx->dt_metrics;
m = (struct dt_metric *) &cache[id];
m->metric = metric;
m->factor = factor;
cache = (struct dt_metric *) ctx->dt_metrics;
cache[id].metric = metric;
cache[id].factor = factor;
(*offset)++;
}

Expand All @@ -80,11 +78,11 @@ static void metric_cache_update(struct flb_ne *ctx, int id, flb_sds_t device,
int ret = -1;
uint64_t ts;
struct dt_metric *m;
struct dt_metric **cache;
struct dt_metric *cache;
struct cmt_counter *c;

cache = (struct dt_metric **) ctx->dt_metrics;
m = (struct dt_metric *) &cache[id];
cache = (struct dt_metric *) ctx->dt_metrics;
m = &cache[id];

ts = cfl_time_now();

Expand Down
29 changes: 14 additions & 15 deletions plugins/in_node_exporter_metrics/ne_diskstats_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

#define KNOWN_FIELDS 17
#define SECTOR_SIZE 512
#define MS_TO_SECONDS .001

struct dt_metric {
void *metric;
Expand All @@ -81,15 +82,13 @@ struct dt_metric {
static void metric_cache_set(struct flb_ne *ctx, void *metric, double factor, int *offset)
{
int id;
struct dt_metric *m;
struct dt_metric **cache;
struct dt_metric *cache;

id = *offset;

cache = (struct dt_metric **) ctx->dt_metrics;
m = (struct dt_metric *) &cache[id];
m->metric = metric;
m->factor = factor;
cache = (struct dt_metric *) ctx->dt_metrics;
cache[id].metric = metric;
cache[id].factor = factor;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
(*offset)++;
}

Expand All @@ -100,12 +99,12 @@ static void metric_cache_update(struct flb_ne *ctx, int id, flb_sds_t device,
uint64_t ts;
double val;
struct dt_metric *m;
struct dt_metric **cache;
struct dt_metric *cache;
struct cmt_gauge *g;
struct cmt_counter *c;

cache = (struct dt_metric **) ctx->dt_metrics;
m = (struct dt_metric *) &cache[id];
cache = (struct dt_metric *) ctx->dt_metrics;
m = &cache[id];

ret = ne_utils_str_to_double(str_val, &val);
if (ret == -1) {
Expand Down Expand Up @@ -197,7 +196,7 @@ static int ne_diskstats_configure(struct flb_ne *ctx)
if (!c) {
return -1;
}
metric_cache_set(ctx, c, .001, &offset);
metric_cache_set(ctx, c, MS_TO_SECONDS, &offset);

/* node_disk_writes_completed_total */
c = cmt_counter_create(ctx->cmt, "node", "disk", "writes_completed_total",
Expand Down Expand Up @@ -233,7 +232,7 @@ static int ne_diskstats_configure(struct flb_ne *ctx)
if (!c) {
return -1;
}
metric_cache_set(ctx, c, .001, &offset);
metric_cache_set(ctx, c, MS_TO_SECONDS, &offset);

/* node_disk_io_now */
g = cmt_gauge_create(ctx->cmt, "node", "disk", "io_now",
Expand All @@ -251,7 +250,7 @@ static int ne_diskstats_configure(struct flb_ne *ctx)
if (!c) {
return -1;
}
metric_cache_set(ctx, c, .001, &offset);
metric_cache_set(ctx, c, MS_TO_SECONDS, &offset);

/* node_disk_io_time_weighted_seconds */
c = cmt_counter_create(ctx->cmt, "node", "disk", "io_time_weighted_seconds_total",
Expand All @@ -260,7 +259,7 @@ static int ne_diskstats_configure(struct flb_ne *ctx)
if (!c) {
return -1;
}
metric_cache_set(ctx, c, .001, &offset);
metric_cache_set(ctx, c, MS_TO_SECONDS, &offset);

/*
* Linux Kernel >= 4.18
Expand Down Expand Up @@ -301,7 +300,7 @@ static int ne_diskstats_configure(struct flb_ne *ctx)
if (!c) {
return -1;
}
metric_cache_set(ctx, c, .001, &offset);
metric_cache_set(ctx, c, MS_TO_SECONDS, &offset);

/*
* Linux Kernel >= 5.5
Expand All @@ -325,7 +324,7 @@ static int ne_diskstats_configure(struct flb_ne *ctx)
if (!c) {
return -1;
}
metric_cache_set(ctx, c, .001, &offset);
metric_cache_set(ctx, c, MS_TO_SECONDS, &offset);

return 0;
}
Expand Down
Loading