diff --git a/src/fr/devinsy/statoolinfos/metrics/http/IpCounters.java b/src/fr/devinsy/statoolinfos/metrics/IpCounters.java similarity index 67% rename from src/fr/devinsy/statoolinfos/metrics/http/IpCounters.java rename to src/fr/devinsy/statoolinfos/metrics/IpCounters.java index cb683b9..c1f0fc0 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/IpCounters.java +++ b/src/fr/devinsy/statoolinfos/metrics/IpCounters.java @@ -16,11 +16,13 @@ * You should have received a copy of the GNU Affero General Public License * along with StatoolInfos. If not, see . */ -package fr.devinsy.statoolinfos.metrics.http; +package fr.devinsy.statoolinfos.metrics; import java.util.HashMap; -import fr.devinsy.statoolinfos.metrics.PathCounters; +import org.apache.commons.lang3.StringUtils; + +import fr.devinsy.statoolinfos.util.IpUtils; import fr.devinsy.strings.StringSet; /** @@ -86,14 +88,17 @@ public class IpCounters extends HashMap */ public void put(final String ip, final String timemark) { - StringSet set = super.get(timemark); - if (set == null) + if (!StringUtils.isBlank(ip)) { - set = new StringSet(); - put(timemark, set); - } + StringSet set = super.get(timemark); + if (set == null) + { + set = new StringSet(); + put(timemark, set); + } - set.put(ip); + set.put(ip); + } } /** @@ -106,9 +111,44 @@ public class IpCounters extends HashMap */ public void put(final String ip, final String... timeMarks) { - for (String timeMark : timeMarks) + if (!StringUtils.isBlank(ip)) { - put(ip, timeMark); + for (String timeMark : timeMarks) + { + put(ip, timeMark); + } + } + } + + /** + * Put ipv 4. + * + * @param ip + * the ip + * @param timeMarks + * the time marks + */ + public void putIpv4(final String ip, final String... timeMarks) + { + if (IpUtils.isIpv4(ip)) + { + put(ip, timeMarks); + } + } + + /** + * Put ipv 6. + * + * @param ip + * the ip + * @param timeMarks + * the time marks + */ + public void putIpv6(final String ip, final String... timeMarks) + { + if (IpUtils.isIpv6(ip)) + { + put(ip, timeMarks); } } } diff --git a/src/fr/devinsy/statoolinfos/metrics/PathCounters.java b/src/fr/devinsy/statoolinfos/metrics/PathCounters.java index deb1395..cfd6461 100644 --- a/src/fr/devinsy/statoolinfos/metrics/PathCounters.java +++ b/src/fr/devinsy/statoolinfos/metrics/PathCounters.java @@ -482,4 +482,44 @@ public class PathCounters extends HashMap // return result; } + + /** + * Sets the. + * + * @param value + * the value + * @param path + * the path + * @param timeMarks + * the time marks + */ + public void set(final long value, final String path, final String... timeMarks) + { + for (String timeMark : timeMarks) + { + set(value, path, timeMark); + } + } + + /** + * Sets the. + * + * @param value + * the value + * @param path + * the path + * @param timeMark + * the time mark + */ + public void set(final long value, final String path, final String timeMark) + { + PathCounter counter = get(path, timeMark); + if (counter == null) + { + counter = new PathCounter(path, timeMark); + put(counter); + } + + counter.setCounter(value); + } } diff --git a/src/fr/devinsy/statoolinfos/metrics/Prober.java b/src/fr/devinsy/statoolinfos/metrics/Prober.java index eac5b7b..ae2cffd 100644 --- a/src/fr/devinsy/statoolinfos/metrics/Prober.java +++ b/src/fr/devinsy/statoolinfos/metrics/Prober.java @@ -42,9 +42,11 @@ import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogAnalyzer; import fr.devinsy.statoolinfos.metrics.http.HttpErrorLogAnalyzer; import fr.devinsy.statoolinfos.metrics.minetest.MinetestProber; import fr.devinsy.statoolinfos.metrics.mumble.MumbleProber; +import fr.devinsy.statoolinfos.metrics.privatebin.PrivatebinProber; import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperty; import fr.devinsy.statoolinfos.properties.PathPropertyUtils; +import fr.devinsy.statoolinfos.util.BuildInformation; import fr.devinsy.strings.StringList; import fr.devinsy.strings.StringsUtils; @@ -161,6 +163,21 @@ public class Prober counters.putAll(data); } + // + if (types.containsAnyIgnoreCase("PrivateBin")) + { + logger.info("== Processing Privatebin."); + String httpAccessLogs = configuration.getProbeHttpAccessLogSource(); + String httpAccessLogRegex = configuration.getProbeHttpAccessLogPattern(); + File dataDirectory = configuration.getAsFile("conf.probe.privatebin.data"); + logger.info("source=[{}]", httpAccessLogs); + logger.info("pattern=[{}]", httpAccessLogRegex); + logger.info("dataDirectory=[{}]", dataDirectory); + + PathCounters data = PrivatebinProber.probe(httpAccessLogs, httpAccessLogRegex, dataDirectory); + counters.putAll(data); + } + // Filter. logger.info("== Filtering with {}", dayCountFilter); if (dayCountFilter >= 0) @@ -349,7 +366,8 @@ public class Prober metrics.appendln("file.class=metrics"); metrics.appendln("file.generator=StatoolInfos"); metrics.appendln("file.datetime=" + LocalDateTime.now().toString()); - metrics.appendln("file.protocol=StatoolInfos-0.3.0"); + metrics.appendln("file.protocol=" + BuildInformation.instance().protocol()); + metrics.appendln(); metrics.appendln("# [Metrics]"); diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/ActivePlayerCounters.java b/src/fr/devinsy/statoolinfos/metrics/UserCounters.java similarity index 79% rename from src/fr/devinsy/statoolinfos/metrics/minetest/ActivePlayerCounters.java rename to src/fr/devinsy/statoolinfos/metrics/UserCounters.java index 104ac3c..71d1726 100644 --- a/src/fr/devinsy/statoolinfos/metrics/minetest/ActivePlayerCounters.java +++ b/src/fr/devinsy/statoolinfos/metrics/UserCounters.java @@ -16,24 +16,25 @@ * You should have received a copy of the GNU Affero General Public License * along with StatoolInfos. If not, see . */ -package fr.devinsy.statoolinfos.metrics.minetest; +package fr.devinsy.statoolinfos.metrics; import java.util.HashMap; -import fr.devinsy.statoolinfos.metrics.PathCounters; +import org.apache.commons.lang3.StringUtils; + import fr.devinsy.strings.StringSet; /** * The Class ActivePlayerCounters. */ -public class ActivePlayerCounters extends HashMap +public class UserCounters extends HashMap { private static final long serialVersionUID = 8340304752282908677L; /** * Instantiates a new active player counters. */ - public ActivePlayerCounters() + public UserCounters() { super(); } @@ -86,14 +87,17 @@ public class ActivePlayerCounters extends HashMap */ public void put(final String nickname, final String timemark) { - StringSet set = super.get(timemark); - if (set == null) + if (!StringUtils.isBlank(nickname)) { - set = new StringSet(); - put(timemark, set); - } + StringSet set = super.get(timemark); + if (set == null) + { + set = new StringSet(); + put(timemark, set); + } - set.put(nickname); + set.put(nickname); + } } /** @@ -106,9 +110,12 @@ public class ActivePlayerCounters extends HashMap */ public void put(final String nickname, final String... timeMarks) { - for (String timeMark : timeMarks) + if (!StringUtils.isBlank(nickname)) { - put(nickname, timeMark); + for (String timeMark : timeMarks) + { + put(nickname, timeMark); + } } } } diff --git a/src/fr/devinsy/statoolinfos/metrics/jitsi/JitsiProber.java b/src/fr/devinsy/statoolinfos/metrics/jitsi/JitsiProber.java new file mode 100644 index 0000000..64d6cc1 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/metrics/jitsi/JitsiProber.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.metrics.jitsi; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.metrics.PathCounters; + +/** + * The Class JitsiProber. + */ +public class JitsiProber +{ + private static Logger logger = LoggerFactory.getLogger(JitsiProber.class); + + /** + * Instantiates a new minetest prober. + */ + public JitsiProber() + { + } + + /** + * Probe. + * + * @param logs + * the logs + * @return the path counters + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static PathCounters probe(final String logs) throws IOException, StatoolInfosException + { + PathCounters result; + + result = new PathCounters(); + // result = MumbleLogAnalyzer.probe(logs); + + // metrics.service.users + // metrics.service.accounts + // metrics.service.accounts.active + // metrics.service.database.bytes + // metrics.service.files.bytes + + // metrics.videos.count + // metrics.videos.lives + // metrics.videos.views + // metrics.videos.comments + // metrics.videos.channels + // metrics.videos.federated.count + // metrics.videos.federated.comments + // metrics.videos.instances.followed + // metrics.videos.instances.followers + + // accounts + // database size + // file size + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogAnalyzer.java index eed44a4..b7b7455 100644 --- a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2021 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -31,8 +31,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.metrics.IpCounters; import fr.devinsy.statoolinfos.metrics.PathCounters; -import fr.devinsy.statoolinfos.metrics.http.IpCounters; +import fr.devinsy.statoolinfos.metrics.UserCounters; import fr.devinsy.statoolinfos.util.FilesUtils; import fr.devinsy.statoolinfos.util.IpUtils; import fr.devinsy.statoolinfos.util.LineIterator; @@ -44,8 +45,6 @@ public class MinetestLogAnalyzer { private static Logger logger = LoggerFactory.getLogger(MinetestLogAnalyzer.class); - public static final String DEFAULT_CHARSET_NAME = "UTF-8"; - // log_format combined '$remote_addr - $remote_user [$time_local] ' // '"$request" $status $body_bytes_sent ' // '"$http_referer" "$http_user_agent"'; @@ -54,7 +53,7 @@ public class MinetestLogAnalyzer private int errorCount; private PathCounters counters; - private ActivePlayerCounters activePlayers; + private UserCounters activePlayers; private IpCounters ips; private IpCounters ipv4; private IpCounters ipv6; @@ -65,7 +64,7 @@ public class MinetestLogAnalyzer public MinetestLogAnalyzer() { this.counters = new PathCounters(); - this.activePlayers = new ActivePlayerCounters(); + this.activePlayers = new UserCounters(); this.ips = new IpCounters(); this.ipv4 = new IpCounters(); this.ipv6 = new IpCounters(); @@ -83,10 +82,10 @@ public class MinetestLogAnalyzer result = new PathCounters(); result.putAll(this.counters); - result.putAll(this.activePlayers.getCounters("metrics.metaverse.players.active")); - result.putAll(this.ips.getCounters("metrics.metaverse.ip")); - result.putAll(this.ipv4.getCounters("metrics.metaverse.ip.ipv4")); - result.putAll(this.ipv6.getCounters("metrics.metaverse.ip.ipv6")); + result.putAll(this.activePlayers.getCounters("metrics.service.users")); + result.putAll(this.ips.getCounters("metrics.service.ip")); + result.putAll(this.ipv4.getCounters("metrics.service.ip.ipv4")); + result.putAll(this.ipv6.getCounters("metrics.service.ip.ipv6")); // return result; @@ -148,9 +147,8 @@ public class MinetestLogAnalyzer if (log != null) { // logger.info("LINE IS MATCHING [{}]", log); - // logger.info(log.getHttpUserAgent().toString()); - // General HTTP access logs. + // Timemarks. String year = log.getYear(); String yearMonth = log.getYearMonth(); String yearWeek = log.getYearWeek(); @@ -185,20 +183,21 @@ public class MinetestLogAnalyzer } // metrics.metaverse.players.active + // metrics.service.users this.activePlayers.put(log.getNickname(), year, yearMonth, yearWeek, date); // metrics.metaverse.players.max // TODO - // metrics.metaverse.joins -- + // metrics.metaverse.joiners -- if (log.getMessage().contains(" joins game.")) { - this.counters.inc("metrics.metaverse.joins", year, yearMonth, yearWeek, date); + this.counters.inc("metrics.metaverse.joiners", year, yearMonth, yearWeek, date); } - // metrics.metaverse.ip - // metrics.metaverse.ip.ipv4 - // metrics.metaverse.ip.ipv6 + // metrics.service.ip + // metrics.service.ip.ipv4 + // metrics.service.ip.ipv6 String ip = log.getIp(); if (ip != null) { diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogLevel.java b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogLevel.java index 9218b3f..dcc32b8 100644 --- a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogLevel.java +++ b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogLevel.java @@ -32,11 +32,11 @@ public enum MinetestLogLevel UNKNOWN; /** - * Value of. + * Of. * - * @param httpCode - * the code - * @return the http status category + * @param value + * the value + * @return the minetest log level */ public static MinetestLogLevel of(final String value) { diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogStat.java b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogStat.java deleted file mode 100644 index c6241bb..0000000 --- a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogStat.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2020 Christian Pierre MOMON - * - * This file is part of StatoolInfos, simple service statistics tool. - * - * StatoolInfos is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * StatoolInfos is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with StatoolInfos. If not, see . - */ -package fr.devinsy.statoolinfos.metrics.minetest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class HttpAccesLogStat. - */ -public class MinetestLogStat -{ - private static Logger logger = LoggerFactory.getLogger(MinetestLogStat.class); - - private int hitCount; - private int hitIpv4Count; - private int hitIpv6Count; - - private int pageCount; - private int pageIpv4Count; - private int pageIpv6Count; - - private int byteCount; - private int byteIpv4Count; - private int byteIpv6Count; - - private int fileCount; - private int fileIpv4Count; - private int fileIpv6Count; - - private int status1xxCount; - private int status2xxCount; - private int status3xxCount; - private int status4xxCount; - private int status5xxCount; - - private int ipCount; - private int ipIpv4Count; - private int ipIpv6Count; - - /** - * Instantiates a new http acces log stat. - */ - public MinetestLogStat() - { - } -} diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestProber.java b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestProber.java index 3a295b8..1ee21f7 100644 --- a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestProber.java +++ b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestProber.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2021 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -34,8 +34,6 @@ public class MinetestProber { private static Logger logger = LoggerFactory.getLogger(MinetestProber.class); - public static final String DEFAULT_CHARSET_NAME = "UTF-8"; - /** * Instantiates a new minetest prober. */ diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleDatabaseAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleDatabaseAnalyzer.java new file mode 100644 index 0000000..728f594 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleDatabaseAnalyzer.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.metrics.mumble; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.metrics.PathCounters; + +/** + * The Class HttpAccessLogProber. + */ +public class MumbleDatabaseAnalyzer +{ + private static Logger logger = LoggerFactory.getLogger(MumbleDatabaseAnalyzer.class); + + /** + * Instantiates a new http access log prober. + */ + private MumbleDatabaseAnalyzer() + { + } + + /** + * Probe. + * + * @param databasePath + * the database path + * @return the path counters + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static PathCounters probe(final String databasePath) throws IOException, StatoolInfosException + { + PathCounters result; + + result = new PathCounters(); + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java new file mode 100644 index 0000000..96a1405 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLog.java @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.metrics.mumble; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.metrics.TimeMarkUtils; +import fr.devinsy.strings.StringList; + +/** + * The Class MinetestLog. + */ +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$"); + + // 1 => <6:Cpm(-1)> Moved Cpm:6(-1) to Salon blabla 1[3:0] + public static final Pattern ROOM_PATTERN = Pattern.compile("^Moved .+ 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: (?.+)$"); + + private MumbleLogLevel level; + private LocalDateTime time; + private String message; + + /** + * Instantiates a new mumble log. + */ + public MumbleLog() + { + this.time = null; + this.level = null; + this.message = null; + } + + public String getDate() + { + String result; + + result = this.time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.FRANCE)); + + // + return result; + } + + /** + * Gets the ip. + * + * @return the ip + */ + public String getIp() + { + String result; + + Matcher matcher = IP_PATTERN.matcher(this.message); + if (matcher.matches()) + { + result = matcher.group("ip"); + } + else + { + result = null; + } + + // + return result; + } + + public MumbleLogLevel getLevel() + { + return this.level; + } + + public String getMessage() + { + return this.message; + } + + /** + * Gets the nickname. + * + * @return the nickname + */ + public String getNickname() + { + String result; + + Matcher matcher = NICK_PATTERN.matcher(this.message); + if (matcher.matches()) + { + result = matcher.group("nickname"); + } + else + { + result = null; + } + + // + return result; + } + + public String getRoomName() + { + String result; + + Matcher matcher = ROOM_PATTERN.matcher(this.message); + if (matcher.matches()) + { + result = matcher.group("room"); + } + else + { + result = null; + } + + // + return result; + } + + public LocalDateTime getTime() + { + return this.time; + } + + /** + * Gets the year. + * + * @return the year + */ + public String getYear() + { + String result; + + if (this.time == null) + { + result = null; + } + else + { + result = TimeMarkUtils.yearOf(this.time); + } + + // + return result; + } + + /** + * Gets the year month. + * + * @return the year month + */ + public String getYearMonth() + { + String result; + + if (this.time == null) + { + result = null; + } + else + { + result = TimeMarkUtils.yearMonthOf(this.time); + } + // + return result; + } + + /** + * Gets the year week. + * + * @return the year week + */ + public String getYearWeek() + { + String result; + if (this.time == null) + { + result = null; + } + else + { + result = TimeMarkUtils.yearWeekOf(this.time); + } + // + return result; + } + + public void setLevel(final MumbleLogLevel level) + { + this.level = level; + } + + public void setMessage(final String message) + { + this.message = message; + } + + public void setTime(final LocalDateTime time) + { + this.time = time; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() + { + String result; + + StringList buffer = new StringList(); + + buffer.append("[time=").append(this.time).append("]"); + + result = buffer.toString(); + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java new file mode 100644 index 0000000..3d3fd76 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/metrics/mumble/MumbleLogAnalyzer.java @@ -0,0 +1,284 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.metrics.mumble; + +import java.io.File; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.metrics.IpCounters; +import fr.devinsy.statoolinfos.metrics.PathCounters; +import fr.devinsy.statoolinfos.metrics.UserCounters; +import fr.devinsy.statoolinfos.util.FilesUtils; +import fr.devinsy.statoolinfos.util.IpUtils; +import fr.devinsy.statoolinfos.util.LineIterator; + +/** + * The Class HttpAccessLogProber. + */ +public class MumbleLogAnalyzer +{ + private static Logger logger = LoggerFactory.getLogger(MumbleLogAnalyzer.class); + + // https://salsa.debian.org/pkg-voip-team/mumble/-/blob/debian/src/murmur/main.cpp#L92 + // QString m= QString::fromLatin1("<%1>%2 %3") + // .arg(QChar::fromLatin1(c)) + // .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")) + // .arg(msg); + public static final Pattern MUMBLE_LOG_PATTERN = Pattern.compile("^<(?[DWCFX])>(?