From efe1fb924132db67da5b175da603b8e8e41c7904 Mon Sep 17 00:00:00 2001 From: steffen Date: Mon, 15 Jun 2026 20:23:43 +0200 Subject: [PATCH] feat: add docker_container widget type --- ethica-agent.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ethica-agent.py b/ethica-agent.py index 34dcba1..b62f91e 100644 --- a/ethica-agent.py +++ b/ethica-agent.py @@ -285,6 +285,27 @@ def run_widget(w: dict) -> tuple: alive = process_alive(proc) return name, "system", "online" if alive else "offline", None, "", proc + if wtype == "docker_container": + container = w.get("container", "") + if not container: + return name, "container", "unknown", None, "", "no container name" + try: + r = subprocess.run( + ["docker", "inspect", "--format", "{{.State.Status}}", container], + capture_output=True, text=True, timeout=10) + st = r.stdout.strip().lower() + if st == "running": + status = "online" + elif st in ("restarting", "paused"): + status = "degraded" + else: + status = "offline" + except FileNotFoundError: + st, status = "docker not found", "offline" + except subprocess.TimeoutExpired: + st, status = "timeout", "offline" + return name, "container", status, None, "", st + if wtype == "custom_cmd": cmd = w["cmd"] timeout = w.get("timeout", 30)