feat: add docker_container widget type

This commit is contained in:
2026-06-15 20:23:43 +02:00
parent dee78c3c08
commit efe1fb9241
+21
View File
@@ -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)