From 5de2b6bda8d824e3f6313199ae0d4a790b90661b Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 20 Apr 2022 20:36:20 +0100 Subject: Fix network monitor interface ignore regex (#195) --- .../java/me/lucko/spark/common/monitor/net/NetworkMonitor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'spark-common/src/main/java/me') diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkMonitor.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkMonitor.java index dadd4e5..79ab8d9 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkMonitor.java +++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkMonitor.java @@ -41,8 +41,9 @@ public enum NetworkMonitor { // Latest readings private static final AtomicReference> SYSTEM = new AtomicReference<>(); - // a pattern to match the interface names to calculate rolling averages for - private static final Pattern INTERFACES_TO_MONITOR = Pattern.compile("^(eth\\d+)|(lo)$"); + // a pattern to match the interface names to exclude from monitoring + // ignore: virtual eth adapters + container bridge networks + private static final Pattern INTERFACES_TO_IGNORE = Pattern.compile("^(veth\\w+)|(br-\\w+)$"); // Rolling averages for system/process data over 15 mins private static final Map SYSTEM_AVERAGES = new ConcurrentHashMap<>(); @@ -96,7 +97,7 @@ public enum NetworkMonitor { private static void submit(Map rollingAveragesMap, Map values) { // ensure all incoming keys are present in the rolling averages map for (String key : values.keySet()) { - if (INTERFACES_TO_MONITOR.matcher(key).matches()) { + if (!INTERFACES_TO_IGNORE.matcher(key).matches()) { rollingAveragesMap.computeIfAbsent(key, k -> new NetworkInterfaceAverages(WINDOW_SIZE)); } } -- cgit