From e8b479f3869a92cabdf65464aecd2f0c0385a3a9 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 22 May 2021 01:38:55 +0200 Subject: [PATCH] Step in metrics charts feature. --- src/fr/devinsy/statoolinfos/core/Factory.java | 6 ++ src/fr/devinsy/statoolinfos/core/Service.java | 7 +- .../htmlize/PropertyFileCheckPage.java | 2 +- .../statoolinfos/htmlize/ServicePage.java | 68 ++++++++++++++++++- .../htmlize/charts/BarMonthsChartView.java | 2 +- .../statoolinfos/metrics/http/HttpStatus.java | 1 - 6 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Factory.java b/src/fr/devinsy/statoolinfos/core/Factory.java index dff5582..5c656f0 100644 --- a/src/fr/devinsy/statoolinfos/core/Factory.java +++ b/src/fr/devinsy/statoolinfos/core/Factory.java @@ -393,6 +393,12 @@ public class Factory CrawlJournal journal = cache.restoreJournal(); result.getCrawlJournal().add(journal.getByUrl(inputURL)); result.getCrawlJournal().addAll(journal.searchByParent(result.getInputURL())); + + // + for (Metrics metrics : result.getMetrics()) + { + result.addAll(metrics.getByPrefix("metrics.")); + } } // diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index f80075a..782ab49 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -39,6 +39,7 @@ import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperty; import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.strings.StringList; +import fr.devinsy.strings.StringSet; /** * The Class Service. @@ -506,7 +507,7 @@ public class Service extends PathPropertyList { StringList result; - result = new StringList(); + StringSet years = new StringSet(); Pattern pattern = Pattern.compile("^" + path + "\\.(?\\d{4}).*$"); @@ -518,11 +519,13 @@ public class Service extends PathPropertyList { if (matcher.start("year") != -1) { - result.add(matcher.group("year")); + years.add(matcher.group("year")); } } } + result = new StringList(years); + // return result; } diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java index 3a6212e..bd91a23 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java @@ -87,7 +87,7 @@ public class PropertyFileCheckPage for (Service service : organization.getServices()) { - checks = service.getInputChecksAll(); + checks = service.getInputChecks(); page = htmlize("Service", checks); FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index b1620c6..c1372c1 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -253,7 +253,7 @@ public class ServicePage // data.setContent("fooChart", graphicIndex++, // LineMonthsChartView.build()); - service.getPrefixes(); + // service.getPrefixes(); Metric metric = service.getMetric("metrics.http.hits"); if ((metric != null) && (!metric.isEmpty())) @@ -267,6 +267,72 @@ public class ServicePage data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.RED)); } + metric = service.getMetric("metrics.http.errors.php"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.RED)); + } + + metric = service.getMetric("metrics.http.hits.ipv4"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.hits.ipv6"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.hits.bots"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.files"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.pages"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.bytes"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.ip"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.ip.ipv4"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.BLUE)); + } + + metric = service.getMetric("metrics.http.ip.ipv6"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.RED)); + } + + metric = service.getMetric("metrics.http.visits"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.RED)); + } + // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java index b644252..07f2b6e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java @@ -69,7 +69,7 @@ public class BarMonthsChartView String result; LocalDate start = LocalDate.parse(metric.getStartYear() + "-01-01"); - LocalDate end = start.plusMonths(metric.getMonthValues().size()); + LocalDate end = start.plusMonths(metric.getMonthValues().size() - 1); StringList labels = ChabuUtils.buildYearMonthAlphaLabels(start, end); result = build(metric.getName(), metric.getDescription(), labels, metric.getMonthValues(), color); diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpStatus.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpStatus.java index db6bb4b..207c954 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpStatus.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpStatus.java @@ -83,5 +83,4 @@ public class HttpStatus { this.message = message; } - }