Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion cortex-js/src/infrastructure/commanders/ps.command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ora from 'ora';
import systeminformation from 'systeminformation';
import { CommandRunner, SubCommand } from 'nest-commander';
import { PSCliUsecases } from './usecases/ps.cli.usecases';
import { SetCommandContext } from './decorators/CommandContext';
Expand Down Expand Up @@ -32,6 +33,30 @@ export class PSCommand extends CommandRunner {
})
.then((isOnline) => {
checkingSpinner.succeed(isOnline ? 'API server is online' : 'API server is offline');
});
})
.then(async () => {
const table = [];
const cpuUsage = (await systeminformation.currentLoad()).currentLoad.toFixed(2);
const gpusLoad = [];
const gpus = await systeminformation.graphics();
for (const gpu of gpus.controllers) {
const totalVram = gpu.vram || 0;
gpusLoad.push({
totalVram,
});
}
const memoryData = await systeminformation.mem();
const memoryUsage = (memoryData.active / memoryData.total * 100).toFixed(2)
table.push({
'CPU Usage': `${cpuUsage}%`,
'Memory Usage': `${memoryUsage}%`,
});
if(gpusLoad.length > 0 && gpusLoad.filter(gpu => gpu.totalVram > 0).length > 0) {
table.push({
'VRAM': gpusLoad,
});
}
console.table(table);
})
}
}