Skip to content

Commit 9af0fb3

Browse files
committed
Added memory readings
1 parent 943b4a2 commit 9af0fb3

File tree

10 files changed

+291
-421
lines changed

10 files changed

+291
-421
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,3 @@ Temperatures: {
186186
### GPU Readings
187187
For more detailed information on GPUs it is recommended to
188188
install the [nvidia-smi](https://developer.nvidia.com/nvidia-system-management-interface) tool.
189-
190-
### Docker
191-
For [Docker](https://www.docker.com/) support, ensure that the Docker daemon is running and accessible.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lup-system",
3-
"version": "1.3.3",
3+
"version": "1.4.0",
44
"description": "NodeJS library to retrieve system information and utilization.",
55
"main": "./lib/index",
66
"types": "./lib/index.d.ts",
@@ -10,6 +10,7 @@
1010
"./cpu": "./lib/cpu.js",
1111
"./drive": "./lib/drive.js",
1212
"./gpu": "./lib/gpu.js",
13+
"./memory": "./lib/memory.js",
1314
"./net": "./lib/net.js",
1415
"./os": "./lib/os.js",
1516
"./temperature": "./lib/temperature.js",

src/__tests__/Docker.test.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/docker.ts

Lines changed: 0 additions & 192 deletions
This file was deleted.

src/drive.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const VIRTUAL_DRIVE_TYPES = [
77
];
88

99
export type DriveUtilization = {
10-
1110
/** The total amount of unused drive space in bytes. */
1211
free: number;
1312

@@ -18,7 +17,6 @@ export type DriveUtilization = {
1817
percentage: number;
1918
};
2019

21-
2220
export type DriveInfo = {
2321
/** The device name of the drive (e.g., /dev/sda1) */
2422
filesystem: string;
@@ -36,7 +34,6 @@ export type DriveInfo = {
3634
utilization: DriveUtilization;
3735
};
3836

39-
4037
/**
4138
* Returns information about the drives on the system (in Windows the logical drives are returned).
4239
*
@@ -69,7 +66,7 @@ export async function getDrives(includeVirtual: boolean = false): Promise<DriveI
6966
used,
7067
free: parseInt(parts[4], 10) || 0,
7168
percentage: total !== 0 ? used / total : 0,
72-
}
69+
},
7370
});
7471
}
7572
break;
@@ -92,7 +89,7 @@ export async function getDrives(includeVirtual: boolean = false): Promise<DriveI
9289
free,
9390
used: total - free,
9491
percentage: total !== 0 ? (total - free) / total : 0,
95-
}
92+
},
9693
});
9794
}
9895
break;

src/gpu.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { execCommand } from './utils';
22

3-
43
export type GPUUtilization = {
54
/** GPU memory utilization as a percentage (0.0-1.0). */
65
memory?: number;
@@ -21,7 +20,6 @@ export type GPUUtilization = {
2120
powerDraw?: number;
2221
};
2322

24-
2523
export type GPU = {
2624
/** Unique ID of the GPU device. */
2725
id: string;
@@ -166,30 +164,30 @@ export async function getGPUs(): Promise<GPU[]> {
166164
}
167165
if (displayAttached) currGpu.displayAttached = ['yes', 'enabled', '1'].includes(displayAttached.toLowerCase());
168166
if (displayActive) currGpu.displayActive = ['yes', 'enabled', '1'].includes(displayActive.toLowerCase());
169-
if (fanSpeed && !Number.isNaN(parseFloat(fanSpeed))){
170-
if(!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
167+
if (fanSpeed && !Number.isNaN(parseFloat(fanSpeed))) {
168+
if (!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
171169
currGpu.utilization.fanSpeed = parseFloat(fanSpeed) / 100;
172170
}
173171
if (memoryTotal && !Number.isNaN(parseInt(memoryTotal, 10)))
174172
currGpu.memory = parseInt(memoryTotal, 10) * 1024 * 1024; // convert MiB to bytes
175-
if (utilizationGPU && !Number.isNaN(parseFloat(utilizationGPU))){
176-
if(!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
173+
if (utilizationGPU && !Number.isNaN(parseFloat(utilizationGPU))) {
174+
if (!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
177175
currGpu.utilization.processing = parseFloat(utilizationGPU) / 100;
178176
}
179-
if (utilizationMemory && !Number.isNaN(parseFloat(utilizationMemory))){
180-
if(!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
177+
if (utilizationMemory && !Number.isNaN(parseFloat(utilizationMemory))) {
178+
if (!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
181179
currGpu.utilization.memory = parseFloat(utilizationMemory) / 100;
182180
}
183181
if (temperatureGPU && !Number.isNaN(parseFloat(temperatureGPU))) {
184-
if(!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
182+
if (!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
185183
currGpu.utilization.temperature = parseFloat(temperatureGPU);
186184
}
187185
if (temperatureMemory && !Number.isNaN(parseFloat(temperatureMemory))) {
188-
if(!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
186+
if (!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
189187
currGpu.utilization.memoryTemperature = parseFloat(temperatureMemory);
190188
}
191189
if (powerDraw && !Number.isNaN(parseFloat(powerDraw))) {
192-
if(!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
190+
if (!currGpu.utilization) currGpu.utilization = {} as GPUUtilization;
193191
currGpu.utilization.powerDraw = parseFloat(powerDraw);
194192
}
195193
gpus[currIdx] = currGpu;

src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './cpu';
2-
export * from './docker';
32
export * from './drive';
43
export * from './gpu';
54
export * from './memory';
@@ -9,7 +8,6 @@ export * from './temperature';
98
export * from './utils';
109

1110
import * as cpu from './cpu';
12-
import * as docker from './docker';
1311
import * as drive from './drive';
1412
import * as gpu from './gpu';
1513
import * as memory from './memory';
@@ -23,7 +21,6 @@ import * as utils from './utils';
2321
*/
2422
const lupSystem = {
2523
...cpu,
26-
...docker,
2724
...drive,
2825
...gpu,
2926
...memory,

0 commit comments

Comments
 (0)