From c80a557972da5941386abe3b3642531a2b9b0bb3 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Thu, 1 Dec 2022 08:31:32 +0100 Subject: [PATCH] Make statistics file rolling --- .../src/org/argeo/slc/systemd/dbus/ServiceStatistics.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/ServiceStatistics.java b/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/ServiceStatistics.java index 787655e7f..b40ba232b 100644 --- a/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/ServiceStatistics.java +++ b/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/ServiceStatistics.java @@ -128,8 +128,10 @@ public class ServiceStatistics { while (manager != null) { synchronized (this) { - String dateSuffix = Instant.ofEpochMilli(begin).atOffset(ZoneOffset.UTC) - .format(DateTimeFormatter.ISO_LOCAL_DATE) + "-" + begin; + // We change the prefix in order to have a file per day + // but keep the begin timestamp in order to identify restarts + String dateSuffix = Instant.now().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_LOCAL_DATE) + + "-" + begin; Path statisticsPath = basePath.resolve("statistics-" + unitName + "-" + dateSuffix + ".csv"); boolean writeHeader = !Files.exists(statisticsPath); -- 2.30.2