Add alert tools, mutes, short status, and backup summary
This commit is contained in:
33
services/config_check.py
Normal file
33
services/config_check.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
from typing import Any, Tuple, List
|
||||
|
||||
|
||||
def validate_cfg(cfg: dict[str, Any]) -> Tuple[List[str], List[str]]:
|
||||
errors: List[str] = []
|
||||
warnings: List[str] = []
|
||||
|
||||
tg = cfg.get("telegram", {})
|
||||
if not tg.get("token"):
|
||||
errors.append("telegram.token is missing")
|
||||
if not tg.get("admin_id"):
|
||||
errors.append("telegram.admin_id is missing")
|
||||
|
||||
thresholds = cfg.get("thresholds", {})
|
||||
for key in ("disk_warn", "load_warn", "high_load_warn"):
|
||||
if key not in thresholds:
|
||||
warnings.append(f"thresholds.{key} not set")
|
||||
|
||||
paths = cfg.get("paths", {})
|
||||
env_path = paths.get("restic_env")
|
||||
if env_path and not os.path.exists(env_path):
|
||||
warnings.append(f"paths.restic_env not found: {env_path}")
|
||||
|
||||
npm = cfg.get("npmplus", {})
|
||||
if npm and not npm.get("token") and (not npm.get("identity") or not npm.get("secret")):
|
||||
warnings.append("npmplus: token missing and identity/secret missing")
|
||||
|
||||
ow = cfg.get("openwrt", {})
|
||||
if ow and not ow.get("host"):
|
||||
warnings.append("openwrt.host is missing")
|
||||
|
||||
return errors, warnings
|
||||
Reference in New Issue
Block a user