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

Commit af0e3bd

Browse files
committed
using system information instead
1 parent 045328c commit af0e3bd

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

cortex-js/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
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",
@@ -76,7 +75,6 @@
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",

cortex-js/src/domain/models/resource.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export interface ResourceStatus {
1010
}
1111

1212
export interface UsedMemInfo {
13-
totalMemMb: number;
14-
usedMemMb: number;
13+
total: number;
14+
used: number;
1515
}

cortex-js/src/infrastructure/services/resources-manager/resources-manager.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ import {
33
UsedMemInfo,
44
} from '@/domain/models/resource.interface';
55
import { Injectable } from '@nestjs/common';
6-
import { cpu, mem } from 'node-os-utils';
6+
import systemInformation, { Systeminformation } from 'systeminformation';
77

88
@Injectable()
99
export 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
}

0 commit comments

Comments
 (0)