From 3feafb815cc0dd52459881973ff93f8795d5145c Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Tue, 11 Jan 2022 16:02:57 +0100 Subject: [PATCH] Improved code. --- .../metrics/http/HttpAccessLogAnalyzer.java | 2 +- .../metrics/minetest/MinetestLogAnalyzer.java | 9 ++++---- .../metrics/minetest/MinetestProber.java | 22 ++++++++++++++----- .../properties/PathPropertyList.java | 19 +++++----------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java index 908a264..9e10247 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java @@ -237,7 +237,7 @@ public class HttpAccessLogAnalyzer } // metrics.http.pages.* = - if ((isPage(log.getRequest())) && (log.getStatus().getCategory() == HttpStatusCategory.SUCCESS)) + if ((log.getStatus().getCategory() == HttpStatusCategory.SUCCESS) && (isPage(log.getRequest()))) { this.counters.inc("metrics.http.pages", year, yearMonth, yearWeek, date); } diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestLogAnalyzer.java index b7b7455..444e76b 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) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -83,6 +83,7 @@ public class MinetestLogAnalyzer result.putAll(this.counters); result.putAll(this.activePlayers.getCounters("metrics.service.users")); + result.putAll(this.activePlayers.getCounters("metrics.service.accounts.active")); 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")); @@ -161,6 +162,7 @@ public class MinetestLogAnalyzer // metrics.metaverse.logs.warning // metrics.metaverse.logs.error // metrics.metaverse.logs.none + // metrics.metaverse.logs.unknown if (log.getLevel() == MinetestLogLevel.ACTION) { this.counters.inc("metrics.metaverse.logs.action", year, yearMonth, yearWeek, date); @@ -182,14 +184,13 @@ public class MinetestLogAnalyzer this.counters.inc("metrics.metaverse.logs.unknown", year, yearMonth, yearWeek, date); } - // metrics.metaverse.players.active - // metrics.service.users + // metrics.service.users (= metrics.metaverse.players.active) this.activePlayers.put(log.getNickname(), year, yearMonth, yearWeek, date); // metrics.metaverse.players.max // TODO - // metrics.metaverse.joiners -- + // metrics.metaverse.joiners if (log.getMessage().contains(" joins game.")) { this.counters.inc("metrics.metaverse.joiners", year, yearMonth, yearWeek, date); diff --git a/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestProber.java b/src/fr/devinsy/statoolinfos/metrics/minetest/MinetestProber.java index 1ee21f7..184f0c9 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) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -55,12 +55,24 @@ public class MinetestProber { PathCounters result; + // metrics.service.users, metrics.service.accounts.active + // metrics.metaverse.joiners + // metrics.service.ip + // metrics.service.ip.ipv4 + // metrics.service.ip.ipv6 + // metrics.metaverse.logs + // metrics.metaverse.logs.action + // metrics.metaverse.logs.warning + // metrics.metaverse.logs.error + // metrics.metaverse.logs.none + // metrics.metaverse.logs.unknown result = MinetestLogAnalyzer.probe(logs); - // metrics.metaverse.players - // accounts - // database size - // file size + // result.putAll(MumbleDatabaseAnalyzer.probe()); + // metrics.service.accounts + // metrics.service.database.bytes + + // metrics.service.files.bytes // return result; diff --git a/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java b/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java index 11788d5..954296d 100644 --- a/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java +++ b/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -258,22 +258,13 @@ public class PathPropertyList extends ArrayList implements PathPro pattern = prefix + "."; } - boolean ended = false; - Iterator iterator = iterator(); - while (!ended) + for (PathProperty current : this) { - if (iterator.hasNext()) + if (StringUtils.startsWith(current.getPath(), pattern)) { - PathProperty current = iterator.next(); - if (StringUtils.startsWith(current.getPath(), pattern)) - { - result.add(current); - } - } - else - { - ended = true; + result.add(current); } + } }