summaryrefslogtreecommitdiffstats
path: root/collectors/proc.plugin
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r--collectors/proc.plugin/plugin_proc.h7
-rw-r--r--collectors/proc.plugin/proc_diskstats.c127
-rw-r--r--collectors/proc.plugin/proc_interrupts.c4
-rw-r--r--collectors/proc.plugin/proc_mdstat.c42
-rw-r--r--collectors/proc.plugin/proc_net_dev.c202
-rw-r--r--collectors/proc.plugin/proc_net_wireless.c286
-rw-r--r--collectors/proc.plugin/proc_pagetypeinfo.c12
-rw-r--r--collectors/proc.plugin/proc_self_mountinfo.c41
-rw-r--r--collectors/proc.plugin/proc_self_mountinfo.h1
-rw-r--r--collectors/proc.plugin/proc_softirqs.c4
-rw-r--r--collectors/proc.plugin/proc_stat.c4
-rw-r--r--collectors/proc.plugin/sys_block_zram.c4
-rw-r--r--collectors/proc.plugin/sys_class_power_supply.c8
-rw-r--r--collectors/proc.plugin/sys_devices_system_edac_mc.c2
-rw-r--r--collectors/proc.plugin/sys_devices_system_node.c2
-rw-r--r--collectors/proc.plugin/sys_fs_btrfs.c13
16 files changed, 515 insertions, 244 deletions
diff --git a/collectors/proc.plugin/plugin_proc.h b/collectors/proc.plugin/plugin_proc.h
index 1e3b8296..8cb5431e 100644
--- a/collectors/proc.plugin/plugin_proc.h
+++ b/collectors/proc.plugin/plugin_proc.h
@@ -54,7 +54,12 @@ 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,
+ const char *ctx_prefix);
+
extern void netdev_rename_device_del(const char *host_device);
#include "proc_self_mountinfo.h"
diff --git a/collectors/proc.plugin/proc_diskstats.c b/collectors/proc.plugin/proc_diskstats.c
index cfaf2134..be4a481c 100644
--- a/collectors/proc.plugin/proc_diskstats.c
+++ b/collectors/proc.plugin/proc_diskstats.c
@@ -201,7 +201,7 @@ static unsigned long long int bcache_read_number_with_units(const char *filename
static int unknown_units_error = 10;
char *end = NULL;
- long double value = str2ld(buffer, &end);
+ NETDATA_DOUBLE value = str2ndd(buffer, &end);
if(end && *end) {
if(*end == 'k')
return (unsigned long long int)(value * 1024.0);
@@ -830,6 +830,30 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
return d;
}
+static void add_labels_to_disk(struct disk *d, RRDSET *st) {
+ rrdlabels_add(st->state->chart_labels, "device", d->disk, RRDLABEL_SRC_AUTO);
+ rrdlabels_add(st->state->chart_labels, "mount_point", d->mount_point, RRDLABEL_SRC_AUTO);
+
+ switch (d->type) {
+ default:
+ case DISK_TYPE_UNKNOWN:
+ rrdlabels_add(st->state->chart_labels, "device_type", "unknown", RRDLABEL_SRC_AUTO);
+ break;
+
+ case DISK_TYPE_PHYSICAL:
+ rrdlabels_add(st->state->chart_labels, "device_type", "physical", RRDLABEL_SRC_AUTO);
+ break;
+
+ case DISK_TYPE_PARTITION:
+ rrdlabels_add(st->state->chart_labels, "device_type", "partition", RRDLABEL_SRC_AUTO);
+ break;
+
+ case DISK_TYPE_VIRTUAL:
+ rrdlabels_add(st->state->chart_labels, "device_type", "virtual", RRDLABEL_SRC_AUTO);
+ break;
+ }
+}
+
int do_proc_diskstats(int update_every, usec_t dt) {
static procfile *ff = NULL;
@@ -1067,6 +1091,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_io_reads = rrddim_add(d->st_io, "reads", NULL, d->sector_size, 1024, RRD_ALGORITHM_INCREMENTAL);
d->rd_io_writes = rrddim_add(d->st_io, "writes", NULL, d->sector_size * -1, 1024, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_io);
}
else rrdset_next(d->st_io);
@@ -1094,8 +1120,9 @@ int do_proc_diskstats(int update_every, usec_t dt) {
, RRDSET_TYPE_AREA
);
- d->rd_io_discards =
- rrddim_add(d->st_ext_io, "discards", NULL, d->sector_size, 1024, RRD_ALGORITHM_INCREMENTAL);
+ d->rd_io_discards = rrddim_add(d->st_ext_io, "discards", NULL, d->sector_size, 1024, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_ext_io);
} else
rrdset_next(d->st_ext_io);
@@ -1130,6 +1157,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_ops_reads = rrddim_add(d->st_ops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_ops_writes = rrddim_add(d->st_ops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_ops);
}
else rrdset_next(d->st_ops);
@@ -1162,7 +1191,10 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_ops_discards = rrddim_add(d->st_ext_ops, "discards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
if (do_fl_stats)
d->rd_ops_flushes = rrddim_add(d->st_ext_ops, "flushes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- } else
+
+ add_labels_to_disk(d, d->st_ext_ops);
+ }
+ else
rrdset_next(d->st_ext_ops);
last_discards = rrddim_set_by_pointer(d->st_ext_ops, d->rd_ops_discards, discards);
@@ -1196,6 +1228,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_qops, RRDSET_FLAG_DETAIL);
d->rd_qops_operations = rrddim_add(d->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_qops);
}
else rrdset_next(d->st_qops);
@@ -1228,6 +1262,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_backlog, RRDSET_FLAG_DETAIL);
d->rd_backlog_backlog = rrddim_add(d->st_backlog, "backlog", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_backlog);
}
else rrdset_next(d->st_backlog);
@@ -1259,8 +1295,9 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_busy, RRDSET_FLAG_DETAIL);
- d->rd_busy_busy =
- rrddim_add(d->st_busy, "busy", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+ d->rd_busy_busy = rrddim_add(d->st_busy, "busy", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_busy);
}
else rrdset_next(d->st_busy);
@@ -1288,6 +1325,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_util, RRDSET_FLAG_DETAIL);
d->rd_util_utilization = rrddim_add(d->st_util, "utilization", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_util);
}
else rrdset_next(d->st_util);
@@ -1326,6 +1365,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_mops_reads = rrddim_add(d->st_mops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_mops_writes = rrddim_add(d->st_mops, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_mops);
}
else rrdset_next(d->st_mops);
@@ -1358,7 +1399,10 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_ext_mops, RRDSET_FLAG_DETAIL);
d->rd_mops_discards = rrddim_add(d->st_ext_mops, "discards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- } else
+
+ add_labels_to_disk(d, d->st_ext_mops);
+ }
+ else
rrdset_next(d->st_ext_mops);
rrddim_set_by_pointer(d->st_ext_mops, d->rd_mops_discards, mdiscards);
@@ -1391,6 +1435,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_iotime_reads = rrddim_add(d->st_iotime, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_iotime_writes = rrddim_add(d->st_iotime, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_iotime);
}
else rrdset_next(d->st_iotime);
@@ -1422,9 +1468,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_iotime_discards = rrddim_add(d->st_ext_iotime, "discards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
if (do_fl_stats)
- d->rd_iotime_flushes =
- rrddim_add(d->st_ext_iotime, "flushes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- } else
+ d->rd_iotime_flushes = rrddim_add(d->st_ext_iotime, "flushes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_ext_iotime);
+ }
+ else
rrdset_next(d->st_ext_iotime);
last_discardms = rrddim_set_by_pointer(d->st_ext_iotime, d->rd_iotime_discards, discardms);
@@ -1465,6 +1513,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_await_reads = rrddim_add(d->st_await, "reads", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
d->rd_await_writes = rrddim_add(d->st_await, "writes", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_await);
}
else rrdset_next(d->st_await);
@@ -1494,18 +1544,22 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_await_discards = rrddim_add(d->st_ext_await, "discards", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
if (do_fl_stats)
- d->rd_await_flushes =
- rrddim_add(d->st_ext_await, "flushes", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
- } else
+ d->rd_await_flushes = rrddim_add(d->st_ext_await, "flushes", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_ext_await);
+ }
+ else
rrdset_next(d->st_ext_await);
rrddim_set_by_pointer(
d->st_ext_await, d->rd_await_discards,
(discards - last_discards) ? (discardms - last_discardms) / (discards - last_discards) : 0);
+
if (do_fl_stats)
rrddim_set_by_pointer(
d->st_ext_await, d->rd_await_flushes,
(flushes - last_flushes) ? (flushms - last_flushms) / (flushes - last_flushes) : 0);
+
rrdset_done(d->st_ext_await);
}
@@ -1534,6 +1588,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_avgsz_reads = rrddim_add(d->st_avgsz, "reads", NULL, d->sector_size, 1024, RRD_ALGORITHM_ABSOLUTE);
d->rd_avgsz_writes = rrddim_add(d->st_avgsz, "writes", NULL, d->sector_size * -1, 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_avgsz);
}
else rrdset_next(d->st_avgsz);
@@ -1561,9 +1617,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_ext_avgsz, RRDSET_FLAG_DETAIL);
- d->rd_avgsz_discards =
- rrddim_add(d->st_ext_avgsz, "discards", NULL, d->sector_size, 1024, RRD_ALGORITHM_ABSOLUTE);
- } else
+ d->rd_avgsz_discards = rrddim_add(d->st_ext_avgsz, "discards", NULL, d->sector_size, 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_ext_avgsz);
+ }
+ else
rrdset_next(d->st_ext_avgsz);
rrddim_set_by_pointer(
@@ -1599,8 +1657,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
rrdset_flag_set(d->st_svctm, RRDSET_FLAG_DETAIL);
d->rd_svctm_svctm = rrddim_add(d->st_svctm, "svctm", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_svctm);
}
- else rrdset_next(d->st_svctm);
+ else
+ rrdset_next(d->st_svctm);
rrddim_set_by_pointer(d->st_svctm, d->rd_svctm_svctm, ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);
rrdset_done(d->st_svctm);
@@ -1705,8 +1766,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_bcache_hit_ratio_1hour = rrddim_add(d->st_bcache_hit_ratio, "1hour", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
d->rd_bcache_hit_ratio_1day = rrddim_add(d->st_bcache_hit_ratio, "1day", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
d->rd_bcache_hit_ratio_total = rrddim_add(d->st_bcache_hit_ratio, "ever", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_bcache_hit_ratio);
}
- else rrdset_next(d->st_bcache_hit_ratio);
+ else
+ rrdset_next(d->st_bcache_hit_ratio);
rrddim_set_by_pointer(d->st_bcache_hit_ratio, d->rd_bcache_hit_ratio_5min, stats_five_minute_cache_hit_ratio);
rrddim_set_by_pointer(d->st_bcache_hit_ratio, d->rd_bcache_hit_ratio_1hour, stats_hour_cache_hit_ratio);
@@ -1735,8 +1799,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_bcache_rate_congested = rrddim_add(d->st_bcache_rates, "congested", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
d->rd_bcache_rate_writeback = rrddim_add(d->st_bcache_rates, "writeback", NULL, -1, 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_bcache_rates);
}
- else rrdset_next(d->st_bcache_rates);
+ else
+ rrdset_next(d->st_bcache_rates);
rrddim_set_by_pointer(d->st_bcache_rates, d->rd_bcache_rate_writeback, writeback_rate);
rrddim_set_by_pointer(d->st_bcache_rates, d->rd_bcache_rate_congested, cache_congested);
@@ -1761,8 +1828,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
);
d->rd_bcache_dirty_size = rrddim_add(d->st_bcache_size, "dirty", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_bcache_size);
}
- else rrdset_next(d->st_bcache_size);
+ else
+ rrdset_next(d->st_bcache_size);
rrddim_set_by_pointer(d->st_bcache_size, d->rd_bcache_dirty_size, dirty_data);
rrdset_done(d->st_bcache_size);
@@ -1786,8 +1856,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
);
d->rd_bcache_available_percent = rrddim_add(d->st_bcache_usage, "avail", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_disk(d, d->st_bcache_usage);
}
- else rrdset_next(d->st_bcache_usage);
+ else
+ rrdset_next(d->st_bcache_usage);
rrddim_set_by_pointer(d->st_bcache_usage, d->rd_bcache_available_percent, cache_available_percent);
rrdset_done(d->st_bcache_usage);
@@ -1813,8 +1886,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_bcache_cache_read_races = rrddim_add(d->st_bcache_cache_read_races, "races", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_bcache_cache_io_errors = rrddim_add(d->st_bcache_cache_read_races, "errors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_bcache_cache_read_races);
}
- else rrdset_next(d->st_bcache_cache_read_races);
+ else
+ rrdset_next(d->st_bcache_cache_read_races);
rrddim_set_by_pointer(d->st_bcache_cache_read_races, d->rd_bcache_cache_read_races, cache_read_races);
rrddim_set_by_pointer(d->st_bcache_cache_read_races, d->rd_bcache_cache_io_errors, cache_io_errors);
@@ -1849,8 +1925,11 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_bcache_misses = rrddim_add(d->st_bcache, "misses", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_bcache_miss_collisions = rrddim_add(d->st_bcache, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_bcache_readaheads = rrddim_add(d->st_bcache, "readaheads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_bcache);
}
- else rrdset_next(d->st_bcache);
+ else
+ rrdset_next(d->st_bcache);
rrddim_set_by_pointer(d->st_bcache, d->rd_bcache_hits, stats_total_cache_hits);
rrddim_set_by_pointer(d->st_bcache, d->rd_bcache_misses, stats_total_cache_misses);
@@ -1884,6 +1963,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
d->rd_bcache_bypass_hits = rrddim_add(d->st_bcache_bypass, "hits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
d->rd_bcache_bypass_misses = rrddim_add(d->st_bcache_bypass, "misses", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_disk(d, d->st_bcache_bypass);
}
else rrdset_next(d->st_bcache_bypass);
diff --git a/collectors/proc.plugin/proc_interrupts.c b/collectors/proc.plugin/proc_interrupts.c
index 78883c47..46290554 100644
--- a/collectors/proc.plugin/proc_interrupts.c
+++ b/collectors/proc.plugin/proc_interrupts.c
@@ -225,6 +225,10 @@ int do_proc_interrupts(int update_every, usec_t dt) {
, update_every
, RRDSET_TYPE_STACKED
);
+
+ char core[50+1];
+ snprintfz(core, 50, "cpu%d", c);
+ rrdlabels_add(core_st[c]->state->chart_labels, "cpu", core, RRDLABEL_SRC_AUTO);
}
else rrdset_next(core_st[c]);
diff --git a/collectors/proc.plugin/proc_mdstat.c b/collectors/proc.plugin/proc_mdstat.c
index bdc298d6..c8015827 100644
--- a/collectors/proc.plugin/proc_mdstat.c
+++ b/collectors/proc.plugin/proc_mdstat.c
@@ -77,6 +77,11 @@ static inline void make_chart_obsolete(char *name, const char *id_modifier)
}
}
+static void add_labels_to_mdstat(struct raid *raid, RRDSET *st) {
+ rrdlabels_add(st->state->chart_labels, "device", raid->name, RRDLABEL_SRC_AUTO);
+ rrdlabels_add(st->state->chart_labels, "raid_level", raid->level, RRDLABEL_SRC_AUTO);
+}
+
int do_proc_mdstat(int update_every, usec_t dt)
{
(void)dt;
@@ -263,7 +268,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
word = procfile_lineword(ff, l, 3);
remove_trailing_chars(word, '%');
- unsigned long long percentage = (unsigned long long)(str2ld(word, NULL) * 100);
+ unsigned long long percentage = (unsigned long long)(str2ndd(word, NULL) * 100);
// possible operations: check, resync, recovery, reshape
// 4-th character is unique for each operation so it is checked
switch (procfile_lineword(ff, l, 1)[3]) {
@@ -287,7 +292,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
word += 7; // skip leading "finish="
if (likely(s > word))
- raid->finish_in = (unsigned long long)(str2ld(word, NULL) * 60);
+ raid->finish_in = (unsigned long long)(str2ndd(word, NULL) * 60);
word = procfile_lineword(ff, l, 6);
s = remove_trailing_chars(word, 'K'); // remove trailing "K/sec"
@@ -407,7 +412,8 @@ int do_proc_mdstat(int update_every, usec_t dt)
RRDSET_TYPE_LINE);
rrdset_isnot_obsolete(st_mdstat_health);
- } else
+ }
+ else
rrdset_next(st_mdstat_health);
if (!redundant_num) {
@@ -458,7 +464,10 @@ int do_proc_mdstat(int update_every, usec_t dt)
RRDSET_TYPE_STACKED);
rrdset_isnot_obsolete(raid->st_disks);
- } else
+
+ add_labels_to_mdstat(raid, raid->st_disks);
+ }
+ else
rrdset_next(raid->st_disks);
if (unlikely(!raid->rd_inuse && !(raid->rd_inuse = rrddim_find_active(raid->st_disks, "inuse"))))
@@ -495,7 +504,10 @@ int do_proc_mdstat(int update_every, usec_t dt)
RRDSET_TYPE_LINE);
rrdset_isnot_obsolete(raid->st_mismatch_cnt);
- } else
+
+ add_labels_to_mdstat(raid, raid->st_mismatch_cnt);
+ }
+ else
rrdset_next(raid->st_mismatch_cnt);
if (unlikely(!raid->rd_mismatch_cnt && !(raid->rd_mismatch_cnt = rrddim_find_active(raid->st_mismatch_cnt, "count"))))
@@ -529,7 +541,10 @@ int do_proc_mdstat(int update_every, usec_t dt)
RRDSET_TYPE_LINE);
rrdset_isnot_obsolete(raid->st_operation);
- } else
+
+ add_labels_to_mdstat(raid, raid->st_operation);
+ }
+ else
rrdset_next(raid->st_operation);
if(unlikely(!raid->rd_check && !(raid->rd_check = rrddim_find_active(raid->st_operation, "check"))))
@@ -569,7 +584,10 @@ int do_proc_mdstat(int update_every, usec_t dt)
update_every, RRDSET_TYPE_LINE);
rrdset_isnot_obsolete(raid->st_finish);
- } else
+
+ add_labels_to_mdstat(raid, raid->st_finish);
+ }
+ else
rrdset_next(raid->st_finish);
if(unlikely(!raid->rd_finish_in && !(raid->rd_finish_in = rrddim_find_active(raid->st_finish, "finish_in"))))
@@ -601,7 +619,10 @@ int do_proc_mdstat(int update_every, usec_t dt)
RRDSET_TYPE_LINE);
rrdset_isnot_obsolete(raid->st_speed);
- } else
+
+ add_labels_to_mdstat(raid, raid->st_speed);
+ }
+ else
rrdset_next(raid->st_speed);
if (unlikely(!raid->rd_speed && !(raid->rd_speed = rrddim_find_active(raid->st_speed, "speed"))))
@@ -635,7 +656,10 @@ int do_proc_mdstat(int update_every, usec_t dt)
RRDSET_TYPE_LINE);
rrdset_isnot_obsolete(raid->st_nonredundant);
- } else
+
+ add_labels_to_mdstat(raid, raid->st_nonredundant);
+ }
+ else
rrdset_next(raid->st_nonredundant);
if (unlikely(!raid->rd_nonredundant && !(raid->rd_nonredundant = rrddim_find_active(raid->st_nonredundant, "available"))))
diff --git a/collectors/proc.plugin/proc_net_dev.c b/collectors/proc.plugin/proc_net_dev.c
index 74076ff7..79572f44 100644
--- a/collectors/proc.plugin/proc_net_dev.c
+++ b/collectors/proc.plugin/proc_net_dev.c
@@ -7,19 +7,39 @@
#define STATE_LENGTH_MAX 32
-// As defined in https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
-const char *operstate_names[] = { "unknown", "notpresent", "down", "lowerlayerdown", "testing", "dormant", "up" };
+enum {
+ NETDEV_DUPLEX_UNKNOWN,
+ NETDEV_DUPLEX_HALF,
+ NETDEV_DUPLEX_FULL
+};
+
+enum {
+ NETDEV_OPERSTATE_UNKNOWN,
+ NETDEV_OPERSTATE_NOTPRESENT,
+ NETDEV_OPERSTATE_DOWN,
+ NETDEV_OPERSTATE_LOWERLAYERDOWN,
+ NETDEV_OPERSTATE_TESTING,
+ NETDEV_OPERSTATE_DORMANT,
+ NETDEV_OPERSTATE_UP
+};
static inline int get_operstate(char *operstate)
{
- int i;
-
- for (i = 0; i < (int) (sizeof(operstate_names) / sizeof(char *)); i++) {
- if (!strcmp(operstate, operstate_names[i])) {
- return i;
- }
- }
- return 0;
+ // As defined in https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
+ if (!strcmp(operstate, "up"))
+ return NETDEV_OPERSTATE_UP;
+ if (!strcmp(operstate, "down"))
+ return NETDEV_OPERSTATE_DOWN;
+ if (!strcmp(operstate, "notpresent"))
+ return NETDEV_OPERSTATE_NOTPRESENT;
+ if (!strcmp(operstate, "lowerlayerdown"))
+ return NETDEV_OPERSTATE_LOWERLAYERDOWN;
+ if (!strcmp(operstate, "testing"))
+ return NETDEV_OPERSTATE_TESTING;
+ if (!strcmp(operstate, "dormant"))
+ return NETDEV_OPERSTATE_DORMANT;
+
+ return NETDEV_OPERSTATE_UNKNOWN;
}
// ----------------------------------------------------------------------------
@@ -90,7 +110,7 @@ static struct netdev {
const char *chart_family;
- struct label *chart_labels;
+ DICTIONARY *chart_labels;
int flipped;
unsigned long priority;
@@ -153,9 +173,18 @@ static struct netdev {
RRDDIM *rd_tcompressed;
RRDDIM *rd_speed;
- RRDDIM *rd_duplex;
- RRDDIM *rd_operstate;
- RRDDIM *rd_carrier;
+ RRDDIM *rd_duplex_full;
+ RRDDIM *rd_duplex_half;
+ RRDDIM *rd_duplex_unknown;
+ RRDDIM *rd_operstate_unknown;
+ RRDDIM *rd_operstate_notpresent;
+ RRDDIM *rd_operstate_down;
+ RRDDIM *rd_operstate_lowerlayerdown;
+ RRDDIM *rd_operstate_testing;
+ RRDDIM *rd_operstate_dormant;
+ RRDDIM *rd_operstate_up;
+ RRDDIM *rd_carrier_up;
+ RRDDIM *rd_carrier_down;
RRDDIM *rd_mtu;
char *filename_speed;
@@ -219,11 +248,21 @@ static void netdev_charts_release(struct netdev *d) {
d->rd_tcompressed = NULL;
d->rd_speed = NULL;
- d->rd_duplex = NULL;
- d->rd_operstate = NULL;
- d->rd_carrier = NULL;
+ d->rd_duplex_full = NULL;
+ d->rd_duplex_half = NULL;
+ d->rd_duplex_unknown = NULL;
+ d->rd_carrier_up = NULL;
+ d->rd_carrier_down = NULL;
d->rd_mtu = NULL;
+ d->rd_operstate_unknown = NULL;
+ d->rd_operstate_notpresent = NULL;
+ d->rd_operstate_down = NULL;
+ d->rd_operstate_lowerlayerdown = NULL;
+ d->rd_operstate_testing = NULL;
+ d->rd_operstate_dormant = NULL;
+ d->rd_operstate_up = NULL;
+
d->chart_var_speed = NULL;
}
@@ -273,7 +312,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);
@@ -294,8 +333,9 @@ static struct netdev_rename {
const char *container_device;
const char *container_name;
+ const char *ctx_prefix;
- struct label *chart_labels;
+ DICTIONARY *chart_labels;
int processed;
@@ -317,7 +357,11 @@ 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)
+ const char *host_device,
+ const char *container_device,
+ const char *container_name,
+ DICTIONARY *labels,
+ const char *ctx_prefix)
{
netdata_mutex_lock(&netdev_rename_mutex);
@@ -328,7 +372,9 @@ 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->ctx_prefix = strdupz(ctx_prefix);
+ 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 +390,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 +423,8 @@ 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);
+ freez((void *) r->ctx_prefix);
+ rrdlabels_destroy(r->chart_labels);
freez((void *) r);
break;
}
@@ -433,23 +480,35 @@ static inline void netdev_rename_cgroup(struct netdev *d, struct netdev_rename *
snprintfz(buffer, RRD_ID_LENGTH_MAX, "net_mtu_%s", r->container_device);
d->chart_id_net_mtu = strdupz(buffer);
- d->chart_ctx_net_bytes = strdupz("cgroup.net_net");
- d->chart_ctx_net_compressed = strdupz("cgroup.net_compressed");
- d->chart_ctx_net_drops = strdupz("cgroup.net_drops");
- d->chart_ctx_net_errors = strdupz("cgroup.net_errors");
- d->chart_ctx_net_events = strdupz("cgroup.net_events");
- d->chart_ctx_net_fifo = strdupz("cgroup.net_fifo");
- d->chart_ctx_net_packets = strdupz("cgroup.net_packets");
- d->chart_ctx_net_speed = strdupz("cgroup.net_speed");
- d->chart_ctx_net_duplex = strdupz("cgroup.net_duplex");
- d->chart_ctx_net_operstate = strdupz("cgroup.net_operstate");
- d->chart_ctx_net_carrier = strdupz("cgroup.net_carrier");
- d->chart_ctx_net_mtu = strdupz("cgroup.net_mtu");
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_net", r->ctx_prefix);
+ d->chart_ctx_net_bytes = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_compressed", r->ctx_prefix);
+ d->chart_ctx_net_compressed = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_drops", r->ctx_prefix);
+ d->chart_ctx_net_drops = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_errors", r->ctx_prefix);
+ d->chart_ctx_net_errors = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_events", r->ctx_prefix);
+ d->chart_ctx_net_events = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_fifo", r->ctx_prefix);
+ d->chart_ctx_net_fifo = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_packets", r->ctx_prefix);
+ d->chart_ctx_net_packets = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_speed", r->ctx_prefix);
+ d->chart_ctx_net_speed = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_duplex", r->ctx_prefix);
+ d->chart_ctx_net_duplex = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_operstate", r->ctx_prefix);
+ d->chart_ctx_net_operstate = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_carrier", r->ctx_prefix);
+ d->chart_ctx_net_carrier = strdupz(buffer);
+ snprintfz(buffer, RRD_ID_LENGTH_MAX, "%scgroup.net_mtu", r->ctx_prefix);
+ d->chart_ctx_net_mtu = strdupz(buffer);
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_copy(d->chart_labels, r->chart_labels);
d->priority = NETDATA_CHART_PRIO_CGROUP_NET_IFACE;
d->flipped = 1;
@@ -542,6 +601,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");
@@ -702,11 +762,15 @@ int do_proc_net_dev(int update_every, usec_t dt) {
char buffer[FILENAME_MAX + 1];
snprintfz(buffer, FILENAME_MAX, path_to_sys_devices_virtual_net, d->name);
- if(likely(access(buffer, R_OK) == 0)) {
+ if (likely(access(buffer, R_OK) == 0)) {
d->virtual = 1;
+ rrdlabels_add(d->chart_labels, "interface_type", "virtual", RRDLABEL_SRC_AUTO|RRDLABEL_FLAG_PERMANENT);
}
- else
+ else {
d->virtual = 0;
+ rrdlabels_add(d->chart_labels, "interface_type", "real", RRDLABEL_SRC_AUTO|RRDLABEL_FLAG_PERMANENT);
+ }
+ rrdlabels_add(d->chart_labels, "device", name, RRDLABEL_SRC_AUTO|RRDLABEL_FLAG_PERMANENT);
if(likely(!d->virtual)) {
// set the filename to get the interface speed
@@ -813,11 +877,11 @@ int do_proc_net_dev(int update_every, usec_t dt) {
} else {
// values can be unknown, half or full -- just check the first letter for speed
if (buffer[0] == 'f')
- d->duplex = 2;
+ d->duplex = NETDEV_DUPLEX_FULL;
else if (buffer[0] == 'h')
- d->duplex = 1;
+ d->duplex = NETDEV_DUPLEX_HALF;
else
- d->duplex = 0;
+ d->duplex = NETDEV_DUPLEX_UNKNOWN;
}
} else {
d->duplex = 0;
@@ -881,7 +945,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);
@@ -926,7 +990,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
d->filename_speed = NULL;
}
else {
- rrdsetvar_custom_chart_variable_set(d->chart_var_speed, (calculated_number) d->speed * KILOBITS_IN_A_MEGABIT);
+ rrdsetvar_custom_chart_variable_set(d->chart_var_speed, (NETDATA_DOUBLE) d->speed * KILOBITS_IN_A_MEGABIT);
if(d->do_speed != CONFIG_BOOLEAN_NO) {
if(unlikely(!d->st_speed)) {
@@ -947,7 +1011,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,13 +1046,17 @@ 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);
+ d->rd_duplex_full = rrddim_add(d->st_duplex, "full", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_duplex_half = rrddim_add(d->st_duplex, "half", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_duplex_unknown = rrddim_add(d->st_duplex, "unknown", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(d->st_duplex);
- rrddim_set_by_pointer(d->st_duplex, d->rd_duplex, (collected_number)d->duplex);
+ rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_full, (collected_number)(d->duplex == NETDEV_DUPLEX_FULL));
+ rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_half, (collected_number)(d->duplex == NETDEV_DUPLEX_HALF));
+ rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_unknown, (collected_number)(d->duplex == NETDEV_DUPLEX_UNKNOWN));
rrdset_done(d->st_duplex);
}
@@ -1013,13 +1081,25 @@ 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);
+ d->rd_operstate_up = rrddim_add(d->st_operstate, "up", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_operstate_down = rrddim_add(d->st_operstate, "down", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_operstate_notpresent = rrddim_add(d->st_operstate, "notpresent", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_operstate_lowerlayerdown = rrddim_add(d->st_operstate, "lowerlayerdown", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_operstate_testing = rrddim_add(d->st_operstate, "testing", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_operstate_dormant = rrddim_add(d->st_operstate, "dormant", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_operstate_unknown = rrddim_add(d->st_operstate, "unknown", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(d->st_operstate);
- rrddim_set_by_pointer(d->st_operstate, d->rd_operstate, (collected_number)d->operstate);
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_up, (collected_number)(d->operstate == NETDEV_OPERSTATE_UP));
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_down, (collected_number)(d->operstate == NETDEV_OPERSTATE_DOWN));
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_notpresent, (collected_number)(d->operstate == NETDEV_OPERSTATE_NOTPRESENT));
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_lowerlayerdown, (collected_number)(d->operstate == NETDEV_OPERSTATE_LOWERLAYERDOWN));
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_testing, (collected_number)(d->operstate == NETDEV_OPERSTATE_TESTING));
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_dormant, (collected_number)(d->operstate == NETDEV_OPERSTATE_DORMANT));
+ rrddim_set_by_pointer(d->st_operstate, d->rd_operstate_unknown, (collected_number)(d->operstate == NETDEV_OPERSTATE_UNKNOWN));
rrdset_done(d->st_operstate);
}
@@ -1044,13 +1124,15 @@ 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);
+ d->rd_carrier_up = rrddim_add(d->st_carrier, "up", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ d->rd_carrier_down = rrddim_add(d->st_carrier, "down", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
else rrdset_next(d->st_carrier);
- rrddim_set_by_pointer(d->st_carrier, d->rd_carrier, (collected_number)d->carrier);
+ rrddim_set_by_pointer(d->st_carrier, d->rd_carrier_up, (collected_number)(d->carrier == 1));
+ rrddim_set_by_pointer(d->st_carrier, d->rd_carrier_down, (collected_number)(d->carrier != 1));
rrdset_done(d->st_carrier);
}
@@ -1075,7 +1157,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 +1193,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 +1241,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 +1287,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 +1333,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 +1379,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 +1425,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);
diff --git a/collectors/proc.plugin/proc_net_wireless.c b/collectors/proc.plugin/proc_net_wireless.c
index cb2443b1..c6ee4ff7 100644
--- a/collectors/proc.plugin/proc_net_wireless.c
+++ b/collectors/proc.plugin/proc_net_wireless.c
@@ -24,9 +24,9 @@ static struct netwireless {
kernel_uint_t status;
// Quality
- calculated_number link;
- calculated_number level;
- calculated_number noise;
+ NETDATA_DOUBLE link;
+ NETDATA_DOUBLE level;
+ NETDATA_DOUBLE noise;
// Discarded packets
kernel_uint_t nwid;
@@ -198,6 +198,10 @@ static void configure_device(int do_status, int do_quality, int do_discarded_pac
wireless_dev->chart_id_net_missed_beacon = strdupz(buffer);
}
+static void add_labels_to_wireless(struct netwireless *w, RRDSET *st) {
+ rrdlabels_add(st->state->chart_labels, "device", w->name, RRDLABEL_SRC_AUTO);
+}
+
int do_proc_net_wireless(int update_every, usec_t dt)
{
UNUSED(dt);
@@ -209,21 +213,11 @@ int do_proc_net_wireless(int update_every, usec_t dt)
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/wireless");
- proc_net_wireless_filename = config_get(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,"filename to monitor",
- filename);
-
- do_status = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,
- "status for all interfaces", CONFIG_BOOLEAN_AUTO);
-
- do_quality = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,
- "quality for all interfaces", CONFIG_BOOLEAN_AUTO);
-
- do_discarded_packets = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,
- "discarded packets for all interfaces",
- CONFIG_BOOLEAN_AUTO);
-
- do_beacon = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,
- "missed beacon for all interface", CONFIG_BOOLEAN_AUTO);
+ proc_net_wireless_filename = config_get(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,"filename to monitor", filename);
+ do_status = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "status for all interfaces", CONFIG_BOOLEAN_AUTO);
+ do_quality = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "quality for all interfaces", CONFIG_BOOLEAN_AUTO);
+ do_discarded_packets = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "discarded packets for all interfaces", CONFIG_BOOLEAN_AUTO);
+ do_beacon = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "missed beacon for all interface", CONFIG_BOOLEAN_AUTO);
}
if (unlikely(!ff)) {
@@ -255,25 +249,28 @@ int do_proc_net_wireless(int update_every, usec_t dt)
wireless_dev->status = str2kernel_uint_t(procfile_lineword(ff, l, 1));
if (unlikely(!wireless_dev->st_status)) {
- wireless_dev->st_status = rrdset_create_localhost("wireless",
- wireless_dev->chart_id_net_status,
- NULL,
- wireless_dev->name,
- "wireless.status",
- "Internal status reported by interface.",
- "status",
- PLUGIN_PROC_NAME,
- PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
- NETDATA_CHART_PRIO_WIRELESS_IFACE,
- update_every,
- RRDSET_TYPE_LINE);
+ wireless_dev->st_status = rrdset_create_localhost(
+ "wireless",
+ wireless_dev->chart_id_net_status,
+ NULL,
+ wireless_dev->name,
+ "wireless.status",
+ "Internal status reported by interface.",
+ "status",
+ PLUGIN_PROC_NAME,
+ PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
+ NETDATA_CHART_PRIO_WIRELESS_IFACE,
+ update_every,
+ RRDSET_TYPE_LINE);
+
rrdset_flag_set(wireless_dev->st_status, RRDSET_FLAG_DETAIL);
- wireless_dev->rd_status = rrddim_add(wireless_dev->st_status, "status", NULL, 1,
- 1, RRD_ALGORITHM_ABSOLUTE);
- } else {
- rrdset_next(wireless_dev->st_status);
+ wireless_dev->rd_status = rrddim_add(wireless_dev->st_status, "status", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_wireless(wireless_dev, wireless_dev->st_status);
}
+ else
+ rrdset_next(wireless_dev->st_status);
rrddim_set_by_pointer(wireless_dev->st_status, wireless_dev->rd_status,
(collected_number)wireless_dev->status);
@@ -281,83 +278,86 @@ int do_proc_net_wireless(int update_every, usec_t dt)
}
if (likely(do_quality != CONFIG_BOOLEAN_NO)) {
- wireless_dev->link = str2ld(procfile_lineword(ff, l, 2), NULL);
- wireless_dev->level = str2ld(procfile_lineword(ff, l, 3), NULL);
- wireless_dev->noise = str2ld(procfile_lineword(ff, l, 4), NULL);
+ wireless_dev->link = str2ndd(procfile_lineword(ff, l, 2), NULL);
+ wireless_dev->level = str2ndd(procfile_lineword(ff, l, 3), NULL);
+ wireless_dev->noise = str2ndd(procfile_lineword(ff, l, 4), NULL);
if (unlikely(!wireless_dev->st_link)) {
- wireless_dev->st_link = rrdset_create_localhost("wireless",
- wireless_dev->chart_id_net_link,
- NULL,
- wireless_dev->name,
- "wireless.link_quality",
- "Overall quality of the link. This is an aggregate value, and depends on the driver and hardware.",
- "value",
- PLUGIN_PROC_NAME,
- PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
- NETDATA_CHART_PRIO_WIRELESS_IFACE + 1,
- update_every,
- RRDSET_TYPE_LINE);
+ wireless_dev->st_link = rrdset_create_localhost(
+ "wireless",
+ wireless_dev->chart_id_net_link,
+ NULL,
+ wireless_dev->name,
+ "wireless.link_quality",
+ "Overall quality of the link. This is an aggregate value, and depends on the driver and hardware.",
+ "value",
+ PLUGIN_PROC_NAME,
+ PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
+ NETDATA_CHART_PRIO_WIRELESS_IFACE + 1,
+ update_every,
+ RRDSET_TYPE_LINE);
rrdset_flag_set(wireless_dev->st_link, RRDSET_FLAG_DETAIL);
- wireless_dev->rd_link = rrddim_add(wireless_dev->st_link, "link_quality", NULL, 1, 1,
- RRD_ALGORITHM_ABSOLUTE);
- } else {
- rrdset_next(wireless_dev->st_link);
+ wireless_dev->rd_link = rrddim_add(wireless_dev->st_link, "link_quality", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_wireless(wireless_dev, wireless_dev->st_link);
}
+ else
+ rrdset_next(wireless_dev->st_link);
if (unlikely(!wireless_dev->st_level)) {
- wireless_dev->st_level = rrdset_create_localhost("wireless",
- wireless_dev->chart_id_net_level,
- NULL,
- wireless_dev->name,
- "wireless.signal_level",
- "The signal level is the wireless signal power level received by the wireless client. The closer the value is to 0, the stronger the signal.",
- "dBm",
- PLUGIN_PROC_NAME,
- PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
- NETDATA_CHART_PRIO_WIRELESS_IFACE + 2,
- update_every,
- RRDSET_TYPE_LINE);
+ wireless_dev->st_level = rrdset_create_localhost(
+ "wireless",
+ wireless_dev->chart_id_net_level,
+ NULL,
+ wireless_dev->name,
+ "wireless.signal_level",
+ "The signal level is the wireless signal power level received by the wireless client. The closer the value is to 0, the stronger the signal.",
+ "dBm",
+ PLUGIN_PROC_NAME,
+ PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
+ NETDATA_CHART_PRIO_WIRELESS_IFACE + 2,
+ update_every,
+ RRDSET_TYPE_LINE);
rrdset_flag_set(wireless_dev->st_level, RRDSET_FLAG_DETAIL);
- wireless_dev->rd_level = rrddim_add(wireless_dev->st_level, "signal_level", NULL, 1, 1,
- RRD_ALGORITHM_ABSOLUTE);
- } else {
- rrdset_next(wireless_dev->st_level);
+ wireless_dev->rd_level = rrddim_add(wireless_dev->st_level, "signal_level", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_wireless(wireless_dev, wireless_dev->st_level);
}
+ else
+ rrdset_next(wireless_dev->st_level);
if (unlikely(!wireless_dev->st_noise)) {
- wireless_dev->st_noise = rrdset_create_localhost("wireless",
- wireless_dev->chart_id_net_noise,
- NULL,
- wireless_dev->name,
- "wireless.noise_level",
- "The noise level indicates the amount of background noise in your environment. The closer the value to 0, the greater the noise level.",
- "dBm",
- PLUGIN_PROC_NAME,
- PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
- NETDATA_CHART_PRIO_WIRELESS_IFACE + 3,
- update_every,
- RRDSET_TYPE_LINE);
+ wireless_dev->st_noise = rrdset_create_localhost(
+ "wireless",
+ wireless_dev->chart_id_net_noise,
+ NULL,
+ wireless_dev->name,
+ "wireless.noise_level",
+ "The noise level indicates the amount of background noise in your environment. The closer the value to 0, the greater the noise level.",
+ "dBm",
+ PLUGIN_PROC_NAME,
+ PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
+ NETDATA_CHART_PRIO_WIRELESS_IFACE + 3,
+ update_every,
+ RRDSET_TYPE_LINE);
rrdset_flag_set(wireless_dev->st_noise, RRDSET_FLAG_DETAIL);
- wireless_dev->rd_noise = rrddim_add(wireless_dev->st_noise, "noise_level", NULL, 1, 1,
- RRD_ALGORITHM_ABSOLUTE);
- } else {
- rrdset_next(wireless_dev->st_noise);
+ wireless_dev->rd_noise = rrddim_add(wireless_dev->st_noise, "noise_level", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_wireless(wireless_dev, wireless_dev->st_noise);
}
+ else
+ rrdset_next(wireless_dev->st_noise);
- rrddim_set_by_pointer(wireless_dev->st_link, wireless_dev->rd_link,
- (collected_number)wireless_dev->link);
+ rrddim_set_by_pointer(wireless_dev->st_link, wireless_dev->rd_link, (collected_number)wireless_dev->link);
rrdset_done(wireless_dev->st_link);
- rrddim_set_by_pointer(wireless_dev->st_level, wireless_dev->rd_level,
- (collected_number)wireless_dev->level);
+ rrddim_set_by_pointer(wireless_dev->st_level, wireless_dev->rd_level, (collected_number)wireless_dev->level);
rrdset_done(wireless_dev->st_level);
- rrddim_set_by_pointer(wireless_dev->st_noise, wireless_dev->rd_noise,
- (collected_number)wireless_dev->noise);
+ rrddim_set_by_pointer(wireless_dev->st_noise, wireless_dev->rd_noise, (collected_number)wireless_dev->noise);
rrdset_done(wireless_dev->st_noise);
}
@@ -369,49 +369,38 @@ int do_proc_net_wireless(int update_every, usec_t dt)
wireless_dev->misc = str2kernel_uint_t(procfile_lineword(ff, l, 9));
if (unlikely(!wireless_dev->st_discarded_packets)) {
- wireless_dev->st_discarded_packets = rrdset_create_localhost("wireless",
- wireless_dev->chart_id_net_discarded_packets,
- NULL,
- wireless_dev->name,
- "wireless.discarded_packets",
- "Packet discarded in the wireless adapter due to \"wireless\" specific problems.",
- "packets/s",
- PLUGIN_PROC_NAME,
- PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
- NETDATA_CHART_PRIO_WIRELESS_IFACE + 4,
- update_every,
- RRDSET_TYPE_LINE);
+ wireless_dev->st_discarded_packets = rrdset_create_localhost(
+ "wireless",
+ wireless_dev->chart_id_net_discarded_packets,
+ NULL,
+ wireless_dev->name,
+ "wireless.discarded_packets",
+ "Packet discarded in the wireless adapter due to \"wireless\" specific problems.",
+ "packets/s",
+ PLUGIN_PROC_NAME,
+ PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
+ NETDATA_CHART_PRIO_WIRELESS_IFACE + 4,
+ update_every,
+ RRDSET_TYPE_LINE);
rrdset_flag_set(wireless_dev->st_discarded_packets, RRDSET_FLAG_DETAIL);
- wireless_dev->rd_nwid = rrddim_add(wireless_dev->st_discarded_packets, "nwid", NULL, 1,
- 1, RRD_ALGORITHM_INCREMENTAL);
- wireless_dev->rd_crypt = rrddim_add(wireless_dev->st_discarded_packets, "crypt", NULL, 1,
- 1, RRD_ALGORITHM_INCREMENTAL);
- wireless_dev->rd_frag = rrddim_add(wireless_dev->st_discarded_packets, "frag", NULL, 1,
- 1, RRD_ALGORITHM_INCREMENTAL);
- wireless_dev->rd_retry = rrddim_add(wireless_dev->st_discarded_packets, "retry", NULL, 1,
- 1, RRD_ALGORITHM_INCREMENTAL);
- wireless_dev->rd_misc = rrddim_add(wireless_dev->st_discarded_packets, "misc", NULL, 1,
- 1, RRD_ALGORITHM_INCREMENTAL);
- } else {
- rrdset_next(wireless_dev->st_discarded_packets);
- }
-
- rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_nwid,
- (collected_number)wireless_dev->nwid);
-
- rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_crypt,
- (collected_number)wireless_dev->crypt);
+ wireless_dev->rd_nwid = rrddim_add(wireless_dev->st_discarded_packets, "nwid", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+ wireless_dev->rd_crypt = rrddim_add(wireless_dev->st_discarded_packets, "crypt", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+ wireless_dev->rd_frag = rrddim_add(wireless_dev->st_discarded_packets, "frag", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+ wireless_dev->rd_retry = rrddim_add(wireless_dev->st_discarded_packets, "retry", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+ wireless_dev->rd_misc = rrddim_add(wireless_dev->st_discarded_packets, "misc", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_frag,
- (collected_number)wireless_dev->frag);
-
- rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_retry,
- (collected_number)wireless_dev->retry);
+ add_labels_to_wireless(wireless_dev, wireless_dev->st_discarded_packets);
+ }
+ else
+ rrdset_next(wireless_dev->st_discarded_packets);
- rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_misc,
- (collected_number)wireless_dev->misc);
+ rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_nwid, (collected_number)wireless_dev->nwid);
+ rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_crypt, (collected_number)wireless_dev->crypt);
+ rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_frag, (collected_number)wireless_dev->frag);
+ rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_retry, (collected_number)wireless_dev->retry);
+ rrddim_set_by_pointer(wireless_dev->st_discarded_packets, wireless_dev->rd_misc, (collected_number)wireless_dev->misc);
rrdset_done(wireless_dev->st_discarded_packets);
}
@@ -420,28 +409,31 @@ int do_proc_net_wireless(int update_every, usec_t dt)
wireless_dev->missed_beacon = str2kernel_uint_t(procfile_lineword(ff, l, 10));
if (unlikely(!wireless_dev->st_missed_beacon)) {
- wireless_dev->st_missed_beacon = rrdset_create_localhost("wireless",
- wireless_dev->chart_id_net_missed_beacon,
- NULL,
- wireless_dev->name,
- "wireless.missed_beacons",
- "Number of missed beacons.",
- "frames/s",
- PLUGIN_PROC_NAME,
- PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
- NETDATA_CHART_PRIO_WIRELESS_IFACE + 5,
- update_every,
- RRDSET_TYPE_LINE);
+ wireless_dev->st_missed_beacon = rrdset_create_localhost(
+ "wireless",
+ wireless_dev->chart_id_net_missed_beacon,
+ NULL,
+ wireless_dev->name,
+ "wireless.missed_beacons",
+ "Number of missed beacons.",
+ "frames/s",
+ PLUGIN_PROC_NAME,
+ PLUGIN_PROC_MODULE_NETWIRELESS_NAME,
+ NETDATA_CHART_PRIO_WIRELESS_IFACE + 5,
+ update_every,
+ RRDSET_TYPE_LINE);
+
rrdset_flag_set(wireless_dev->st_missed_beacon, RRDSET_FLAG_DETAIL);
- wireless_dev->rd_missed_beacon = rrddim_add(wireless_dev->st_missed_beacon, "missed_beacons",
- NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- } else {
- rrdset_next(wireless_dev->st_missed_beacon);
+ wireless_dev->rd_missed_beacon = rrddim_add(wireless_dev->st_missed_beacon, "missed_beacons", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ add_labels_to_wireless(wireless_dev, wireless_dev->st_missed_beacon);
}
+ else
+ rrdset_next(wireless_dev->st_missed_beacon);
+
+ rrddim_set_by_pointer(wireless_dev->st_missed_beacon, wireless_dev->rd_missed_beacon, (collected_number)wireless_dev->missed_beacon);
- rrddim_set_by_pointer(wireless_dev->st_missed_beacon, wireless_dev->rd_missed_beacon,
- (collected_number)wireless_dev->missed_beacon);
rrdset_done(wireless_dev->st_missed_beacon);
}
diff --git a/collectors/proc.plugin/proc_pagetypeinfo.c b/collectors/proc.plugin/proc_pagetypeinfo.c
index e1026cf5..017edc49 100644
--- a/collectors/proc.plugin/proc_pagetypeinfo.c
+++ b/collectors/proc.plugin/proc_pagetypeinfo.c
@@ -242,15 +242,14 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) {
// "Node" + NUMA-NodeID + ZoneName + TypeName
char setname[4+1+MAX_ZONETYPE_NAME+1+MAX_PAGETYPE_NAME +1];
- snprintfz(setname, MAX_ZONETYPE_NAME + MAX_PAGETYPE_NAME, "Node %d %s %s",
- pgl->node, pgl->zone, pgl->type);
+ snprintfz(setname, MAX_ZONETYPE_NAME + MAX_PAGETYPE_NAME, "Node %d %s %s", pgl->node, pgl->zone, pgl->type);
st_nodezonetype[p] = rrdset_create_localhost(
"mem"
, setid
, NULL
, "pagetype"
- , NULL
+ , "mem.pagetype"
, setname
, "B"
, PLUGIN_PROC_NAME
@@ -259,6 +258,13 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) {
, update_every
, RRDSET_TYPE_STACKED
);
+
+ char node[50+1];
+ snprintfz(node, 50, "node%d", pgl->node);
+ rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_id", node, RRDLABEL_SRC_AUTO);
+ rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_zone", pgl->zone, RRDLABEL_SRC_AUTO);
+ rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_type", pgl->type, RRDLABEL_SRC_AUTO);
+
for (o = 0; o < pageorders_cnt; o++) {
char dimid[3+1];
snprintfz(dimid, 3, "%lu", o);
diff --git a/collectors/proc.plugin/proc_self_mountinfo.c b/collectors/proc.plugin/proc_self_mountinfo.c
index ca00f8a8..4456d597 100644
--- a/collectors/proc.plugin/proc_self_mountinfo.c
+++ b/collectors/proc.plugin/proc_self_mountinfo.c
@@ -182,6 +182,33 @@ static inline int is_read_only(const char *s) {
return 0;
}
+// for the full list of protected mount points look at
+// https://github.com/systemd/systemd/blob/1eb3ef78b4df28a9e9f464714208f2682f957e36/src/core/namespace.c#L142-L149
+// https://github.com/systemd/systemd/blob/1eb3ef78b4df28a9e9f464714208f2682f957e36/src/core/namespace.c#L180-L194
+static const char *systemd_protected_mount_points[] = {
+ "/home",
+ "/root",
+ "/usr",
+ "/boot",
+ "/efi",
+ "/etc",
+ "/run/user",
+ "/lib",
+ "/lib64",
+ "/bin",
+ "/sbin",
+ NULL
+};
+
+static inline int mount_point_is_protected(char *mount_point)
+{
+ for (size_t i = 0; systemd_protected_mount_points[i] != NULL; i++)
+ if (!strcmp(mount_point, systemd_protected_mount_points[i]))
+ return 1;
+
+ return 0;
+}
+
// read the whole mountinfo into a linked list
struct mountinfo *mountinfo_read(int do_statvfs) {
char filename[FILENAME_MAX + 1];
@@ -199,11 +226,21 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
struct mountinfo *root = NULL, *last = NULL, *mi = NULL;
+ // create a dictionary to track uniqueness
+ DICTIONARY *dict = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED|DICTIONARY_FLAG_DONT_OVERWRITE_VALUE|DICTIONARY_FLAG_NAME_LINK_DONT_CLONE);
+
unsigned long l, lines = procfile_lines(ff);
for(l = 0; l < lines ;l++) {
if(unlikely(procfile_linewords(ff, l) < 5))
continue;
+ // make sure we don't add the same item twice
+ char *v = (char *)dictionary_set(dict, procfile_lineword(ff, l, 4), "N", 2);
+ if(v) {
+ if(*v == 'O') continue;
+ *v = 'O';
+ }
+
mi = mallocz(sizeof(struct mountinfo));
unsigned long w = 0;
@@ -242,6 +279,9 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
if(unlikely(is_read_only(mi->mount_options)))
mi->flags |= MOUNTINFO_READONLY;
+ if(unlikely(mount_point_is_protected(mi->mount_point)))
+ mi->flags |= MOUNTINFO_IS_IN_SYSD_PROTECTED_LIST;
+
// count the optional fields
/*
unsigned long wo = w;
@@ -411,6 +451,7 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
}
*/
+ dictionary_destroy(dict);
procfile_close(ff);
return root;
}
diff --git a/collectors/proc.plugin/proc_self_mountinfo.h b/collectors/proc.plugin/proc_self_mountinfo.h
index 92918a73..b915550a 100644
--- a/collectors/proc.plugin/proc_self_mountinfo.h
+++ b/collectors/proc.plugin/proc_self_mountinfo.h
@@ -10,6 +10,7 @@
#define MOUNTINFO_NO_STAT 0x00000010
#define MOUNTINFO_NO_SIZE 0x00000020
#define MOUNTINFO_READONLY 0x00000040
+#define MOUNTINFO_IS_IN_SYSD_PROTECTED_LIST 0x00000080
struct mountinfo {
long id; // mount ID: unique identifier of the mount (may be reused after umount(2)).
diff --git a/collectors/proc.plugin/proc_softirqs.c b/collectors/proc.plugin/proc_softirqs.c
index bb14c159..7eff28c9 100644
--- a/collectors/proc.plugin/proc_softirqs.c
+++ b/collectors/proc.plugin/proc_softirqs.c
@@ -217,6 +217,10 @@ int do_proc_softirqs(int update_every, usec_t dt) {
, update_every
, RRDSET_TYPE_STACKED
);
+
+ char core[50+1];
+ snprintfz(core, 50, "cpu%d", c);
+ rrdlabels_add(core_st[c]->state->chart_labels, "cpu", core, RRDLABEL_SRC_AUTO);
}
else
rrdset_next(core_st[c]);
diff --git a/collectors/proc.plugin/proc_stat.c b/collectors/proc.plugin/proc_stat.c
index c889f073..6faba55a 100644
--- a/collectors/proc.plugin/proc_stat.c
+++ b/collectors/proc.plugin/proc_stat.c
@@ -1039,6 +1039,10 @@ int do_proc_stat(int update_every, usec_t dt) {
, RRDSET_TYPE_STACKED
);
+ char corebuf[50+1];
+ snprintfz(corebuf, 50, "cpu%zu", core);
+ rrdlabels_add(cpuidle_charts[core].st->state->chart_labels, "cpu", corebuf, RRDLABEL_SRC_AUTO);
+
char cpuidle_dim_id[RRD_ID_LENGTH_MAX + 1];
cpuidle_charts[core].active_time_rd = rrddim_add(cpuidle_charts[core].st, "active", "C0 (active)", 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
for(state = 0; state < cpuidle_charts[core].cpuidle_state_len; state++) {
diff --git a/collectors/proc.plugin/sys_block_zram.c b/collectors/proc.plugin/sys_block_zram.c
index 3a39b3b6..ddd1e7ae 100644
--- a/collectors/proc.plugin/sys_block_zram.c
+++ b/collectors/proc.plugin/sys_block_zram.c
@@ -75,6 +75,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
, RRDSET_TYPE_AREA);
d->rd_compr_data_size = rrddim_add(d->st_usage, "compressed", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
d->rd_metadata_size = rrddim_add(d->st_usage, "metadata", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+ rrdlabels_add(d->st_usage->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO);
snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_savings.%s", name);
d->st_savings = rrdset_create_localhost(
@@ -92,6 +93,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
, RRDSET_TYPE_AREA);
d->rd_savings_size = rrddim_add(d->st_savings, "savings", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
d->rd_original_size = rrddim_add(d->st_savings, "original", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+ rrdlabels_add(d->st_savings->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO);
snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_ratio.%s", name);
d->st_comp_ratio = rrdset_create_localhost(
@@ -108,6 +110,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
, update_every
, RRDSET_TYPE_LINE);
d->rd_comp_ratio = rrddim_add(d->st_comp_ratio, "ratio", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE);
+ rrdlabels_add(d->st_comp_ratio->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO);
snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_efficiency.%s", name);
d->st_alloc_efficiency = rrdset_create_localhost(
@@ -124,6 +127,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
, update_every
, RRDSET_TYPE_LINE);
d->rd_alloc_efficiency = rrddim_add(d->st_alloc_efficiency, "percent", NULL, 1, 10000, RRD_ALGORITHM_ABSOLUTE);
+ rrdlabels_add(d->st_alloc_efficiency->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO);
}
static int init_devices(DICTIONARY *devices, unsigned int zram_id, int update_every) {
diff --git a/collectors/proc.plugin/sys_class_power_supply.c b/collectors/proc.plugin/sys_class_power_supply.c
index c558a384..a80d46e9 100644
--- a/collectors/proc.plugin/sys_class_power_supply.c
+++ b/collectors/proc.plugin/sys_class_power_supply.c
@@ -112,6 +112,10 @@ void power_supply_free(struct power_supply *ps) {
}
}
+static void add_labels_to_power_supply(struct power_supply *ps, RRDSET *st) {
+ rrdlabels_add(st->state->chart_labels, "device", ps->name, RRDLABEL_SRC_AUTO);
+}
+
int do_sys_class_power_supply(int update_every, usec_t dt) {
(void)dt;
static int do_capacity = -1, do_property[3] = {-1};
@@ -358,6 +362,8 @@ int do_sys_class_power_supply(int update_every, usec_t dt) {
, update_every
, RRDSET_TYPE_LINE
);
+
+ add_labels_to_power_supply(ps, ps->capacity->st);
}
else
rrdset_next(ps->capacity->st);
@@ -389,6 +395,8 @@ int do_sys_class_power_supply(int update_every, usec_t dt) {
, update_every
, RRDSET_TYPE_LINE
);
+
+ add_labels_to_power_supply(ps, pr->st);
}
else
rrdset_next(pr->st);
diff --git a/collectors/proc.plugin/sys_devices_system_edac_mc.c b/collectors/proc.plugin/sys_devices_system_edac_mc.c
index b1114837..29015790 100644
--- a/collectors/proc.plugin/sys_devices_system_edac_mc.c
+++ b/collectors/proc.plugin/sys_devices_system_edac_mc.c
@@ -74,7 +74,7 @@ int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt) {
}
static int do_ce = -1, do_ue = -1;
- calculated_number ce_sum = 0, ue_sum = 0;
+ NETDATA_DOUBLE ce_sum = 0, ue_sum = 0;
struct mc *m;
if(unlikely(do_ce == -1)) {
diff --git a/collectors/proc.plugin/sys_devices_system_node.c b/collectors/proc.plugin/sys_devices_system_node.c
index ff408ed8..fd339430 100644
--- a/collectors/proc.plugin/sys_devices_system_node.c
+++ b/collectors/proc.plugin/sys_devices_system_node.c
@@ -115,6 +115,8 @@ int do_proc_sys_devices_system_node(int update_every, usec_t dt) {
, RRDSET_TYPE_LINE
);
+ rrdlabels_add(m->numastat_st->state->chart_labels, "numa_node", m->name, RRDLABEL_SRC_AUTO);
+
rrdset_flag_set(m->numastat_st, RRDSET_FLAG_DETAIL);
rrddim_add(m->numastat_st, "numa_hit", "hit", 1, 1, RRD_ALGORITHM_INCREMENTAL);
diff --git a/collectors/proc.plugin/sys_fs_btrfs.c b/collectors/proc.plugin/sys_fs_btrfs.c
index e28b60a7..158587a8 100644
--- a/collectors/proc.plugin/sys_fs_btrfs.c
+++ b/collectors/proc.plugin/sys_fs_btrfs.c
@@ -448,6 +448,11 @@ static inline int find_all_btrfs_pools(const char *path) {
return 0;
}
+static void add_labels_to_btrfs(BTRFS_NODE *n, RRDSET *st) {
+ rrdlabels_add(st->state->chart_labels, "device", n->id, RRDLABEL_SRC_AUTO);
+ rrdlabels_add(st->state->chart_labels, "device_label", n->label, RRDLABEL_SRC_AUTO);
+}
+
int do_sys_fs_btrfs(int update_every, usec_t dt) {
static int initialized = 0
, do_allocation_disks = CONFIG_BOOLEAN_AUTO
@@ -579,6 +584,8 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) {
node->rd_allocation_disks_metadata_used = rrddim_add(node->st_allocation_disks, "meta_used", "meta used", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
node->rd_allocation_disks_system_free = rrddim_add(node->st_allocation_disks, "sys_free", "sys free", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
node->rd_allocation_disks_system_used = rrddim_add(node->st_allocation_disks, "sys_used", "sys used", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_btrfs(node, node->st_allocation_disks);
}
else rrdset_next(node->st_allocation_disks);
@@ -632,6 +639,8 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) {
node->rd_allocation_data_free = rrddim_add(node->st_allocation_data, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
node->rd_allocation_data_used = rrddim_add(node->st_allocation_data, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_btrfs(node, node->st_allocation_data);
}
else rrdset_next(node->st_allocation_data);
@@ -676,6 +685,8 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) {
node->rd_allocation_metadata_free = rrddim_add(node->st_allocation_metadata, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
node->rd_allocation_metadata_used = rrddim_add(node->st_allocation_metadata, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
node->rd_allocation_metadata_reserved = rrddim_add(node->st_allocation_metadata, "reserved", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_btrfs(node, node->st_allocation_metadata);
}
else rrdset_next(node->st_allocation_metadata);
@@ -720,6 +731,8 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) {
node->rd_allocation_system_free = rrddim_add(node->st_allocation_system, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
node->rd_allocation_system_used = rrddim_add(node->st_allocation_system, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
+
+ add_labels_to_btrfs(node, node->st_allocation_system);
}
else rrdset_next(node->st_allocation_system);