Renamed metrics.service.files metric and added auto-fix.

This commit is contained in:
Christian P. MOMON 2022-02-19 14:29:24 +01:00
parent e24c7ad2aa
commit d017781858
7 changed files with 42 additions and 7 deletions

View file

@ -77,7 +77,7 @@ public class FederationMetricGenericPage
FederationMetricHtmlizer.htmlize(data, "graphic.accounts.active", federation, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.database.bytes", federation, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.files.bytes", federation, view, period, "metrics.service.files.bytes", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", federation, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();

View file

@ -77,7 +77,7 @@ public class OrganizationMetricGenericPage
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts", organization, view, period, "metrics.service.accounts", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts.active", organization, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.database.bytes", organization, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.files.bytes", organization, view, period, "metrics.service.files.bytes", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", organization, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();

View file

@ -78,7 +78,7 @@ public class ServiceMetricGenericPage
ServiceMetricHtmlizer.htmlize(data, "graphic.accounts.active", service, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.database.bytes", service, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.files.bytes", service, view, period, "metrics.service.files.bytes", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", service, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN);
// metrics.moderation.accounts.reported.* =
// metrics.moderation.accounts.sanctioned.* =

View file

@ -24,7 +24,7 @@
<h2>Données</h2>
<div id="graphic.database.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.files.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.datafiles.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
</div>
</body>

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.
*
@ -414,6 +414,38 @@ public class PathCounters extends HashMap<String, PathCounter>
}
}
/**
* Rename path.
*
* @param oldPath
* the old path
* @param newPath
* the new path
* @return the long
*/
public long renamePath(final String oldPath, final String newPath)
{
long result;
result = 0;
for (String key : new StringList(this.keySet()))
{
if (key.startsWith(oldPath))
{
result += 1;
PathCounter counter = get(key);
counter.setPath(counter.getPath().replace(oldPath, newPath));
remove(key);
put(counter);
System.out.println("Renamed " + key + " to " + counter.getPath());
}
}
//
return result;
}
/**
* Search by date.
*

View file

@ -243,6 +243,9 @@ public class Prober
PathCounters previousCounters = readMetrics(target);
logger.info("previous size={}", previousCounters.size());
// Temporary fixed 2022-02.
previousCounters.renamePath("metrics.service.files", "metrics.service.datafiles");
// Merge.
logger.info("== Merging");
for (PathCounter counter : counters.values())

View file

@ -90,11 +90,11 @@ public class DatafilesProber
// metrics.service.datafiles.bytes
long size = FileUtils.sizeOfDirectory(directory);
result.set(size, prefix + ".files.bytes", timemarks);
result.set(size, prefix + ".datafiles.bytes", timemarks);
// metrics.service.datafiles.count
long count = FilesUtils.listRecursively(directory.getAbsoluteFile()).size();
result.set(count, prefix + ".files.count", timemarks);
result.set(count, prefix + ".datafiles.count", timemarks);
}
else
{