Add homelab_server_boot_time_seconds to /metrics
When each agent-reported server last started (last report minus uptime), so uptime is time() - the metric and a reboot shows as it moving. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41fbbf3467
commit
48aea747bc
3 files changed
+8
No files matched your search
@@ -509,6 +509,8 @@ export async function buildMetrics(now: Date = new Date()): Promise<string> {
|
||||
const seen = Date.parse(s.lastSeenAt);
|
||||
out.add("homelab_server_up", "gauge", "1 if the server's agent has reported within the offline threshold, else 0.", now.getTime() - seen <= offlineAfterMs ? 1 : 0, { server });
|
||||
out.add("homelab_server_last_seen_timestamp_seconds", "gauge", "When the server's agent last reported, as a Unix time.", Math.floor(seen / 1000), { server });
|
||||
// As node_exporter does: when it started, not how long ago, so the figure holds still between reports (uptime is time() - this) and a reboot shows as it moving.
|
||||
if (s.uptimeSeconds !== null) out.add("homelab_server_boot_time_seconds", "gauge", "When the server last started, as a Unix time (from the uptime its agent reports); uptime is time() minus this.", Math.floor(seen / 1000) - s.uptimeSeconds, { server });
|
||||
if (s.cpuLoadPercent !== null) out.add("homelab_server_cpu_load_percent", "gauge", "CPU load as the agent reports it.", s.cpuLoadPercent, { server });
|
||||
if (s.memTotalBytes && s.memUsedBytes !== null) out.add("homelab_server_memory_used_percent", "gauge", "Memory in use.", (s.memUsedBytes / s.memTotalBytes) * 100, { server });
|
||||
let disks: { mount: string; sizeBytes: number; usedBytes: number }[] = [];
|
||||
|
||||
Reference in new issue
Block a user