diff options
author | Luck <git@lucko.me> | 2022-04-20 20:36:20 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2022-04-20 20:36:20 +0100 |
commit | 5de2b6bda8d824e3f6313199ae0d4a790b90661b (patch) | |
tree | e18140dfc955ce2e0b90e8c3ad11f0730c04dba6 /spark-common/src/main/java/me | |
parent | 86a312842662ba57faa8fd5e8471672dfac13089 (diff) | |
download | spark-5de2b6bda8d824e3f6313199ae0d4a790b90661b.tar.gz spark-5de2b6bda8d824e3f6313199ae0d4a790b90661b.tar.bz2 spark-5de2b6bda8d824e3f6313199ae0d4a790b90661b.zip |
Fix network monitor interface ignore regex (#195)
Diffstat (limited to 'spark-common/src/main/java/me')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkMonitor.java | 7 |
1 files changed, 4 insertions, 3 deletions
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<Map<String, NetworkInterfaceInfo>> 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<String, NetworkInterfaceAverages> SYSTEM_AVERAGES = new ConcurrentHashMap<>(); @@ -96,7 +97,7 @@ public enum NetworkMonitor { private static void submit(Map<String, NetworkInterfaceAverages> rollingAveragesMap, Map<String, NetworkInterfaceInfo> 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)); } } |