Add system info to SystemInfo

Provide the kernel, machine, CPU Model, hostname, and Node.js version
fields to SystemInfo and display them in the Web UI.  These were added
as metrics exposed to prometheus in b46efeb.
This commit is contained in:
Hornwitser committed 2024-01-16 21:27:02 +01:00
1 parent 4e36fa1b4e
commit de47989527
6 files changed
+63 -3

No files matched your search

+8 -2
View File
@@ -4,7 +4,7 @@ import util from "util";
import { Gauge } from "./prometheus";
import { SystemInfo } from "./data";
function cpuModel() {
function filterCpuModel() {
const model = os.cpus()[0].model;
// Remove irelevant clutter
return model
@@ -16,6 +16,7 @@ function cpuModel() {
.trim() // AMD CPUs may have trailing spaces in the model.
;
}
const cpuModel = filterCpuModel();
export const systemInfo = new Gauge(
"system_info",
@@ -27,7 +28,7 @@ export const systemInfo = new Gauge(
systemInfo.labels({
"kernel": os.type(),
"machine": os.machine(),
"cpu_model": cpuModel(),
"cpu_model": cpuModel,
"hostname": os.hostname(),
"node": process.version,
}).set(1);
@@ -153,6 +154,11 @@ export async function gatherSystemInfo(id: SystemInfo["id"]) {
return new SystemInfo(
id,
os.hostname(),
process.version,
os.type(),
os.machine(),
cpuModel,
cpuUsage,
os.totalmem(),
os.freemem(),