Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 48a65f3

Browse files
feat: add resources consumed in ps command
1 parent 31b172b commit 48a65f3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

cortex-js/src/infrastructure/commanders/ps.command.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ora from 'ora';
2+
import systeminformation from 'systeminformation';
23
import { CommandRunner, SubCommand } from 'nest-commander';
34
import { PSCliUsecases } from './usecases/ps.cli.usecases';
45
import { SetCommandContext } from './decorators/CommandContext';
@@ -32,6 +33,30 @@ export class PSCommand extends CommandRunner {
3233
})
3334
.then((isOnline) => {
3435
checkingSpinner.succeed(isOnline ? 'API server is online' : 'API server is offline');
35-
});
36+
})
37+
.then(async () => {
38+
const table = [];
39+
const cpuUsage = (await systeminformation.currentLoad()).currentLoad.toFixed(2);
40+
const gpusLoad = [];
41+
const gpus = await systeminformation.graphics();
42+
for (const gpu of gpus.controllers) {
43+
const totalVram = gpu.vram || 0;
44+
gpusLoad.push({
45+
totalVram,
46+
});
47+
}
48+
const memoryData = await systeminformation.mem();
49+
const memoryUsage = (memoryData.active / memoryData.total * 100).toFixed(2)
50+
table.push({
51+
'CPU Usage': `${cpuUsage}%`,
52+
'Memory Usage': `${memoryUsage}%`,
53+
});
54+
if(gpusLoad.length > 0 && gpusLoad.filter(gpu => gpu.totalVram > 0).length > 0) {
55+
table.push({
56+
'VRAM': gpusLoad,
57+
});
58+
}
59+
console.table(table);
60+
})
3661
}
3762
}

0 commit comments

Comments
 (0)