This repository was archived by the owner on Jul 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
cortex-js/src/infrastructure/commanders Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 11import ora from 'ora' ;
2+ import systeminformation from 'systeminformation' ;
23import { CommandRunner , SubCommand } from 'nest-commander' ;
34import { PSCliUsecases } from './usecases/ps.cli.usecases' ;
45import { 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}
You can’t perform that action at this time.
0 commit comments