Spaces:
Runtime error
Runtime error
File size: 826 Bytes
11d0b50 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import os from "os";
export interface SystemInfo {
cpu: {
model: string;
cores: number;
threads: number;
};
memory: {
total: string;
available: string;
};
platform: string;
arch: string;
nodeVersion: string;
}
export function getSystemInfo(): SystemInfo {
const cpus = os.cpus();
const totalMemory = os.totalmem();
const freeMemory = os.freemem();
return {
cpu: {
model: cpus[0]?.model || "Unknown",
cores: os.cpus().length,
threads: os.cpus().length, // In Node.js, this is the same as logical cores
},
memory: {
total: `${(totalMemory / 1024 / 1024 / 1024).toFixed(2)} GB`,
available: `${(freeMemory / 1024 / 1024 / 1024).toFixed(2)} GB`,
},
platform: os.platform(),
arch: os.arch(),
nodeVersion: process.version,
};
}
|