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 = `
+ Owner${owner} + Managers${managers} + Agent Version${hbcVer} + Agent Type${hbcType} + Last Packet${lastPkt} +
`; + + if (data.thresholds === null) { + html += `
Threshold alerting not configured.
`; + } else if (data.thresholds.length === 0) { + html += `
No thresholds defined.
`; + } else { + html += `
Effective Thresholds
+ + + `; + for (const t of data.thresholds) { + const w = t.warning != null ? escHtml(String(t.warning)) : '—'; + const c = t.critical != null ? escHtml(String(t.critical)) : '—'; + html += ` + + + + + `; + } + html += `
MetricOpWarningCritical
${escHtml(t.metric)}${escHtml(t.operator)}${w}${c}
`; + } + + el.innerHTML = html; + } + async function fetchHostGlance(hostname) { const card = document.querySelector(`.host-card[data-hostname="${hostname}"]`); const availablePlugins = (card?.dataset.plugins || '').split(',').filter(Boolean);