mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-12-22 12:33:01 +00:00
dummy-metric and dummy metrics.external
This commit is contained in:
parent
809ef98607
commit
4efd957972
6 changed files with 29 additions and 0 deletions
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
|
@ -13,6 +13,7 @@
|
|||
"METRIC__INTERVAL": "5",
|
||||
"METRIC__LOG__ENABLED": "True",
|
||||
"METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
|
||||
"METRIC__EXTERNAL__EXECUTABLES": "[\"${workspaceFolder}/dummy-metric\"]",
|
||||
},
|
||||
"justMyCode": true
|
||||
}
|
||||
|
|
6
dummy-metric
Executable file
6
dummy-metric
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Dummy"
|
||||
echo "95"
|
||||
echo "normal"
|
||||
awk "BEGIN{srand(); r=rand(); print r * 100}"
|
|
@ -15,6 +15,7 @@ def handle_report() -> None:
|
|||
metrics.cpu(),
|
||||
metrics.memory(),
|
||||
metrics.disk(),
|
||||
metrics.external(),
|
||||
)
|
||||
|
||||
# maybe print this to stdout
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from ._report import Report
|
||||
from .cpu import cpu
|
||||
from .disk import disk
|
||||
from .external import external
|
||||
from .memory import memory
|
||||
|
||||
__all__ = [
|
||||
|
@ -8,5 +9,6 @@ __all__ = [
|
|||
|
||||
"cpu",
|
||||
"disk",
|
||||
"external",
|
||||
"memory",
|
||||
]
|
||||
|
|
18
kiwi_simple_metrics/metrics/external.py
Normal file
18
kiwi_simple_metrics/metrics/external.py
Normal 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,
|
||||
)
|
|
@ -23,6 +23,7 @@ class Settings(BaseSettings):
|
|||
cpu: metric.CpuMS = metric.CpuMS()
|
||||
memory: metric.MemoryMS = metric.MemoryMS()
|
||||
disk: metric.DiskMS = metric.DiskMS()
|
||||
external: metric.ExternalMS = metric.ExternalMS()
|
||||
|
||||
# pinging webhooks
|
||||
webhook: misc.WebhookSettings = misc.WebhookSettings()
|
||||
|
|
Loading…
Reference in a new issue