summaryrefslogtreecommitdiffstats
path: root/src/collectors
diff options
context:
space:
mode:
Diffstat (limited to 'src/collectors')
-rw-r--r--src/collectors/common-contexts/mem.swap.h8
-rw-r--r--src/collectors/freebsd.plugin/freebsd_kstat_zfs.c9
-rw-r--r--src/collectors/proc.plugin/proc_meminfo.c11
-rw-r--r--src/collectors/proc.plugin/proc_net_dev.c51
-rw-r--r--src/collectors/proc.plugin/proc_spl_kstat_zfs.c2
-rw-r--r--src/collectors/proc.plugin/zfs_common.c2
-rw-r--r--src/collectors/proc.plugin/zfs_common.h2
7 files changed, 58 insertions, 27 deletions
diff --git a/src/collectors/common-contexts/mem.swap.h b/src/collectors/common-contexts/mem.swap.h
index 6d692ef3b..1c1b053d7 100644
--- a/src/collectors/common-contexts/mem.swap.h
+++ b/src/collectors/common-contexts/mem.swap.h
@@ -6,6 +6,14 @@ static inline void common_mem_swap(uint64_t free_bytes, uint64_t used_bytes, int
static RRDSET *st_system_swap = NULL;
static RRDDIM *rd_free = NULL, *rd_used = NULL;
+ if (free_bytes == 0 && used_bytes == 0 && st_system_swap) {
+ rrdset_is_obsolete___safe_from_collector_thread(st_system_swap);
+ st_system_swap = NULL;
+ rd_free = NULL;
+ rd_used = NULL;
+ return;
+ }
+
if(unlikely(!st_system_swap)) {
st_system_swap = rrdset_create_localhost(
"mem"
diff --git a/src/collectors/freebsd.plugin/freebsd_kstat_zfs.c b/src/collectors/freebsd.plugin/freebsd_kstat_zfs.c
index fdece7deb..ded6a8ee5 100644
--- a/src/collectors/freebsd.plugin/freebsd_kstat_zfs.c
+++ b/src/collectors/freebsd.plugin/freebsd_kstat_zfs.c
@@ -43,6 +43,8 @@ int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
int hash_chains[5];
int hash_chain_max[5];
int p[5];
+ int pd[5];
+ int pm[5];
int c[5];
int c_min[5];
int c_max[5];
@@ -145,7 +147,14 @@ int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt) {
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_collisions", mibs.hash_collisions, arcstats.hash_collisions);
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_chains", mibs.hash_chains, arcstats.hash_chains);
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.hash_chain_max", mibs.hash_chain_max, arcstats.hash_chain_max);
+
+#if __FreeBSD_version >= 1400000
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.pd", mibs.pd, arcstats.pd);
+ GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.pm", mibs.pm, arcstats.pm);
+#else
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.p", mibs.p, arcstats.p);
+#endif
+
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c", mibs.c, arcstats.c);
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c_min", mibs.c_min, arcstats.c_min);
GETSYSCTL_SIMPLE("kstat.zfs.misc.arcstats.c_max", mibs.c_max, arcstats.c_max);
diff --git a/src/collectors/proc.plugin/proc_meminfo.c b/src/collectors/proc.plugin/proc_meminfo.c
index db458b239..781329b59 100644
--- a/src/collectors/proc.plugin/proc_meminfo.c
+++ b/src/collectors/proc.plugin/proc_meminfo.c
@@ -12,6 +12,8 @@
int do_proc_meminfo(int update_every, usec_t dt) {
(void)dt;
+ static bool swap_configured = false;
+
static procfile *ff = NULL;
static int do_ram = -1
, do_swap = -1
@@ -235,7 +237,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
// http://calimeroteknik.free.fr/blag/?article20/really-used-memory-on-gnu-linux
// KReclaimable includes SReclaimable, it was added in kernel v4.20
- unsigned long long reclaimable = KReclaimable > 0 ? KReclaimable : SReclaimable;
+ unsigned long long reclaimable = inside_lxc_container ? 0 : (KReclaimable > 0 ? KReclaimable : SReclaimable);
unsigned long long MemCached = Cached + reclaimable - Shmem;
unsigned long long MemUsed = MemTotal - MemFree - MemCached - Buffers;
// The Linux kernel doesn't report ZFS ARC usage as cache memory (the ARC is included in the total used system memory)
@@ -257,6 +259,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
if (SwapTotal && (do_swap == CONFIG_BOOLEAN_YES || do_swap == CONFIG_BOOLEAN_AUTO)) {
do_swap = CONFIG_BOOLEAN_YES;
common_mem_swap(SwapFree * 1024, SwapUsed * 1024, update_every);
+ swap_configured = true;
{
static RRDSET *st_mem_swap_cached = NULL;
@@ -313,8 +316,14 @@ int do_proc_meminfo(int update_every, usec_t dt) {
rrddim_set_by_pointer(st_mem_zswap, rd_zswapped, Zswapped);
rrdset_done(st_mem_zswap);
}
+ } else {
+ if (swap_configured) {
+ common_mem_swap(SwapFree * 1024, SwapUsed * 1024, update_every);
+ swap_configured = false;
+ }
}
+
if (arl_hwcorrupted->flags & ARL_ENTRY_FLAG_FOUND &&
(do_hwcorrupt == CONFIG_BOOLEAN_YES || do_hwcorrupt == CONFIG_BOOLEAN_AUTO)) {
do_hwcorrupt = CONFIG_BOOLEAN_YES;
diff --git a/src/collectors/proc.plugin/proc_net_dev.c b/src/collectors/proc.plugin/proc_net_dev.c
index 40702c387..41c10ddbc 100644
--- a/src/collectors/proc.plugin/proc_net_dev.c
+++ b/src/collectors/proc.plugin/proc_net_dev.c
@@ -12,7 +12,7 @@
#define READ_RETRY_PERIOD 60 // seconds
-time_t double_linked_device_collect_delay_secs = 120;
+time_t virtual_device_collect_delay_secs = 40;
enum {
NETDEV_DUPLEX_UNKNOWN,
@@ -92,7 +92,6 @@ static struct netdev {
int enabled;
bool updated;
bool function_ready;
- bool double_linked; // iflink != ifindex
time_t discover_time;
@@ -809,7 +808,6 @@ static struct netdev *get_netdev(const char *name) {
d->len = strlen(d->name);
d->chart_labels = rrdlabels_create();
d->function_ready = false;
- d->double_linked = false;
d->chart_type_net_bytes = strdupz("net");
d->chart_type_net_compressed = strdupz("net_compressed");
@@ -858,25 +856,10 @@ static struct netdev *get_netdev(const char *name) {
return d;
}
-static bool is_iface_double_linked(struct netdev *d) {
- char filename[FILENAME_MAX + 1];
- unsigned long long iflink = 0;
- unsigned long long ifindex = 0;
-
- snprintfz(filename, FILENAME_MAX, "%s/sys/class/net/%s/iflink", netdata_configured_host_prefix, d->name);
- if (read_single_number_file(filename, &iflink))
- return false;
-
- snprintfz(filename, FILENAME_MAX, "%s/sys/class/net/%s/ifindex", netdata_configured_host_prefix, d->name);
- if (read_single_number_file(filename, &ifindex))
- return false;
-
- return iflink != ifindex;
-}
-
int do_proc_net_dev(int update_every, usec_t dt) {
(void)dt;
static SIMPLE_PATTERN *disabled_list = NULL;
+ static SIMPLE_PATTERN *virtual_iface_no_delay = NULL;
static procfile *ff = NULL;
static int enable_new_interfaces = -1;
static int do_bandwidth = -1, do_packets = -1, do_errors = -1, do_drops = -1, do_fifo = -1, do_compressed = -1,
@@ -921,8 +904,26 @@ int do_proc_net_dev(int update_every, usec_t dt) {
do_compressed = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETDEV, "compressed packets for all interfaces", CONFIG_BOOLEAN_NO);
disabled_list = simple_pattern_create(
- config_get(CONFIG_SECTION_PLUGIN_PROC_NETDEV, "disable by default interfaces matching",
- "lo fireqos* *-ifb fwpr* fwbr* fwln*"), NULL, SIMPLE_PATTERN_EXACT, true);
+ config_get(
+ CONFIG_SECTION_PLUGIN_PROC_NETDEV,
+ "disable by default interfaces matching",
+ "lo fireqos* *-ifb fwpr* fwbr* fwln*"),
+ NULL,
+ SIMPLE_PATTERN_EXACT,
+ true);
+
+ virtual_iface_no_delay = simple_pattern_create(
+ " bond* "
+ " vlan* "
+ " vmbr* "
+ " wg* "
+ " vpn* "
+ " tun* "
+ " gre* "
+ " docker* ",
+ NULL,
+ SIMPLE_PATTERN_EXACT,
+ true);
netdev_renames_init();
}
@@ -1009,8 +1010,6 @@ int do_proc_net_dev(int update_every, usec_t dt) {
if(d->enabled == CONFIG_BOOLEAN_NO)
continue;
- d->double_linked = is_iface_double_linked(d);
-
d->do_bandwidth = do_bandwidth;
d->do_packets = do_packets;
d->do_errors = do_errors;
@@ -1060,8 +1059,10 @@ int do_proc_net_dev(int update_every, usec_t dt) {
// This is necessary to prevent the creation of charts for virtual interfaces that will later be
// recreated as container interfaces (create container) or
// rediscovered and recreated only to be deleted almost immediately (stop/remove container)
- if (d->double_linked && d->virtual && (now - d->discover_time < double_linked_device_collect_delay_secs))
+ if (d->virtual && !simple_pattern_matches(virtual_iface_no_delay, d->name) &&
+ (now - d->discover_time < virtual_device_collect_delay_secs)) {
continue;
+ }
if(likely(d->do_bandwidth != CONFIG_BOOLEAN_NO || !d->virtual)) {
d->rbytes = str2kernel_uint_t(procfile_lineword(ff, l, 1));
@@ -1717,7 +1718,7 @@ void *netdev_main(void *ptr_is_null __maybe_unused)
worker_register_job_name(0, "netdev");
if (getenv("KUBERNETES_SERVICE_HOST") != NULL && getenv("KUBERNETES_SERVICE_PORT") != NULL)
- double_linked_device_collect_delay_secs = 300;
+ virtual_device_collect_delay_secs = 300;
rrd_function_add_inline(localhost, NULL, "network-interfaces", 10,
RRDFUNCTIONS_PRIORITY_DEFAULT, RRDFUNCTIONS_NETDEV_HELP,
diff --git a/src/collectors/proc.plugin/proc_spl_kstat_zfs.c b/src/collectors/proc.plugin/proc_spl_kstat_zfs.c
index be96f4449..5a0f90951 100644
--- a/src/collectors/proc.plugin/proc_spl_kstat_zfs.c
+++ b/src/collectors/proc.plugin/proc_spl_kstat_zfs.c
@@ -54,6 +54,8 @@ int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) {
arl_expect(arl_base, "hash_chains", &arcstats.hash_chains);
arl_expect(arl_base, "hash_chain_max", &arcstats.hash_chain_max);
arl_expect(arl_base, "p", &arcstats.p);
+ arl_expect(arl_base, "pd", &arcstats.pd);
+ arl_expect(arl_base, "pm", &arcstats.pm);
arl_expect(arl_base, "c", &arcstats.c);
arl_expect(arl_base, "c_min", &arcstats.c_min);
arl_expect(arl_base, "c_max", &arcstats.c_max);
diff --git a/src/collectors/proc.plugin/zfs_common.c b/src/collectors/proc.plugin/zfs_common.c
index cb5bd20e0..dadf2f84d 100644
--- a/src/collectors/proc.plugin/zfs_common.c
+++ b/src/collectors/proc.plugin/zfs_common.c
@@ -560,7 +560,7 @@ void generate_charts_arc_summary(const char *plugin, const char *module, int upd
//unsigned long long anon_hits = arcstats.hits - (arcstats.mfu_hits + arcstats.mru_hits + arcstats.mfu_ghost_hits + arcstats.mru_ghost_hits);
unsigned long long arc_size = arcstats.size;
- unsigned long long mru_size = arcstats.p;
+ unsigned long long mru_size = arcstats.p > 0 ? arcstats.p : arcstats.pd + arcstats.pm;
//unsigned long long target_min_size = arcstats.c_min;
//unsigned long long target_max_size = arcstats.c_max;
unsigned long long target_size = arcstats.c;
diff --git a/src/collectors/proc.plugin/zfs_common.h b/src/collectors/proc.plugin/zfs_common.h
index c0f088170..7c2b3d334 100644
--- a/src/collectors/proc.plugin/zfs_common.h
+++ b/src/collectors/proc.plugin/zfs_common.h
@@ -41,6 +41,8 @@ struct arcstats {
unsigned long long hash_chains;
unsigned long long hash_chain_max;
unsigned long long p;
+ unsigned long long pd;
+ unsigned long long pm;
unsigned long long c;
unsigned long long c_min;
unsigned long long c_max;