diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java index 96a1405..c33e698 100644 --- a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -38,14 +38,17 @@ public class MumbleLog private static Logger logger = LoggerFactory.getLogger(MumbleLog.class); // 1 => <8:neox(-1)> Authenticated - public static final Pattern NICK_PATTERN = Pattern.compile("^1 => <\\d+:(?neox)(-?\\d+)> Authenticated$"); + public static final Pattern NICK_PATTERN = Pattern.compile("^\\d+ => <\\d+:(?\\S+)\\(-?\\d+\\)> Authenticated$"); // 1 => <6:Cpm(-1)> Moved Cpm:6(-1) to Salon blabla 1[3:0] - public static final Pattern ROOM_PATTERN = Pattern.compile("^Moved .+ to (?.+)[.+]$"); + public static final Pattern ROOM_PATTERN = Pattern.compile("^\\d+ => <\\S+> Moved \\S+ to (?.+)\\[.+\\]$"); // 1 => <6:(-1)> New connection: 123.456.78.90:54958 // 1 => <2:(-1)> New connection: [1234:5678:90ab:cdef::aaaa:eeee]:57588 - public static final Pattern IP_PATTERN = Pattern.compile("^New connection: (?.+)$"); + public static final Pattern IP_PATTERN = Pattern.compile("^\\d+ => \\S+ New connection: \\[?(?.+)\\]?:\\d+$"); + + // 1 => Ignoring connection: 123.45.555.555:44124 (Global ban) + public static final Pattern GLOBALBAN_PATTERN = Pattern.compile("^\\d+ => Ignoring connection: \\[?(?.+)\\]?:\\d+ \\(Global ban\\)$"); private MumbleLogLevel level; private LocalDateTime time; @@ -71,6 +74,29 @@ public class MumbleLog return result; } + /** + * Gets the global ban ip. + * + * @return the global ban ip + */ + public String getGlobalBanIp() + { + String result; + + Matcher matcher = GLOBALBAN_PATTERN.matcher(this.message); + if (matcher.matches()) + { + result = matcher.group("ip"); + } + else + { + result = null; + } + + // + return result; + } + /** * Gets the ip. * @@ -116,7 +142,7 @@ public class MumbleLog Matcher matcher = NICK_PATTERN.matcher(this.message); if (matcher.matches()) { - result = matcher.group("nickname"); + result = matcher.group("nick"); } else { @@ -127,6 +153,11 @@ public class MumbleLog return result; } + /** + * Gets the room name. + * + * @return the room name + */ public String getRoomName() { String result; @@ -145,6 +176,11 @@ public class MumbleLog return result; } + /** + * Gets the time. + * + * @return the time + */ public LocalDateTime getTime() { return this.time; diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java index 406531c..8fbb2ff 100644 --- a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -59,6 +59,7 @@ public class MumbleLogAnalyzer private IpCounters ipv4; private IpCounters ipv6; private UserCounters rooms; + private IpCounters globalBanIps; /** * Instantiates a new http access log prober. @@ -71,6 +72,7 @@ public class MumbleLogAnalyzer this.ipv4 = new IpCounters(); this.ipv6 = new IpCounters(); this.rooms = new UserCounters(); + this.globalBanIps = new IpCounters(); } /** @@ -90,6 +92,7 @@ public class MumbleLogAnalyzer result.putAll(this.ipv4.getCounters("metrics.service.ip.ipv4")); result.putAll(this.ipv6.getCounters("metrics.service.ip.ipv6")); result.putAll(this.rooms.getCounters("metrics.audioconferencing.rooms.active")); + result.putAll(this.globalBanIps.getCounters("metrics.mumble.globalbans.ip")); // return result; @@ -184,7 +187,11 @@ public class MumbleLogAnalyzer } else if (log.getLevel() == MumbleLogLevel.DEFAULT) { - this.counters.inc("metrics.mumble.logs.DEFAULT", year, yearMonth, yearWeek, date); + this.counters.inc("metrics.mumble.logs.default", year, yearMonth, yearWeek, date); + } + else + { + this.counters.inc("metrics.mumble.logs.unknown", year, yearMonth, yearWeek, date); } // metrics.service.users @@ -219,6 +226,14 @@ public class MumbleLogAnalyzer // metrics.audioconferencing.rooms.active this.rooms.put(log.getRoomName(), year, yearMonth, yearWeek, date); + // metrics.mumble.globalbans + String globalBanIp = log.getGlobalBanIp(); + if (globalBanIp != null) + { + this.counters.inc("metrics.mumble.globalbans", year, yearMonth, yearWeek, date); + this.globalBanIps.put(globalBanIp, year, yearMonth, yearWeek, date); + } + // metrics.audioconferencing.conferences // metrics.audioconferencing.hours // metrics.audioconferencing.traffic.received.bytes diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogLevel.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogLevel.java index 753d784..e839316 100644 --- a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogLevel.java +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -45,19 +45,19 @@ public enum MumbleLogLevel { MumbleLogLevel result; - if (StringUtils.equals(value, "DEBUG")) + if (StringUtils.equals(value, "D")) { result = DEBUG; } - else if (StringUtils.equals(value, "WARNING")) + else if (StringUtils.equals(value, "W")) { result = WARNING; } - else if (StringUtils.equals(value, "CRITICAL")) + else if (StringUtils.equals(value, "C")) { result = CRITICAL; } - else if (StringUtils.equals(value, "FATAL")) + else if (StringUtils.equals(value, "F")) { result = FATAL; } diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleProber.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleProber.java index cd78766..f85cb17 100644 --- a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleProber.java +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleProber.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -66,6 +66,8 @@ public class MumbleProber // metrics.mumble.logs.critical // metrics.mumble.logs.fatal // metrics.mumble.logs.default + // metrics.mumble.globalbans + // metrics.mumble.globalbans.ip result = MumbleLogAnalyzer.probe(logs); // result.putAll(MumbleDatabaseAnalyzer.probe());