dummy-metric and dummy metrics.external

This commit is contained in:
Jörn-Michael Miehe 2023-09-01 14:57:06 +00:00
parent 809ef98607
commit 4efd957972
6 changed files with 29 additions and 0 deletions

1
.vscode/launch.json vendored
View file

@ -13,6 +13,7 @@
"METRIC__INTERVAL": "5", "METRIC__INTERVAL": "5",
"METRIC__LOG__ENABLED": "True", "METRIC__LOG__ENABLED": "True",
"METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]", "METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
"METRIC__EXTERNAL__EXECUTABLES": "[\"${workspaceFolder}/dummy-metric\"]",
}, },
"justMyCode": true "justMyCode": true
} }

6
dummy-metric Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
echo "Dummy"
echo "95"
echo "normal"
awk "BEGIN{srand(); r=rand(); print r * 100}"

View file

@ -15,6 +15,7 @@ def handle_report() -> None:
metrics.cpu(), metrics.cpu(),
metrics.memory(), metrics.memory(),
metrics.disk(), metrics.disk(),
metrics.external(),
) )
# maybe print this to stdout # maybe print this to stdout

View file

@ -1,6 +1,7 @@
from ._report import Report from ._report import Report
from .cpu import cpu from .cpu import cpu
from .disk import disk from .disk import disk
from .external import external
from .memory import memory from .memory import memory
__all__ = [ __all__ = [
@ -8,5 +9,6 @@ __all__ = [
"cpu", "cpu",
"disk", "disk",
"external",
"memory", "memory",
] ]

View file

@ -0,0 +1,18 @@
from typing import Iterator
from ..settings import SETTINGS
from ._report import Report, ReportData
def _hwdata() -> Iterator[ReportData]:
yield ReportData(
name="Foo",
value=69.42,
)
def external() -> Report | None:
return Report.aggregate(
settings=SETTINGS.external,
get_data=_hwdata,
)

View file

@ -23,6 +23,7 @@ class Settings(BaseSettings):
cpu: metric.CpuMS = metric.CpuMS() cpu: metric.CpuMS = metric.CpuMS()
memory: metric.MemoryMS = metric.MemoryMS() memory: metric.MemoryMS = metric.MemoryMS()
disk: metric.DiskMS = metric.DiskMS() disk: metric.DiskMS = metric.DiskMS()
external: metric.ExternalMS = metric.ExternalMS()
# pinging webhooks # pinging webhooks
webhook: misc.WebhookSettings = misc.WebhookSettings() webhook: misc.WebhookSettings = misc.WebhookSettings()