Added GSL metric generator.

This commit is contained in:
Christian P. MOMON 2022-04-18 20:34:54 +02:00
parent 7533d0cd43
commit 03d7661ba9
3 changed files with 129 additions and 0 deletions

View file

@ -178,6 +178,16 @@ conf.probe.gitea.database.password=
conf.probe.target=/srv/statoolinfos/well-known/statoolinfos/foo.bar.org-metrics.properties
```
### GSL metrics
Configuration template:
```
conf.probe.types=GSL
conf.probe.gsl.stats=/foo/bar/stats.properties
conf.probe.target=/srv/statoolinfos/well-known/statoolinfos/foo.bar.org-metrics.properties
```
### LibreQR metrics
Configuration template:

View file

@ -40,6 +40,7 @@ import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.metrics.etherpad.EtherpadProber;
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.HttpErrorLogAnalyzer;
import fr.devinsy.statoolinfos.metrics.libreqr.LibreQRProber;
@ -184,6 +185,18 @@ public class Prober
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"))
{

View file

@ -0,0 +1,106 @@
/*
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.gsl;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.metrics.PathCounters;
import fr.devinsy.strings.StringList;
/**
* The Class GSLProber.
*/
public class GSLProber
{
private static Logger logger = LoggerFactory.getLogger(GSLProber.class);
/**
* Instantiates a new GSL prober.
*/
private GSLProber()
{
}
/**
* Probe.
*
* @param httpLogs
* the http logs
* @param httpLogRegex
* the http log regex
* @param dataPath
* the data 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 File statsFile) throws IOException, StatoolInfosException
{
PathCounters result;
result = new PathCounters();
//
Properties properties = new Properties();
properties.load(new FileReader(statsFile));
StringList timemarks = result.getNowTimeMarks();
// metrics.gsl.articles =
String value = properties.getProperty("gsl.articles");
if (NumberUtils.isDigits(value))
{
result.set(Long.valueOf(value), "metrics.gsl.articles", timemarks);
}
// metrics.gsl.articles.pages=
value = properties.getProperty("gsl.articles.pages");
if (NumberUtils.isDigits(value))
{
result.set(Long.valueOf(value), "metrics.gsl.articles.pages", timemarks);
}
// metrics.gsl.articles.posts=
value = properties.getProperty("gsl.articles.posts");
if (NumberUtils.isDigits(value))
{
result.set(Long.valueOf(value), "metrics.gsl.articles.posts", timemarks);
}
// metrics.gsl.authors =
value = properties.getProperty("gsl.authors");
if (NumberUtils.isDigits(value))
{
result.set(Long.valueOf(value), "metrics.gsl.authors", timemarks);
}
//
return result;
}
}