From 953da6d51141f62e1536c3d6bc9ef48f9bad8734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:02:54 +0000 Subject: [PATCH] disk_metric reporting --- kiwi_simple_metrics/metrics.py | 17 ++++++++++++++--- kiwi_simple_metrics/settings.py | 6 ++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/kiwi_simple_metrics/metrics.py b/kiwi_simple_metrics/metrics.py index 9a78e96..85e3432 100644 --- a/kiwi_simple_metrics/metrics.py +++ b/kiwi_simple_metrics/metrics.py @@ -64,7 +64,18 @@ def disk_metric() -> Report | None: value=percent, ) for path, percent in data] - return Report( - ", ".join(report.result for report in reports), - failed=any(report.failed for report in reports), + report_inner = ", ".join( + report.result + for report in reports[:SETTINGS.disk.count] + ) + + return Report( + SETTINGS.disk.report_outer.format( + name="DISK FREE", + inner=report_inner, + ), + failed=any( + report.failed + for report in reports + ), ) diff --git a/kiwi_simple_metrics/settings.py b/kiwi_simple_metrics/settings.py index 260679c..8852d95 100644 --- a/kiwi_simple_metrics/settings.py +++ b/kiwi_simple_metrics/settings.py @@ -19,9 +19,15 @@ class MetricSettings(BaseModel): class DiskMS(MetricSettings): + # outer format string for reporting + report_outer: str = "{name}: [{inner}]" + # paths to check for disk space paths: list[DirectoryPath] = Field(default_factory=list) + # include only `count` many of the paths with the least free space + count: int = 1 + class Settings(BaseSettings): model_config = SettingsConfigDict(