diff --git a/.vscode/launch.json b/.vscode/launch.json index 0bb267d..c3af61b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,7 @@ "env": { "METRIC__INTERVAL": "5", "METRIC__LOG__ENABLED": "True", - "METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]", + "METRIC__EXTERNAL__ENABLED": "True", "METRIC__EXTERNAL__EXECUTABLES": "[\"${workspaceFolder}/example/dummy-metric\"]", }, "justMyCode": true diff --git a/kiwi_simple_metrics/metrics/_report.py b/kiwi_simple_metrics/metrics/_report.py index e974ab1..5cf4044 100644 --- a/kiwi_simple_metrics/metrics/_report.py +++ b/kiwi_simple_metrics/metrics/_report.py @@ -102,6 +102,9 @@ class Report: reports = [data.report for data in get_data()] + if not reports: + return None + return cls( result=settings.report_outer.format( name=settings.name, diff --git a/kiwi_simple_metrics/settings/metric.py b/kiwi_simple_metrics/settings/metric.py index d1b5b68..dc597b8 100644 --- a/kiwi_simple_metrics/settings/metric.py +++ b/kiwi_simple_metrics/settings/metric.py @@ -1,8 +1,8 @@ import math from typing import Any, Literal -from pydantic import (BaseModel, DirectoryPath, Field, FieldValidationInfo, - FilePath, field_validator) +from pydantic import (BaseModel, DirectoryPath, FieldValidationInfo, FilePath, + field_validator) class MetricSettings(BaseModel): @@ -81,15 +81,16 @@ class DiskMS(MetricSettings): count: int | None = 1 # paths to check for disk space - paths: list[DirectoryPath] = Field(default_factory=list) + paths: list[DirectoryPath] = [DirectoryPath("/")] class ExternalMS(MetricSettings): name: str = "External Metric" + enabled: bool = False threshold: float = 0 # path to executable files - executables: list[FilePath] = Field(default_factory=list) + executables: list[FilePath] = [] # wait at most this many seconds for each executable timeout: int = 60