Server lines: add the fullest disk over a week, and lines in the admin table

Each server card shows its fullest disk over the last week under the load and
memory lines (a disk moves too slowly to show in a day), and the Manage
servers table has a Load and disk column with all three side by side.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-12 23:27:40 +01:00
1 parent 4f077d4f4a
commit 168d01dc7b
7 files changed
+103 -25

No files matched your search

Binary file not shown.
+26 -2
View File
@@ -67,7 +67,12 @@ describe("servers", () => {
rows.push({ serverId: a, metric: "cpu", value: 100 - h * 4, recordedAt: hoursAgo(h).toISOString() });
rows.push({ serverId: a, metric: "mem", value: 50, recordedAt: hoursAgo(h).toISOString() });
}
// b: a disk figure only (not one of the lines), and a reading from two days ago (out of the stretch)
// a: two disks over the week — "/" climbing from 50 to 62, "/data" steady at 85 (the fuller one)
for (const d of [6, 5, 4, 3, 2, 1, 0.2]) {
rows.push({ serverId: a, metric: "disk:/", value: 50 + (6 - d) * 2, recordedAt: hoursAgo(d * 24).toISOString() });
rows.push({ serverId: a, metric: "disk:/data", value: 85, recordedAt: hoursAgo(d * 24).toISOString() });
}
// b: a disk figure only (no load or memory), and a reading from two days ago (out of the stretch)
rows.push({ serverId: b, metric: "disk:/", value: 80, recordedAt: hoursAgo(1).toISOString() });
rows.push({ serverId: b, metric: "cpu", value: 99, recordedAt: hoursAgo(48).toISOString() });
await db.insert(serverMetrics).values(rows);
@@ -75,7 +80,9 @@ describe("servers", () => {
test("load and memory over the last day, a slice an hour; a gap is null; others are left out", async () => {
const out = await S.serverSparklines(NOW);
assert.deepEqual(Object.keys(out).map(Number), [a], "b has nothing in the last day that is drawn");
assert.deepEqual(Object.keys(out).map(Number).sort(), [a, b].sort(), "b has only a disk, a has everything");
assert.equal(out[b].cpu, undefined, "b's load was two days ago: not in the last day");
assert.equal(out[b].mem, undefined);
const cpu = out[a].cpu!;
assert.equal(cpu.values.length, S.SLICES);
assert.equal(cpu.values[0], 6, "23.5 hours ago is the first slice: 100 − 94");
@@ -87,6 +94,23 @@ describe("servers", () => {
assert.ok(out[a].mem!.values.every((v) => v === null || v === 50));
});
test("the fullest disk stands for the server, over a week, with its mount", async () => {
const out = await S.serverSparklines(NOW);
const disk = out[a].disk!;
assert.deepEqual([disk.mount, disk.days, disk.latest], ["/data", 7, 85], "/data (85) is fuller than / (62)");
assert.equal(disk.values.length, S.SLICES);
assert.ok(disk.values.filter((v) => v !== null).length >= 6);
assert.deepEqual([out[b].disk!.mount, out[b].disk!.latest], ["/", 80]);
});
test("the fullest is the one that is fullest now; a tie goes to the shorter mount; none is none", () => {
assert.equal(S.fullestDisk([{ mount: "/", latest: 62 }, { mount: "/data", latest: 85 }])!.mount, "/data");
assert.equal(S.fullestDisk([{ mount: "/data", latest: 70 }, { mount: "/", latest: 70 }])!.mount, "/");
assert.equal(S.fullestDisk([{ mount: "/a", latest: null }, { mount: "/b", latest: 10 }])!.mount, "/b");
assert.equal(S.fullestDisk([]), null);
assert.equal(S.fullestDisk([{ mount: "/", latest: null }]), null);
});
test("readings in the same slice are averaged", async () => {
await db.insert(serverMetrics).values([
{ serverId: a, metric: "cpu", value: 10, recordedAt: hoursAgo(10.9).toISOString() },