Add selftest scheduler, queue history, and OpenWrt signal stats
This commit is contained in:
@@ -19,12 +19,14 @@ from services.runner import run_cmd
|
||||
from services.npmplus import fetch_certificates, format_certificates, list_proxy_hosts, set_proxy_host
|
||||
from services.gitea import get_gitea_health
|
||||
from services.openwrt import get_openwrt_status
|
||||
from services.system import worst_disk_usage
|
||||
import state
|
||||
from state import UPDATES_CACHE, REBOOT_PENDING
|
||||
from services.metrics import summarize
|
||||
from services.audit import read_audit_tail
|
||||
from services.incidents import read_recent, incidents_path
|
||||
from services.external_checks import format_report
|
||||
from services.disk_report import build_disk_report
|
||||
|
||||
|
||||
@dp.message(F.text == "💽 Disks")
|
||||
@@ -308,6 +310,48 @@ async def incidents(msg: Message):
|
||||
await msg.answer(text, reply_markup=system_logs_audit_kb, parse_mode="Markdown")
|
||||
|
||||
|
||||
@dp.message(F.text == "/incidents_summary")
|
||||
async def incidents_summary(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
return
|
||||
last_24h = read_recent(cfg, hours=24, limit=2000)
|
||||
last_7d = read_recent(cfg, hours=24 * 7, limit=4000)
|
||||
|
||||
def count(lines):
|
||||
import re
|
||||
total = len(lines)
|
||||
cats = {}
|
||||
for line in lines:
|
||||
m = re.search(r"category=([A-Za-z0-9_-]+)", line)
|
||||
if m:
|
||||
cats[m.group(1)] = cats.get(m.group(1), 0) + 1
|
||||
top = ", ".join(f"{k}:{v}" for k, v in sorted(cats.items(), key=lambda x: x[1], reverse=True)[:5]) or "n/a"
|
||||
return total, top
|
||||
|
||||
t24, top24 = count(last_24h)
|
||||
t7, top7 = count(last_7d)
|
||||
text = (
|
||||
"📣 Incidents summary\n\n"
|
||||
f"24h: {t24} (top: {top24})\n"
|
||||
f"7d: {t7} (top: {top7})"
|
||||
)
|
||||
await msg.answer(text, reply_markup=system_logs_audit_kb)
|
||||
|
||||
|
||||
@dp.message(F.text == "/disk_snapshot")
|
||||
async def disk_snapshot(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
return
|
||||
usage, mount = worst_disk_usage()
|
||||
mount = mount or "/"
|
||||
try:
|
||||
report = await build_disk_report(cfg, mount, usage or 0)
|
||||
except Exception as e:
|
||||
await msg.answer(f"⚠️ Disk snapshot error: {e}")
|
||||
return
|
||||
await msg.answer(f"💽 Disk snapshot ({mount})\n\n{report}", reply_markup=system_info_kb)
|
||||
|
||||
|
||||
@dp.message(F.text == "🔒 SSL")
|
||||
async def ssl_certs(msg: Message):
|
||||
if not is_admin_msg(msg):
|
||||
|
||||
Reference in New Issue
Block a user