Initial version of Telegram admin bot
This commit is contained in:
13
docker_watchdog.py
Normal file
13
docker_watchdog.py
Normal file
@@ -0,0 +1,13 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user