Skip to content

Commit

Permalink
in_node_exporter_metrics: systemd: treat states as boolean values.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Jul 27, 2024
1 parent 5c7a94f commit 8f3d1d3
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions plugins/in_node_exporter_metrics/ne_systemd_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,29 @@ static int ne_systemd_update_unit_state(struct flb_ne *ctx)
}

for(index = 0 ; index < 5 ; index++) {
cmt_gauge_add(ctx->systemd_unit_state,
timestamp,
0,
3,
(char *[]){ unit.name,
if (strcmp(unit_states[index], unit.active_state) == 0) {
cmt_gauge_set(ctx->systemd_unit_state,
timestamp,
1,
3,
(char *[]){ unit.name,
unit_states[index],
unit.type
});
}
);
}
else {
cmt_gauge_set(ctx->systemd_unit_state,
timestamp,
0,
3,
(char *[]){ unit.name,
unit_states[index],
unit.type
});
}
}

cmt_gauge_inc(ctx->systemd_unit_state,
timestamp,
3,
(char *[]){ unit.name,
unit.active_state,
unit.type
});


if (unit.type != NULL) {
free(unit.type);
}
Expand Down

0 comments on commit 8f3d1d3

Please sign in to comment.