feat(telemetry): add canonical VPS host monitoring
This commit is contained in:
@@ -68,6 +68,33 @@ test("accepts synthetic discovery and durable message results over Core-initiate
|
||||
}
|
||||
});
|
||||
|
||||
test("delivers a normalized host observation over the existing pinned mTLS channel", async () => {
|
||||
const recorded = [];
|
||||
const pair = await startPair({
|
||||
recordHostTelemetry: async (snapshot, context) => {
|
||||
recorded.push({ snapshot, context });
|
||||
return { status: "recorded" };
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const observation = hostTelemetrySnapshot();
|
||||
assert.deepEqual(await pair.edge.submitHostTelemetry(observation), {
|
||||
status: "recorded",
|
||||
});
|
||||
assert.equal(recorded.length, 1);
|
||||
assert.equal(recorded[0].snapshot.hostKey, "robot2b-b2-edge-vps");
|
||||
assert.equal(
|
||||
recorded[0].context.authenticatedEdgeRef,
|
||||
"edge:pilot-1",
|
||||
);
|
||||
assert.equal(pair.edge.status().eventsAccepted, 1);
|
||||
assert.equal(pair.core.status().eventsAccepted, 1);
|
||||
} finally {
|
||||
await stopPair(pair);
|
||||
}
|
||||
});
|
||||
|
||||
test("recovers the claimed device from telemetry after a Core restart and completes a typed command", async () => {
|
||||
const commandRef = "command:11111111-1111-4111-8111-111111111111";
|
||||
const deviceRef = "device:22222222-2222-4222-8222-222222222222";
|
||||
@@ -547,9 +574,61 @@ function createCoreClient(options) {
|
||||
commandTransport: options.commandTransport,
|
||||
offerCommand: options.offerCommand,
|
||||
recordCommandStatus: options.recordCommandStatus,
|
||||
recordHostTelemetry: options.recordHostTelemetry,
|
||||
});
|
||||
}
|
||||
|
||||
function hostTelemetrySnapshot() {
|
||||
return {
|
||||
schemaVersion: "nodedc.infrastructure.host-telemetry.v1",
|
||||
profile: "linux-host-telegraf-v1",
|
||||
hostKey: "robot2b-b2-edge-vps",
|
||||
observedAt: new Date().toISOString(),
|
||||
source: {
|
||||
agent: "telegraf",
|
||||
agentVersion: "1.38.4",
|
||||
collectorRef: "service:nodedc-host-telemetry-agent",
|
||||
},
|
||||
hardware: {
|
||||
hostname: "koffyvngij",
|
||||
architecture: "x64",
|
||||
platform: "linux",
|
||||
kernelRelease: "6.8.0",
|
||||
cpuModel: "KVM CPU",
|
||||
logicalProcessors: 1,
|
||||
},
|
||||
cpu: { usagePercent: 20, load1: 0.2, load5: 0.1, load15: 0.05 },
|
||||
memory: {
|
||||
totalBytes: 1024,
|
||||
availableBytes: 700,
|
||||
freeBytes: null,
|
||||
usedBytes: 324,
|
||||
usedPercent: 31.6,
|
||||
},
|
||||
swap: {
|
||||
totalBytes: 0,
|
||||
availableBytes: null,
|
||||
freeBytes: 0,
|
||||
usedBytes: 0,
|
||||
usedPercent: 0,
|
||||
},
|
||||
system: {
|
||||
uptimeSeconds: 100,
|
||||
users: 1,
|
||||
processes: {
|
||||
total: 10,
|
||||
running: 1,
|
||||
sleeping: 9,
|
||||
blocked: 0,
|
||||
zombies: 0,
|
||||
},
|
||||
},
|
||||
disks: [],
|
||||
network: [],
|
||||
services: [],
|
||||
};
|
||||
}
|
||||
|
||||
function productionDiscoveryObserver() {
|
||||
return createDeviceGatewayIngest({
|
||||
identifierPepper: "test-only-device-edge-channel-identifier-pepper",
|
||||
|
||||
Reference in New Issue
Block a user