Compare commits

..

2 commits

5 changed files with 317 additions and 170 deletions

View file

@ -22,6 +22,8 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -43,7 +45,7 @@ import fr.devinsy.statoolinfos.metrics.gitea.GiteaProber;
import fr.devinsy.statoolinfos.metrics.gsl.GSLProber;
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogAnalyzer;
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogs;
import fr.devinsy.statoolinfos.metrics.http.HttpErrorLogAnalyzer;
import fr.devinsy.statoolinfos.metrics.httperrorlog.HttpErrorLogAnalyzer;
import fr.devinsy.statoolinfos.metrics.libreqr.LibreQRProber;
import fr.devinsy.statoolinfos.metrics.minetest.MinetestProber;
import fr.devinsy.statoolinfos.metrics.mumble.MumbleProber;
@ -95,8 +97,7 @@ public class Prober
* @param configuration
* the configuration
* @param dayCountFilter
* the day count filter, 0=today, 1=previous day, 7=previous
* week
* the day count filter
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
@ -111,168 +112,18 @@ public class Prober
if (!types.isEmpty())
{
PathCounters counters = new PathCounters();
//
if (types.containsAnyIgnoreCase("HttpAccessLog"))
for (String type : types)
{
logger.info("== Probing HttpAccessLog.");
String source = configuration.getProbeHttpAccessLogSource();
String pattern = configuration.getProbeHttpAccessLogPattern();
String pathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("source=[{}]", source);
logger.info("pattern=[{}]", pattern);
logger.info("path=[{}]", pathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(source), pattern, pathFilter);
PathCounters data = HttpAccessLogAnalyzer.probe(httpAccessLogs);
counters.putAll(data);
try
{
Method method = Prober.class.getMethod("probe" + type, Configuration.class);
PathCounters subCounters = (PathCounters) method.invoke(null, configuration);
counters.putAll(subCounters);
}
//
if (types.containsAnyIgnoreCase("HttpErrorLog"))
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception)
{
logger.info("== Probing HttpErrorLog.");
String source = configuration.getProbeHttpErrorLogSource();
logger.info("source=[{}]", source);
PathCounters data = HttpErrorLogAnalyzer.probe(source);
counters.putAll(data);
logger.error("Prober not found: [{}]", type);
}
//
if (types.containsAnyIgnoreCase("Etherpad"))
{
logger.info("== Probing Etherpad.");
String logs = configuration.get("conf.probe.etherpad.logs");
logger.info("logs=[{}]", logs);
DatabaseConfig database = configuration.getDatabaseConfig("conf.probe.etherpad");
logger.info("database={}", database.toString());
String httpLogs = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("httpLogs=[{}]", httpLogs);
logger.info("httpAccessPattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPathFilter=[{}]", httpAccessPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpLogs), httpAccessLogPattern, httpAccessPathFilter);
PathCounters metrics = EtherpadProber.probe(httpAccessLogs, FilesUtils.searchByWildcard(logs), database);
counters.putAll(metrics);
}
//
if (types.containsAnyIgnoreCase("Framadate"))
{
logger.info("== Probing Framadate.");
String source = configuration.getProbeHttpAccessLogSource();
logger.info("source=[{}]", source);
// PathCounters datafilesPath =
// HttpErrorLogAnalyzer.probe(source);
// counters.putAll(data);
}
//
if (types.containsAnyIgnoreCase("Gitea"))
{
logger.info("== Probing Gitea.");
File dataDirectory = configuration.getAsFile("conf.probe.gitea.data");
logger.info("dataPath=[{}]", dataDirectory);
String apiURL = configuration.get("conf.probe.gitea.api.url");
logger.info("apiURL=[{}]", apiURL);
String apiToken = configuration.get("conf.probe.gitea.api.token");
logger.info("apiToken=[{}]", apiToken == null ? "null" : "************************");
DatabaseConfig database = configuration.getDatabaseConfig("conf.probe.gitea");
logger.info("database={}", database.toString());
String httpLogs = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessLogPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("httpLogs=[{}]", httpLogs);
logger.info("httpAccessPattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPath=[{}]", httpAccessLogPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpLogs), httpAccessLogPattern, httpAccessLogPathFilter);
PathCounters metrics = GiteaProber.probe(httpAccessLogs, apiURL, apiToken, dataDirectory, database);
counters.putAll(metrics);
}
//
if (types.containsAnyIgnoreCase("GSL"))
{
logger.info("== Probing GSL.");
File statsFile = configuration.getAsFile("conf.probe.gsl.stats");
logger.info("statsfile=[{}]", statsFile);
PathCounters data = GSLProber.probe(statsFile);
counters.putAll(data);
}
//
if (types.containsAnyIgnoreCase("LibreQR"))
{
logger.info("== Probing LibreQR.");
String httpAccessSource = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessLogPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("httpAccessSource=[{}]", httpAccessSource);
logger.info("httpAccessPattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPath=[{}]", httpAccessLogPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpAccessSource), httpAccessLogPattern, httpAccessLogPathFilter);
File dataDirectory = configuration.getAsFile("conf.probe.libreqr.datafiles");
logger.info("dataDirectory=[{}]", dataDirectory);
PathCounters data = LibreQRProber.probe(httpAccessLogs, dataDirectory);
counters.putAll(data);
}
//
if (types.containsAnyIgnoreCase("Minetest"))
{
logger.info("== Probing Minetest.");
String source = configuration.get("conf.probe.minetest.logs");
logger.info("source=[{}]", source);
DatabaseConfig playerDatabase = configuration.getDatabaseConfig("conf.probe.minetest.players");
logger.info("players database={}", playerDatabase.toString());
DatabaseConfig worldDatabase = configuration.getDatabaseConfig("conf.probe.minetest.worlds");
logger.info("wordls database={}", worldDatabase.toString());
PathCounters data = MinetestProber.probe(source, playerDatabase, worldDatabase);
counters.putAll(data);
}
//
if (types.containsAnyIgnoreCase("Mumble"))
{
logger.info("== Probing Mumble.");
String source = configuration.get("conf.probe.mumble.logs");
logger.info("source=[{}]", source);
PathCounters data = MumbleProber.probe(source);
counters.putAll(data);
}
//
if (types.containsAnyIgnoreCase("PrivateBin"))
{
logger.info("== Probing Privatebin.");
String httpAccessLogSource = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessLogPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("source=[{}]", httpAccessLogSource);
logger.info("pattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPath=[{}]", httpAccessLogPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpAccessLogSource), httpAccessLogPattern, httpAccessLogPathFilter);
File dataDirectory = configuration.getAsFile("conf.probe.privatebin.data");
logger.info("dataDirectory=[{}]", dataDirectory);
PathCounters data = PrivatebinProber.probe(httpAccessLogs, dataDirectory);
counters.putAll(data);
}
// Filter.
@ -353,6 +204,302 @@ public class Prober
probe(configuration, dayCountFilter);
}
/**
* Probe etherpad.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeEtherpad(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing Etherpad.");
String logs = configuration.get("conf.probe.etherpad.logs");
DatabaseConfig database = configuration.getDatabaseConfig("conf.probe.etherpad");
logger.info("logs=[{}]", logs);
logger.info("database={}", database.toString());
String httpLogs = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("httpLogs=[{}]", httpLogs);
logger.info("httpAccessPattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPathFilter=[{}]", httpAccessPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpLogs), httpAccessLogPattern, httpAccessPathFilter);
result = EtherpadProber.probe(httpAccessLogs, FilesUtils.searchByWildcard(logs), database);
//
return result;
}
/**
* Probe framadate.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeFramadate(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing Framadate.");
String source = configuration.getProbeHttpAccessLogSource();
logger.info("source=[{}]", source);
// TODO
// PathCounters datafilesPath =
// HttpErrorLogAnalyzer.probe(source);
// counters.putAll(data);
result = new PathCounters();
//
return result;
}
/**
* Probe gitea.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeGitea(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing Gitea.");
File dataDirectory = configuration.getAsFile("conf.probe.gitea.data");
String apiURL = configuration.get("conf.probe.gitea.api.url");
String apiToken = configuration.get("conf.probe.gitea.api.token");
DatabaseConfig database = configuration.getDatabaseConfig("conf.probe.gitea");
logger.info("dataPath=[{}]", dataDirectory);
logger.info("apiURL=[{}]", apiURL);
logger.info("apiToken=[{}]", apiToken == null ? "null" : "************************");
logger.info("database={}", database.toString());
String httpLogs = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessLogPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("httpLogs=[{}]", httpLogs);
logger.info("httpAccessPattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPath=[{}]", httpAccessLogPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpLogs), httpAccessLogPattern, httpAccessLogPathFilter);
result = GiteaProber.probe(httpAccessLogs, apiURL, apiToken, dataDirectory, database);
//
return result;
}
/**
* Probe GSL.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeGSL(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing GSL.");
File statsFile = configuration.getAsFile("conf.probe.gsl.stats");
logger.info("statsfile=[{}]", statsFile);
result = GSLProber.probe(statsFile);
//
return result;
}
/**
* Probe htt access log.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeHttpAccessLog(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing HttpAccessLog.");
String source = configuration.getProbeHttpAccessLogSource();
String pattern = configuration.getProbeHttpAccessLogPattern();
String pathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("source=[{}]", source);
logger.info("pattern=[{}]", pattern);
logger.info("path=[{}]", pathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(source), pattern, pathFilter);
result = HttpAccessLogAnalyzer.probe(httpAccessLogs);
//
return result;
}
public static PathCounters probeHttpErrorLog(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing HttpErrorLog.");
String source = configuration.getProbeHttpErrorLogSource();
logger.info("source=[{}]", source);
result = HttpErrorLogAnalyzer.probe(source);
//
return result;
}
/**
* Probe libre QR.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeLibreQR(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing LibreQR.");
String httpAccessSource = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessLogPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("httpAccessSource=[{}]", httpAccessSource);
logger.info("httpAccessPattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPath=[{}]", httpAccessLogPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpAccessSource), httpAccessLogPattern, httpAccessLogPathFilter);
File dataDirectory = configuration.getAsFile("conf.probe.libreqr.datafiles");
logger.info("dataDirectory=[{}]", dataDirectory);
result = LibreQRProber.probe(httpAccessLogs, dataDirectory);
//
return result;
}
/**
* Probe minetest.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeMinetest(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing Minetest.");
String source = configuration.get("conf.probe.minetest.logs");
DatabaseConfig playerDatabase = configuration.getDatabaseConfig("conf.probe.minetest.players");
DatabaseConfig worldDatabase = configuration.getDatabaseConfig("conf.probe.minetest.worlds");
logger.info("source=[{}]", source);
logger.info("players database={}", playerDatabase.toString());
logger.info("wordls database={}", worldDatabase.toString());
result = MinetestProber.probe(source, playerDatabase, worldDatabase);
//
return result;
}
/**
* Probe mumble.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probeMumble(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing Mumble.");
String source = configuration.get("conf.probe.mumble.logs");
logger.info("source=[{}]", source);
result = MumbleProber.probe(source);
//
return result;
}
/**
* Probe private bin.
*
* @param configuration
* the configuration
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probePrivateBin(final Configuration configuration) throws IOException, StatoolInfosException
{
PathCounters result;
logger.info("== Probing Privatebin.");
String httpAccessLogSource = configuration.getProbeHttpAccessLogSource();
String httpAccessLogPattern = configuration.getProbeHttpAccessLogPattern();
String httpAccessLogPathFilter = configuration.getProbeHttpAccessLogPathFilter();
logger.info("source=[{}]", httpAccessLogSource);
logger.info("pattern=[{}]", httpAccessLogPattern);
logger.info("httpAccessPath=[{}]", httpAccessLogPathFilter);
HttpAccessLogs httpAccessLogs = new HttpAccessLogs(FilesUtils.searchByWildcard(httpAccessLogSource), httpAccessLogPattern, httpAccessLogPathFilter);
File dataDirectory = configuration.getAsFile("conf.probe.privatebin.data");
logger.info("dataDirectory=[{}]", dataDirectory);
result = PrivatebinProber.probe(httpAccessLogs, dataDirectory);
//
return result;
}
/**
* Read metrics.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2023 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httperrorlog;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httperrorlog;
import java.io.File;
import java.io.IOException;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2023 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple key value database.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2023 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple key value database.
*