Add incidents export, queue alerts, and health summaries
This commit is contained in:
@@ -124,6 +124,37 @@ async def docker_health(msg: Message):
|
||||
log_incident(cfg, f"docker_health alias={alias} by {msg.from_user.id}", category="docker")
|
||||
|
||||
|
||||
@dp.message(F.text == "/docker_health_summary")
|
||||
async def docker_health_summary(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
return
|
||||
if not DOCKER_MAP:
|
||||
await msg.answer("⚠️ DOCKER_MAP пуст", reply_markup=docker_kb)
|
||||
return
|
||||
problems = []
|
||||
total = len(DOCKER_MAP)
|
||||
for alias, real in DOCKER_MAP.items():
|
||||
rc, out = await docker_cmd(["inspect", "-f", "{{json .State}}", real], timeout=10)
|
||||
if rc != 0:
|
||||
problems.append(f"{alias}: inspect error")
|
||||
continue
|
||||
try:
|
||||
state = json.loads(out)
|
||||
except Exception:
|
||||
problems.append(f"{alias}: bad JSON")
|
||||
continue
|
||||
status = state.get("Status", "n/a")
|
||||
health = (state.get("Health") or {}).get("Status", "n/a")
|
||||
if status != "running" or health not in ("healthy", "none"):
|
||||
problems.append(f"{alias}: {status}/{health}")
|
||||
ok = total - len(problems)
|
||||
lines = [f"🐳 Docker health: 🟢 {ok}/{total} healthy, 🔴 {len(problems)} issues"]
|
||||
if problems:
|
||||
lines.append("Problems:")
|
||||
lines.extend([f"- {p}" for p in problems])
|
||||
await msg.answer("\n".join(lines), reply_markup=docker_kb)
|
||||
|
||||
|
||||
@dp.message(F.text == "📈 Stats")
|
||||
async def dstats(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
|
||||
Reference in New Issue
Block a user