14 lines
479 B
Python
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)
|