Skip to content

Commit

Permalink
in_node_exporter_metrics: Fix registering callback for systemd
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Aug 28, 2023
1 parent 1f125c5 commit ec308b2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/in_node_exporter_metrics/ne.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ static int in_ne_init(struct flb_input_instance *in,
ctx->coll_netdev_fd = -1;
ctx->coll_filefd_fd = -1;
ctx->coll_textfile_fd = -1;
ctx->coll_systemd_fd = -1;

ctx->callback = flb_callback_create(in->name);
if (!ctx->callback) {
Expand Down Expand Up @@ -680,12 +681,12 @@ static int in_ne_init(struct flb_input_instance *in,
}
ne_textfile_init(ctx);
}
else if (strncmp(entry->str, "systemd", 8) == 0) {
else if (strncmp(entry->str, "systemd", 7) == 0) {
if (ctx->systemd_scrape_interval == 0) {
flb_plg_debug(ctx->ins, "enabled metrics %s", entry->str);
metric_idx = 13;
}
else if (ctx->textfile_scrape_interval > 0) {
else if (ctx->systemd_scrape_interval > 0) {
/* Create the filefd collector */
ret = flb_input_set_collector_time(in,
ne_timer_systemd_metrics_cb,
Expand Down Expand Up @@ -782,7 +783,7 @@ static int in_ne_exit(void *data, struct flb_config *config)
else if (strncmp(entry->str, "textfile", 8) == 0) {
/* nop */
}
else if (strncmp(entry->str, "systemd", 8) == 0) {
else if (strncmp(entry->str, "systemd", 7) == 0) {
ne_systemd_exit(ctx);
}
else {
Expand Down Expand Up @@ -813,6 +814,9 @@ static int in_ne_exit(void *data, struct flb_config *config)
if (ctx->coll_netdev_fd != -1) {
ne_netdev_exit(ctx);
}
if (ctx->coll_systemd_fd != -1) {
ne_systemd_exit(ctx);
}

flb_ne_config_destroy(ctx);

Expand Down

0 comments on commit ec308b2

Please sign in to comment.