summaryrefslogtreecommitdiffstats
path: root/collectors/proc.plugin
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2022-06-13 20:35:45 +0300
committerGitHub <noreply@github.com>2022-06-13 20:35:45 +0300
commit1b0f6c6b2296dc082d85f38c298a61442dcf2490 (patch)
tree2cfee5101d9cae338d0635f44fe62b010f3548ee /collectors/proc.plugin
parent4c64b8ea4ff720d946bbb9a11ca7474c5673bb6c (diff)
Labels with dictionary (#13070)
* squashed and rebased to master * fix overflow and single character bug in sanitize; include rrd.h instead of node_info.h * added unittest for UTF-8 multibyte sanitization * Fix unit test compilation * Fix CMake build * remove double sanitizer for opentsdb; cleanup sanitize_json_string() * rename error_description to error_message to avoid conflict with json-c * revert last and undef error_description from json-c * more unittests; attempt to fix protobuf map issue * get rid of rrdlabels_get() and replace it with a safe version that writes the value to a buffer * added dictionary sorting unittest; rrdlabels_to_buffer() now is sorted * better sorted dictionary checking * proper unittesting for sorted dictionaries * call dictionary deletion callback when destroying the dictionary * remove obsolete variable * Fix exporting unit tests * Fix k8s label parsing test * workaround for cmocka and strdupz() * Bypass cmocka memory allocation check * Revert "Bypass cmocka memory allocation check" This reverts commit 4c49923839d9229bea23ca914dd8a0be1ebe2bf4. * Revert "workaround for cmocka and strdupz()" This reverts commit 7bebee04801db1865c748a7896d5fa54bb7104a5. * Bypass cmocka memory allocation checks * respect json formatting for chart labels * cloud sends colons * print the value only once * allow parenthesis in values and spaces; make stream sender send quotes for values Co-authored-by: Vladimir Kobal <vlad@prokk.net>
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r--collectors/proc.plugin/plugin_proc.h2
-rw-r--r--collectors/proc.plugin/proc_net_dev.c44
2 files changed, 23 insertions, 23 deletions
diff --git a/collectors/proc.plugin/plugin_proc.h b/collectors/proc.plugin/plugin_proc.h
index 1e3b829652..d5612df03b 100644
--- a/collectors/proc.plugin/plugin_proc.h
+++ b/collectors/proc.plugin/plugin_proc.h
@@ -54,7 +54,7 @@ extern unsigned long long zfs_arcstats_shrinkable_cache_size_bytes;
// netdev renames
extern void netdev_rename_device_add(
- const char *host_device, const char *container_device, const char *container_name, struct label *labels);
+ const char *host_device, const char *container_device, const char *container_name, DICTIONARY *labels);
extern void netdev_rename_device_del(const char *host_device);
#include "proc_self_mountinfo.h"
diff --git a/collectors/proc.plugin/proc_net_dev.c b/collectors/proc.plugin/proc_net_dev.c
index 74076ff769..089ca1bb75 100644
--- a/collectors/proc.plugin/proc_net_dev.c
+++ b/collectors/proc.plugin/proc_net_dev.c
@@ -90,7 +90,7 @@ static struct netdev {
const char *chart_family;
- struct label *chart_labels;
+ DICTIONARY *chart_labels;
int flipped;
unsigned long priority;
@@ -273,7 +273,7 @@ static void netdev_free_chart_strings(struct netdev *d) {
static void netdev_free(struct netdev *d) {
netdev_charts_release(d);
netdev_free_chart_strings(d);
- free_label_list(d->chart_labels);
+ rrdlabels_destroy(d->chart_labels);
freez((void *)d->name);
freez((void *)d->filename_speed);
@@ -295,7 +295,7 @@ static struct netdev_rename {
const char *container_device;
const char *container_name;
- struct label *chart_labels;
+ DICTIONARY *chart_labels;
int processed;
@@ -316,9 +316,7 @@ static struct netdev_rename *netdev_rename_find(const char *host_device, uint32_
}
// other threads can call this function to register a rename to a netdev
-void netdev_rename_device_add(
- const char *host_device, const char *container_device, const char *container_name, struct label *labels)
-{
+void netdev_rename_device_add(const char *host_device, const char *container_device, const char *container_name, DICTIONARY *labels) {
netdata_mutex_lock(&netdev_rename_mutex);
uint32_t hash = simple_hash(host_device);
@@ -328,7 +326,8 @@ void netdev_rename_device_add(
r->host_device = strdupz(host_device);
r->container_device = strdupz(container_device);
r->container_name = strdupz(container_name);
- update_label_list(&r->chart_labels, labels);
+ r->chart_labels = rrdlabels_create();
+ rrdlabels_migrate_to_these(r->chart_labels, labels);
r->hash = hash;
r->next = netdev_rename_root;
r->processed = 0;
@@ -344,7 +343,7 @@ void netdev_rename_device_add(
r->container_device = strdupz(container_device);
r->container_name = strdupz(container_name);
- update_label_list(&r->chart_labels, labels);
+ rrdlabels_migrate_to_these(r->chart_labels, labels);
r->processed = 0;
netdev_pending_renames++;
@@ -377,7 +376,7 @@ void netdev_rename_device_del(const char *host_device) {
freez((void *) r->host_device);
freez((void *) r->container_name);
freez((void *) r->container_device);
- free_label_list(r->chart_labels);
+ rrdlabels_destroy(r->chart_labels);
freez((void *) r);
break;
}
@@ -449,7 +448,7 @@ static inline void netdev_rename_cgroup(struct netdev *d, struct netdev_rename *
snprintfz(buffer, RRD_ID_LENGTH_MAX, "net %s", r->container_device);
d->chart_family = strdupz(buffer);
- update_label_list(&d->chart_labels, r->chart_labels);
+ rrdlabels_migrate_to_these(d->chart_labels, r->chart_labels);
d->priority = NETDATA_CHART_PRIO_CGROUP_NET_IFACE;
d->flipped = 1;
@@ -542,6 +541,7 @@ static struct netdev *get_netdev(const char *name) {
d->name = strdupz(name);
d->hash = simple_hash(d->name);
d->len = strlen(d->name);
+ d->chart_labels = rrdlabels_create();
d->chart_type_net_bytes = strdupz("net");
d->chart_type_net_compressed = strdupz("net_compressed");
@@ -881,7 +881,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
, RRDSET_TYPE_AREA
);
- rrdset_update_labels(d->st_bandwidth, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_bandwidth, d->chart_labels);
d->rd_rbytes = rrddim_add(d->st_bandwidth, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL);
d->rd_tbytes = rrddim_add(d->st_bandwidth, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL);
@@ -947,7 +947,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_speed, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_speed, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_speed, d->chart_labels);
d->rd_speed = rrddim_add(d->st_speed, "speed", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
@@ -982,7 +982,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_duplex, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_duplex, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_duplex, d->chart_labels);
d->rd_duplex = rrddim_add(d->st_duplex, "duplex", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
@@ -1013,7 +1013,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_operstate, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_operstate, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_operstate, d->chart_labels);
d->rd_operstate = rrddim_add(d->st_operstate, "state", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
@@ -1044,7 +1044,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_carrier, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_carrier, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_carrier, d->chart_labels);
d->rd_carrier = rrddim_add(d->st_carrier, "carrier", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
@@ -1075,7 +1075,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_mtu, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_mtu, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_mtu, d->chart_labels);
d->rd_mtu = rrddim_add(d->st_mtu, "mtu", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
@@ -1111,7 +1111,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_packets, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_packets, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_packets, d->chart_labels);
d->rd_rpackets = rrddim_add(d->st_packets, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_tpackets = rrddim_add(d->st_packets, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -1159,7 +1159,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_errors, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_errors, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_errors, d->chart_labels);
d->rd_rerrors = rrddim_add(d->st_errors, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_terrors = rrddim_add(d->st_errors, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -1205,7 +1205,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_drops, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_drops, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_drops, d->chart_labels);
d->rd_rdrops = rrddim_add(d->st_drops, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_tdrops = rrddim_add(d->st_drops, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -1251,7 +1251,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_fifo, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_fifo, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_fifo, d->chart_labels);
d->rd_rfifo = rrddim_add(d->st_fifo, "receive", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_tfifo = rrddim_add(d->st_fifo, "transmit", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -1297,7 +1297,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_compressed, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_compressed, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_compressed, d->chart_labels);
d->rd_rcompressed = rrddim_add(d->st_compressed, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_tcompressed = rrddim_add(d->st_compressed, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -1343,7 +1343,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
rrdset_flag_set(d->st_events, RRDSET_FLAG_DETAIL);
- rrdset_update_labels(d->st_events, d->chart_labels);
+ rrdset_update_rrdlabels(d->st_events, d->chart_labels);
d->rd_rframe = rrddim_add(d->st_events, "frames", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_tcollisions = rrddim_add(d->st_events, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);