Speedtest Tracker, Costs, "Having trouble" on status pages, grouped Integrations and Dashboard
- Speedtest Tracker integration: charts, alerts for a slow line (median of the last three tests under a share of what is paid for) and for failing tests. - Costs page (Records): things paid for by hand plus Hetzner's estimate, totals per currency, bills rolled forward into Coming up as Renewals. - Status pages: a "Having trouble" state for things that answer but have an open alert; Speedtest reads as the internet. - Integrations page and kind picker grouped like the sidebar (one shared types file); Notifications "What to send" shown one group at a time; Dashboard integration sections follow the menu groups, with tiles for integrations that have no widget. - Docs, tests, and ROLES.md menu table brought up to date. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78822346b1
commit
f86661f6c9
49 files changed
+18156
-238
No files matched your search
@@ -12,6 +12,7 @@ import { backupState, listAll as listDuplicati } from "./duplicati.js";
|
||||
import { isJellyfinFresh, jellyfinSyncStatuses, streamsOf } from "./jellyfinSync.js";
|
||||
import { isNextcloudFresh, nextcloudSyncStatuses } from "./nextcloudSync.js";
|
||||
import { dockerVulnSyncStatuses, isDockerVulnFresh } from "./dockerVulnSync.js";
|
||||
import { isSpeedtestFresh, recentResults as recentSpeedtestResults, speedtestSyncStatuses } from "./speedtestSync.js";
|
||||
import { costOf as hetznerCostOf, hetznerSyncStatuses, isHetznerFresh, serversOf as hetznerServersOf } from "./hetznerSync.js";
|
||||
import { isNetBoxFresh, netboxSyncStatuses } from "./netboxSync.js";
|
||||
import { isN8nFresh, n8nSyncStatuses, workflowsOf as n8nWorkflowsOf } from "./n8nSync.js";
|
||||
@@ -85,6 +86,20 @@ async function addNextcloudMetrics(out: Exposition, now: Date) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Each Speedtest Tracker, for /metrics: its newest completed test — download and upload in bits per second, ping in seconds. Only while the reading is recent. */
|
||||
async function addSpeedtestMetrics(out: Exposition, now: Date) {
|
||||
const statuses = await speedtestSyncStatuses();
|
||||
for (const row of await db.select({ id: integrations.id, name: integrations.name }).from(integrations).where(and(eq(integrations.type, "speedtest"), eq(integrations.enabled, true)))) {
|
||||
if (!isSpeedtestFresh(statuses[row.id], now.getTime())) continue;
|
||||
const latest = (await recentSpeedtestResults(row.id, 20)).find((r) => r.status === "completed");
|
||||
if (!latest) continue;
|
||||
const labels = { name: row.name };
|
||||
if (latest.downloadBps !== null) out.add("homelab_speedtest_download_bits_per_second", "gauge", "Download speed of the newest completed speed test, in bits per second.", latest.downloadBps, labels);
|
||||
if (latest.uploadBps !== null) out.add("homelab_speedtest_upload_bits_per_second", "gauge", "Upload speed of the newest completed speed test, in bits per second.", latest.uploadBps, labels);
|
||||
if (latest.pingMs !== null) out.add("homelab_speedtest_ping_seconds", "gauge", "Ping of the newest completed speed test, in seconds.", latest.pingMs / 1000, labels);
|
||||
}
|
||||
}
|
||||
|
||||
/** Each Hetzner Cloud server, for /metrics: whether it is running, its traffic this month against the quota, and the project's monthly cost estimate. Only while the reading is recent. */
|
||||
async function addHetznerMetrics(out: Exposition, now: Date) {
|
||||
const statuses = await hetznerSyncStatuses();
|
||||
@@ -426,6 +441,7 @@ export async function buildMetrics(now: Date = new Date()): Promise<string> {
|
||||
await addNextcloudMetrics(out, now);
|
||||
await addDockerVulnMetrics(out, now);
|
||||
await addHetznerMetrics(out, now);
|
||||
await addSpeedtestMetrics(out, now);
|
||||
await addHeartbeatMetrics(out, now);
|
||||
return out.toString();
|
||||
}
|
||||
Reference in new issue
Block a user