summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2024-02-18 23:16:31 +0100
committerToni Uhlig <matzeton@googlemail.com>2024-02-20 23:16:31 +0100
commit717d66b0e7a05eb0d22c85fda7a4448885e7f1ec (patch)
treecb82321b2f69214bd5e080bb57ff703d0f6b464b
parent791b27219dc4f7680c072a601558af3977a30bbd (diff)
Fixed missing statistics updating for unknown mapping keys in collectd/influxd.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--examples/c-collectd/c-collectd.c5
-rw-r--r--examples/c-influxd/c-influxd.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c
index e17267ee3..9f230495a 100644
--- a/examples/c-collectd/c-collectd.c
+++ b/examples/c-collectd/c-collectd.c
@@ -1074,6 +1074,8 @@ static ssize_t collectd_map_index(char const * const json_key,
struct global_map const * const map,
size_t map_length)
{
+ ssize_t unknown_key = -1;
+
if (json_key == NULL || key_length == 0)
{
return -1;
@@ -1083,6 +1085,7 @@ static ssize_t collectd_map_index(char const * const json_key,
{
if (map[i].json_key == NULL)
{
+ unknown_key = i;
continue;
}
@@ -1092,7 +1095,7 @@ static ssize_t collectd_map_index(char const * const json_key,
}
}
- return -1;
+ return unknown_key;
}
static int collectd_map_flow_u8(struct nDPIsrvd_socket * const sock,
diff --git a/examples/c-influxd/c-influxd.c b/examples/c-influxd/c-influxd.c
index ed6f2e99e..c58c36ae3 100644
--- a/examples/c-influxd/c-influxd.c
+++ b/examples/c-influxd/c-influxd.c
@@ -946,6 +946,8 @@ static ssize_t influxd_map_index(char const * const json_key,
struct global_map const * const map,
size_t map_length)
{
+ ssize_t unknown_key = -1;
+
if (json_key == NULL || key_length == 0)
{
return -1;
@@ -955,6 +957,7 @@ static ssize_t influxd_map_index(char const * const json_key,
{
if (map[i].json_key == NULL)
{
+ unknown_key = i;
continue;
}
@@ -964,7 +967,7 @@ static ssize_t influxd_map_index(char const * const json_key,
}
}
- return -1;
+ return unknown_key;
}
static int influxd_map_flow_u8(struct nDPIsrvd_socket * const sock,