Lesender Selbsttest (Version, Services, Hosts, Downtimes) beim Start und täglich 04:00, Seite /selftest, Teilcheck checkmk_api in /health, Chat-Meldung bei Wechsel. Toleranter Antwort-Parser (value/members, state_type int/String), Fallbacks für Host-Abfrage und Downtime-Liste, Fehlerhinweise je HTTP-Status. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
32 lines
727 B
Python
32 lines
727 B
Python
from dataclasses import dataclass, field
|
|
|
|
from .constants import STATUS_DEVIATED, STATUS_FAILED, STATUS_OK
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class CheckResult:
|
|
name: str
|
|
status: str
|
|
text: str
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SelftestRun:
|
|
ts: int
|
|
version: str
|
|
checks: list[CheckResult] = field(default_factory=list)
|
|
version_changed: bool = False
|
|
|
|
@property
|
|
def ok(self) -> bool:
|
|
return self.overall_status == STATUS_OK
|
|
|
|
@property
|
|
def overall_status(self) -> str:
|
|
statuses = {c.status for c in self.checks}
|
|
if STATUS_FAILED in statuses:
|
|
return STATUS_FAILED
|
|
if STATUS_DEVIATED in statuses:
|
|
return STATUS_DEVIATED
|
|
return STATUS_OK
|