Add alert tools, mutes, short status, and backup summary
This commit is contained in:
@@ -76,6 +76,45 @@ async def st(msg: Message):
|
||||
await cmd_status(msg)
|
||||
|
||||
|
||||
@dp.message(F.text == "/status_short")
|
||||
async def st_short(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
return
|
||||
now = time.time()
|
||||
uptime_sec = int(now - psutil.boot_time())
|
||||
days, rem = divmod(uptime_sec, 86400)
|
||||
hours, rem = divmod(rem, 3600)
|
||||
minutes, _ = divmod(rem, 60)
|
||||
load1, load5, load15 = psutil.getloadavg()
|
||||
mem = psutil.virtual_memory()
|
||||
disks = format_disks().splitlines()
|
||||
disk_line = disks[1] if len(disks) > 1 else "Disks: n/a"
|
||||
await msg.answer(
|
||||
"📋 **Status (short)**\n"
|
||||
f"🖥 `{socket.gethostname()}`\n"
|
||||
f"⏱ Uptime: {days}d {hours}h {minutes}m\n"
|
||||
f"⚙️ Load: {load1:.2f} {load5:.2f} {load15:.2f}\n"
|
||||
f"🧠 RAM: {mem.percent}% ({mem.used // (1024**3)} / {mem.total // (1024**3)} GiB)\n"
|
||||
f"💾 {disk_line}",
|
||||
reply_markup=menu_kb,
|
||||
parse_mode="Markdown",
|
||||
)
|
||||
|
||||
|
||||
@dp.message(F.text == "/health_short")
|
||||
async def health_short(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
return
|
||||
try:
|
||||
text = await asyncio.to_thread(health, cfg, DOCKER_MAP)
|
||||
except Exception as e:
|
||||
await msg.answer(f"❌ Health failed: {type(e).__name__}: {e}", reply_markup=menu_kb)
|
||||
return
|
||||
lines = [ln for ln in text.splitlines() if ln.strip()]
|
||||
brief = " | ".join(lines[1:5]) if len(lines) > 1 else text
|
||||
await msg.answer(f"🩺 Health (short)\n{brief}", reply_markup=menu_kb)
|
||||
|
||||
|
||||
def _rate_str(value: float) -> str:
|
||||
if value >= 1024 * 1024:
|
||||
return f"{value / (1024 * 1024):.2f} MiB/s"
|
||||
|
||||
Reference in New Issue
Block a user