Add audit logging with weekly rotation

This commit is contained in:
2026-02-08 00:54:29 +03:00
parent 61236b9d60
commit a221393858
5 changed files with 137 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ from services.npmplus import fetch_certificates, format_certificates
import state
from state import UPDATES_CACHE, REBOOT_PENDING
from services.metrics import summarize
from services.audit import read_audit_tail
@dp.message(F.text == "💽 Disks")
@@ -68,6 +69,17 @@ async def metrics(msg: Message):
await msg.answer(summarize(state.METRICS_STORE, minutes=15), reply_markup=system_kb)
@dp.message(F.text == "🧾 Audit")
async def audit_log(msg: Message):
if not is_admin_msg(msg):
return
text = read_audit_tail(cfg, limit=200)
if text.startswith("⚠️") or text.startswith(""):
await msg.answer(text, reply_markup=system_kb)
else:
await msg.answer(text, reply_markup=system_kb, parse_mode="Markdown")
@dp.message(F.text == "🔒 SSL")
async def ssl_certs(msg: Message):
if not is_admin_msg(msg):