Improved naming.
This commit is contained in:
parent
909cc17a8b
commit
614c064a24
3 changed files with 111 additions and 101 deletions
|
@ -381,9 +381,9 @@ public class Configuration extends PathPropertyList
|
||||||
*
|
*
|
||||||
* @return the probe mode
|
* @return the probe mode
|
||||||
*/
|
*/
|
||||||
public ProbeMode getProbeMode()
|
public ProbePeriod getProbeMode()
|
||||||
{
|
{
|
||||||
ProbeMode result;
|
ProbePeriod result;
|
||||||
|
|
||||||
String value = get("conf.probe.mode");
|
String value = get("conf.probe.mode");
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ public class Configuration extends PathPropertyList
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = ProbeMode.valueOf(StringUtils.upperCase(value));
|
result = ProbePeriod.valueOf(StringUtils.upperCase(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -21,7 +21,7 @@ package fr.devinsy.statoolinfos.core;
|
||||||
/**
|
/**
|
||||||
* The Enum LogFilter.
|
* The Enum LogFilter.
|
||||||
*/
|
*/
|
||||||
public enum ProbeMode
|
public enum ProbePeriod
|
||||||
{
|
{
|
||||||
FULL,
|
FULL,
|
||||||
TODAY,
|
TODAY,
|
|
@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Configuration;
|
import fr.devinsy.statoolinfos.core.Configuration;
|
||||||
import fr.devinsy.statoolinfos.core.Factory;
|
import fr.devinsy.statoolinfos.core.Factory;
|
||||||
import fr.devinsy.statoolinfos.core.ProbeMode;
|
import fr.devinsy.statoolinfos.core.ProbePeriod;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
||||||
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogAnalyzer;
|
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogAnalyzer;
|
||||||
|
@ -97,115 +97,125 @@ public class Prober
|
||||||
|
|
||||||
System.out.println("Targets=" + types.toStringWithBrackets());
|
System.out.println("Targets=" + types.toStringWithBrackets());
|
||||||
|
|
||||||
PathCounters counters = new PathCounters();
|
if (configuration.getProbeMode() != null)
|
||||||
|
|
||||||
//
|
|
||||||
if (types.containsAnyIgnoreCase("HttpAccessLog"))
|
|
||||||
{
|
{
|
||||||
logger.info("== Processing HttpAccessLog.");
|
PathCounters counters = new PathCounters();
|
||||||
String source = configuration.getProbeHttpAccessLogSource();
|
|
||||||
String patternRegex = configuration.getProbeHttpAccessLogPattern();
|
|
||||||
logger.info("source=[{}]", source);
|
|
||||||
logger.info("pattern=[{}]", patternRegex);
|
|
||||||
|
|
||||||
PathCounters data = HttpAccessLogAnalyzer.probe(source, patternRegex);
|
//
|
||||||
counters.putAll(data);
|
if (types.containsAnyIgnoreCase("HttpAccessLog"))
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (types.containsAnyIgnoreCase("HttpErrorLog"))
|
|
||||||
{
|
|
||||||
logger.info("== Processing HttpErrorLog.");
|
|
||||||
String source = configuration.getProbeHttpErrorLogSource();
|
|
||||||
logger.info("source=[{}]", source);
|
|
||||||
|
|
||||||
PathCounters data = HttpErrorLogAnalyzer.probe(source);
|
|
||||||
counters.putAll(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (types.containsAnyIgnoreCase("Framadate"))
|
|
||||||
{
|
|
||||||
logger.info("== Processing Framadate.");
|
|
||||||
String source = configuration.getProbeHttpErrorLogSource();
|
|
||||||
logger.info("source=[{}]", source);
|
|
||||||
|
|
||||||
// PathCounters data = HttpErrorLogAnalyzer.probe(source);
|
|
||||||
// counters.putAll(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (types.containsAnyIgnoreCase("Mumble"))
|
|
||||||
{
|
|
||||||
logger.info("== Processing Mumble.");
|
|
||||||
String source = configuration.getProbeHttpErrorLogSource();
|
|
||||||
logger.info("source=[{}]", source);
|
|
||||||
|
|
||||||
// PathCounters data = HttpErrorLogAnalyzer.probe(source);
|
|
||||||
// counters.putAll(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter.
|
|
||||||
logger.info("== Filtering");
|
|
||||||
if (configuration.getProbeMode() == ProbeMode.TODAY)
|
|
||||||
{
|
|
||||||
logger.info("=== TODAY");
|
|
||||||
counters = counters.searchByPeriod(LocalDate.now(), LocalDate.now());
|
|
||||||
}
|
|
||||||
else if (configuration.getProbeMode() == ProbeMode.PREVIOUS_DAY)
|
|
||||||
{
|
|
||||||
logger.info("=== PREVIOUS_DAY");
|
|
||||||
counters = counters.searchByPeriod(LocalDate.now().minusDays(1), LocalDate.now());
|
|
||||||
}
|
|
||||||
else if (configuration.getProbeMode() == ProbeMode.PREVIOUS_DAYS_7)
|
|
||||||
{
|
|
||||||
logger.info("=== PREVIOUS_WEEK");
|
|
||||||
counters = counters.searchByPeriod(LocalDate.now().minusDays(7), LocalDate.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
File target = configuration.getProbeTarget();
|
|
||||||
logger.info("target=[{}]", target);
|
|
||||||
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Undefined target.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (target.exists())
|
|
||||||
{
|
{
|
||||||
logger.info("ModeProbe=" + configuration.getProbeMode());
|
logger.info("== Processing HttpAccessLog.");
|
||||||
if (configuration.getProbeMode() != ProbeMode.FULL)
|
String source = configuration.getProbeHttpAccessLogSource();
|
||||||
{
|
String patternRegex = configuration.getProbeHttpAccessLogPattern();
|
||||||
// Load.
|
logger.info("source=[{}]", source);
|
||||||
logger.info("== Reading previous target file.");
|
logger.info("pattern=[{}]", patternRegex);
|
||||||
PathCounters previousCounters = readMetrics(target);
|
|
||||||
logger.info("previous size={}", previousCounters.size());
|
|
||||||
|
|
||||||
// Merge.
|
PathCounters data = HttpAccessLogAnalyzer.probe(source, patternRegex);
|
||||||
logger.info("== Merging");
|
counters.putAll(data);
|
||||||
for (PathCounter counter : counters.values())
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (types.containsAnyIgnoreCase("HttpErrorLog"))
|
||||||
|
{
|
||||||
|
logger.info("== Processing HttpErrorLog.");
|
||||||
|
String source = configuration.getProbeHttpErrorLogSource();
|
||||||
|
logger.info("source=[{}]", source);
|
||||||
|
|
||||||
|
PathCounters data = HttpErrorLogAnalyzer.probe(source);
|
||||||
|
counters.putAll(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (types.containsAnyIgnoreCase("Framadate"))
|
||||||
|
{
|
||||||
|
logger.info("== Processing Framadate.");
|
||||||
|
String source = configuration.getProbeHttpErrorLogSource();
|
||||||
|
logger.info("source=[{}]", source);
|
||||||
|
|
||||||
|
// PathCounters data = HttpErrorLogAnalyzer.probe(source);
|
||||||
|
// counters.putAll(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (types.containsAnyIgnoreCase("Mumble"))
|
||||||
|
{
|
||||||
|
logger.info("== Processing Mumble.");
|
||||||
|
String source = configuration.getProbeHttpErrorLogSource();
|
||||||
|
logger.info("source=[{}]", source);
|
||||||
|
|
||||||
|
// PathCounters data = HttpErrorLogAnalyzer.probe(source);
|
||||||
|
// counters.putAll(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter.
|
||||||
|
logger.info("== Filtering");
|
||||||
|
if (configuration.getProbeMode() == ProbePeriod.TODAY)
|
||||||
|
{
|
||||||
|
logger.info("=== TODAY");
|
||||||
|
counters = counters.searchByPeriod(LocalDate.now(), LocalDate.now());
|
||||||
|
}
|
||||||
|
else if (configuration.getProbeMode() == ProbePeriod.PREVIOUS_DAY)
|
||||||
|
{
|
||||||
|
logger.info("=== PREVIOUS_DAY");
|
||||||
|
counters = counters.searchByPeriod(LocalDate.now().minusDays(1), LocalDate.now());
|
||||||
|
}
|
||||||
|
else if (configuration.getProbeMode() == ProbePeriod.PREVIOUS_DAYS_7)
|
||||||
|
{
|
||||||
|
logger.info("=== PREVIOUS_WEEK");
|
||||||
|
counters = counters.searchByPeriod(LocalDate.now().minusDays(7), LocalDate.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
File target = configuration.getProbeTarget();
|
||||||
|
logger.info("target=[{}]", target);
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Undefined target.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (target.exists())
|
||||||
|
{
|
||||||
|
logger.info("ModeProbe=" + configuration.getProbeMode());
|
||||||
|
if (configuration.getProbeMode() != ProbePeriod.FULL)
|
||||||
{
|
{
|
||||||
PathCounter previousCounter = previousCounters.get(counter.getPath(), counter.getTimeMark());
|
// Load.
|
||||||
previousCounter.setCounter(counter.getCounter());
|
logger.info("== Reading previous target file.");
|
||||||
|
PathCounters previousCounters = readMetrics(target);
|
||||||
|
logger.info("previous size={}", previousCounters.size());
|
||||||
|
|
||||||
|
// Merge.
|
||||||
|
logger.info("== Merging");
|
||||||
|
for (PathCounter counter : counters.values())
|
||||||
|
{
|
||||||
|
PathCounter previousCounter = previousCounters.get(counter.getPath(), counter.getTimeMark());
|
||||||
|
if (previousCounter == null)
|
||||||
|
{
|
||||||
|
previousCounters.put(counter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
previousCounter.setCounter(counter.getCounter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
counters = previousCounters;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
counters = previousCounters;
|
logger.info("== Backing previous target file.");
|
||||||
|
target.renameTo(new File(target.getParentFile(), target.getName() + ".bak"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
writeMetrics(target, counters);
|
||||||
logger.info("== Backing previous target file.");
|
|
||||||
target.renameTo(new File(target.getParentFile(), target.getName() + ".bak"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writeMetrics(target, counters);
|
//
|
||||||
|
logger.info("== Writing.");
|
||||||
|
logger.info("size={}", counters.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
logger.info("== Writing.");
|
|
||||||
logger.info("size={}", counters.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue