feat: initial node groups #44
@@ -22,22 +22,15 @@ export async function readCpuSnapshot(): Promise<CpuSnapshot> {
|
|||||||
const stat = await readFile('/proc/stat', 'utf8');
|
const stat = await readFile('/proc/stat', 'utf8');
|
||||||
const line = stat.split('\n')[0];
|
const line = stat.split('\n')[0];
|
||||||
|
|
||||||
const parts = line
|
const parts: number[] = line
|
||||||
.trim()
|
.trim()
|
||||||
.split(/\s+/)
|
.split(/\s+/)
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.map(v => Number(v));
|
.map((v: unknown) => Number(v));
|
||||||
|
|
||||||
const [
|
const idle = parts[3];
|
||||||
user,
|
const iowait = parts[4];
|
||||||
nice,
|
const steal = parts[7];
|
||||||
system,
|
|
||||||
idle,
|
|
||||||
iowait,
|
|
||||||
irq,
|
|
||||||
softirq,
|
|
||||||
steal
|
|
||||||
] = parts;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
idle: idle + iowait,
|
idle: idle + iowait,
|
||||||
@@ -74,7 +67,7 @@ export async function readCgroupCpuStat() {
|
|||||||
|
|
||||||
for (const path of possiblePaths) {
|
for (const path of possiblePaths) {
|
||||||
try {
|
try {
|
||||||
const txt = await readFile(path, 'utf8');
|
const txt: string = await readFile(path, 'utf8');
|
||||||
|
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
txt
|
txt
|
||||||
|
|||||||
Reference in New Issue
Block a user