Add procfs memory and mount-aware disk collectors, Intel and AMD GPU backends, bounded Intel sampling, portable validation tools, and Linux setup documentation. Bump to 0.2.0 and verify on Windows and Ubuntu 24.04 under WSL2.
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict"
|
|
import { monitor } from "../dist/metrics.js"
|
|
import { report } from "../dist/format.js"
|
|
|
|
const snapshot = await monitor.snapshot()
|
|
console.log(report(snapshot))
|
|
assert.ok(snapshot.cpu.percent !== null && snapshot.cpu.percent >= 0 && snapshot.cpu.percent <= 100)
|
|
assert.ok(snapshot.ram.total > 0 && snapshot.ram.used <= snapshot.ram.total)
|
|
assert.ok(snapshot.disks.items.length > 0, snapshot.disks.error ?? "No disks")
|
|
for (const disk of snapshot.disks.items) {
|
|
assert.ok(disk.free >= 0 && disk.used >= 0 && disk.reserved >= 0)
|
|
assert.equal(disk.free + disk.used + disk.reserved, disk.total)
|
|
}
|
|
if (process.argv.includes("--require-gpu")) {
|
|
assert.equal(snapshot.gpu.error, null)
|
|
assert.ok(snapshot.gpu.adapter?.percent !== null && snapshot.gpu.adapter)
|
|
}
|
|
if (snapshot.gpu.adapter?.percent != null) {
|
|
assert.ok(snapshot.gpu.adapter.percent >= 0 && snapshot.gpu.adapter.percent <= 100)
|
|
console.log(`\nLive GPU check passed: ${snapshot.gpu.adapter.name}`)
|
|
} else {
|
|
console.log("\nGPU utilization unavailable on this host; CPU/RAM/disk checks still apply.")
|
|
}
|
|
console.log("Live disk, CPU, and RAM checks passed.")
|