refactor monitor, add threshold rtesting

This commit is contained in:
Andreas Wrede
2026-03-31 12:22:03 -04:00
parent ad7178ebcb
commit dd23d9d163
15 changed files with 488 additions and 101 deletions
+4 -4
View File
@@ -8,6 +8,7 @@ import os
import logging
from aiohttp import web
import jinja2
from . import data
logger = logging.getLogger(__name__)
@@ -22,7 +23,6 @@ async def start(
port: int,
config,
hbdclass,
msgs_getter,
log=None,
email=None,
pushmsg=None,
@@ -52,7 +52,7 @@ async def start(
res.append('<body BGCOLOR = "#FFFFFF" LINK = "#008000" VLINK = "#008000">')
res.append(f"<H2>Heartbeat status {VER}</h2>")
res += hbdclass.ubHost.buildhosttable()
res += hbdclass.ubHost.buildmsgtable(msgs_getter())
res += hbdclass.ubHost.buildmsgtable(data.msgs)
res.append(
"<p> %s (%s)</p>"
% (
@@ -69,7 +69,7 @@ async def start(
return web.json_response(json.loads("[" + ",".join(lst) + "]"))
async def api_messages(request):
lst = msgs_getter()[-30:]
lst = data.msgs[-30:]
return web.json_response(lst)
async def cmd(request):
@@ -155,7 +155,7 @@ async def start(
hosts=[
hbdclass.Host.hosts[h].stateinfo() for h in sorted(hbdclass.Host.hosts)
],
messages=msgs_getter()[-30:],
messages=data.msgs[-30:],
)
return web.Response(text=body, content_type="text/html")