This repository was archived by the owner on Jul 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
infrastructure/services/resources-manager Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 5353 "decompress" : " ^4.2.1" ,
5454 "js-yaml" : " ^4.1.0" ,
5555 "nest-commander" : " ^3.13.0" ,
56- "node-os-utils" : " ^1.3.7" ,
5756 "openai" : " ^4.50.0" ,
5857 "readline" : " ^1.3.0" ,
5958 "reflect-metadata" : " ^0.2.0" ,
7675 "@types/jest" : " ^29.5.2" ,
7776 "@types/js-yaml" : " ^4.0.9" ,
7877 "@types/node" : " ^20.12.9" ,
79- "@types/node-os-utils" : " ^1.3.4" ,
8078 "@types/supertest" : " ^6.0.2" ,
8179 "@types/update-notifier" : " ^6.0.8" ,
8280 "@types/uuid" : " ^9.0.8" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,6 @@ export interface ResourceStatus {
1010}
1111
1212export interface UsedMemInfo {
13- totalMemMb : number ;
14- usedMemMb : number ;
13+ total : number ;
14+ used : number ;
1515}
Original file line number Diff line number Diff line change @@ -3,21 +3,25 @@ import {
33 UsedMemInfo ,
44} from '@/domain/models/resource.interface' ;
55import { Injectable } from '@nestjs/common' ;
6- import { cpu , mem } from 'node-os-utils ' ;
6+ import systemInformation , { Systeminformation } from 'systeminformation ' ;
77
88@Injectable ( )
99export class ResourcesManagerService {
1010 async getResourceStatuses ( ) : Promise < ResourceStatus > {
11- const promises = [ cpu . usage ( ) , mem . used ( ) ] ;
11+ const promises = [ systemInformation . currentLoad ( ) , systemInformation . mem ( ) ] ;
1212 const results = await Promise . all ( promises ) ;
1313
14- const cpuUsage = results [ 0 ] as number ;
15- const memInfo = results [ 1 ] as UsedMemInfo ;
14+ const cpuUsage = results [ 0 ] as Systeminformation . CurrentLoadData ;
15+ const memory = results [ 1 ] as Systeminformation . MemData ;
16+ const memInfo : UsedMemInfo = {
17+ total : memory . total ,
18+ used : memory . used ,
19+ } ;
1620
1721 return {
1822 mem : memInfo ,
1923 cpu : {
20- usage : cpuUsage ,
24+ usage : cpuUsage . avgLoad ,
2125 } ,
2226 } ;
2327 }
You can’t perform that action at this time.
0 commit comments