Improved code.

This commit is contained in:
Christian P. MOMON 2022-01-11 16:02:57 +01:00
parent f02a3b7dd4
commit 3feafb815c
4 changed files with 28 additions and 24 deletions

View file

@ -237,7 +237,7 @@ public class HttpAccessLogAnalyzer
} }
// metrics.http.pages.* = // 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); this.counters.inc("metrics.http.pages", year, yearMonth, yearWeek, date);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -83,6 +83,7 @@ public class MinetestLogAnalyzer
result.putAll(this.counters); result.putAll(this.counters);
result.putAll(this.activePlayers.getCounters("metrics.service.users")); 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.ips.getCounters("metrics.service.ip"));
result.putAll(this.ipv4.getCounters("metrics.service.ip.ipv4")); result.putAll(this.ipv4.getCounters("metrics.service.ip.ipv4"));
result.putAll(this.ipv6.getCounters("metrics.service.ip.ipv6")); result.putAll(this.ipv6.getCounters("metrics.service.ip.ipv6"));
@ -161,6 +162,7 @@ public class MinetestLogAnalyzer
// metrics.metaverse.logs.warning // metrics.metaverse.logs.warning
// metrics.metaverse.logs.error // metrics.metaverse.logs.error
// metrics.metaverse.logs.none // metrics.metaverse.logs.none
// metrics.metaverse.logs.unknown
if (log.getLevel() == MinetestLogLevel.ACTION) if (log.getLevel() == MinetestLogLevel.ACTION)
{ {
this.counters.inc("metrics.metaverse.logs.action", year, yearMonth, yearWeek, date); 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); this.counters.inc("metrics.metaverse.logs.unknown", year, yearMonth, yearWeek, date);
} }
// metrics.metaverse.players.active // metrics.service.users (= metrics.metaverse.players.active)
// metrics.service.users
this.activePlayers.put(log.getNickname(), year, yearMonth, yearWeek, date); this.activePlayers.put(log.getNickname(), year, yearMonth, yearWeek, date);
// metrics.metaverse.players.max // metrics.metaverse.players.max
// TODO // TODO
// metrics.metaverse.joiners -- // metrics.metaverse.joiners
if (log.getMessage().contains(" joins game.")) if (log.getMessage().contains(" joins game."))
{ {
this.counters.inc("metrics.metaverse.joiners", year, yearMonth, yearWeek, date); this.counters.inc("metrics.metaverse.joiners", year, yearMonth, yearWeek, date);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -55,12 +55,24 @@ public class MinetestProber
{ {
PathCounters result; 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); result = MinetestLogAnalyzer.probe(logs);
// metrics.metaverse.players // result.putAll(MumbleDatabaseAnalyzer.probe());
// accounts // metrics.service.accounts
// database size // metrics.service.database.bytes
// file size
// metrics.service.files.bytes
// //
return result; return result;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -258,22 +258,13 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
pattern = prefix + "."; pattern = prefix + ".";
} }
boolean ended = false; for (PathProperty current : this)
Iterator<PathProperty> iterator = iterator();
while (!ended)
{ {
if (iterator.hasNext())
{
PathProperty current = iterator.next();
if (StringUtils.startsWith(current.getPath(), pattern)) if (StringUtils.startsWith(current.getPath(), pattern))
{ {
result.add(current); result.add(current);
} }
}
else
{
ended = true;
}
} }
} }