Files
tg-admin-bot/docker_watchdog.py
2026-02-07 21:34:24 +03:00

14 lines
479 B
Python

import asyncio, subprocess
async def docker_watchdog(cfg, notify, bot, chat_id):
last = {}
while True:
for alias, real in cfg["docker"]["containers"].items():
state = subprocess.getoutput(
f"docker inspect -f '{{{{.State.Status}}}}' {real}"
)
if last.get(alias) != state:
await notify(bot, chat_id, f"🐳 {alias}: {state}")
last[alias] = state
await asyncio.sleep(120)