Skip to content
Merged
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
17 changes: 16 additions & 1 deletion plugins/in_node_exporter_metrics/ne_sockstat_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#define _GNU_SOURCE

#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <limits.h>

#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_input_plugin.h>
Expand Down Expand Up @@ -168,6 +171,9 @@ static int sockstat_update(struct flb_ne *ctx)
int i;
struct flb_slist_entry *key;
struct flb_slist_entry *val;
int path_len;
char ipv6_proc_path[PATH_MAX];
struct stat st;

mk_list_init(&list);
ret = ne_utils_file_read_lines(ctx->path_procfs, "/net/sockstat", &list);
Expand Down Expand Up @@ -296,7 +302,16 @@ static int sockstat_update(struct flb_ne *ctx)

flb_slist_destroy(&list);

/* Parse IPv6 statistics */
/* Parse IPv6 statistics (if enabled) */
path_len = snprintf(ipv6_proc_path, sizeof(ipv6_proc_path), "%s%s", ctx->path_procfs, "/net/sockstat6");
if (path_len < 0 || path_len >= (int) sizeof(ipv6_proc_path)) {
return -1;
}
ret = stat(ipv6_proc_path, &st);
if (ret == -1 && errno == ENOENT) {
flb_plg_debug(ctx->ins, "cannot read %s, skip ipv6 metrics collection", ipv6_proc_path);
return 0;
}
mk_list_init(&list);
ret = ne_utils_file_read_lines(ctx->path_procfs, "/net/sockstat6", &list);
if (ret != -1) {
Expand Down
Loading