diff --git a/hbd/server/templates/plugins.html b/hbd/server/templates/plugins.html index 60e7c9e..a6b27e8 100644 --- a/hbd/server/templates/plugins.html +++ b/hbd/server/templates/plugins.html @@ -514,6 +514,9 @@ // pluginCache[hostname][pluginName] = { data, timestamp, fetchedAt } const pluginCache = {}; + // infoCache[hostname] = info data object from /api/0/hosts/{hostname}/info + const infoCache = {}; + function setCache(hostname, pluginName, sample) { if (!pluginCache[hostname]) pluginCache[hostname] = {}; pluginCache[hostname][pluginName] = { @@ -547,6 +550,57 @@ return json.samples?.[0] ?? null; } + async function fetchHostInfo(hostname) { + const r = await fetch(`/api/0/hosts/${encodeURIComponent(hostname)}/info`); + if (!r.ok) throw new Error(`HTTP ${r.status}`); + return await r.json(); + } + + function renderInfoSection(hostname, data) { + const el = document.getElementById(`info-${hostname}`); + if (!el) return; + + const owner = data.owner ? escHtml(data.owner) : '—'; + const managers = data.managers && data.managers.length + ? data.managers.map(escHtml).join(', ') : '—'; + const hbcVer = data.hbc_version ? escHtml(String(data.hbc_version)) : '—'; + const hbcType = data.hbc_type ? escHtml(String(data.hbc_type)) : '—'; + const lastPkt = data.last_packet != null + ? new Date(data.last_packet * 1000).toLocaleString() : '—'; + + let html = `
`; + + if (data.thresholds === null) { + html += `| Metric | Op | Warning | Critical | +
|---|---|---|---|
| ${escHtml(t.metric)} | +${escHtml(t.operator)} | +${w} | +${c} | +