systeminformation 6.0.0-beta.11 → 6.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/dist/bsd/network-stats.js +2 -1
- package/dist/common/defaults.js +7 -1
- package/dist/common/filesys.d.ts +19 -0
- package/dist/common/filesys.js +167 -2
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +1 -13
- package/dist/common/types.d.ts +11 -0
- package/dist/common/windows.d.ts +4 -0
- package/dist/common/windows.js +57 -1
- package/dist/cpu-current-load.d.ts +1 -0
- package/dist/cpu-current-load.js +26 -2
- package/dist/darwin/displays.d.ts +1 -0
- package/dist/darwin/displays.js +30 -1
- package/dist/darwin/index.d.ts +1 -0
- package/dist/darwin/index.js +4 -2
- package/dist/darwin/network-interfaces.d.ts +3 -0
- package/dist/darwin/network-interfaces.js +78 -3
- package/dist/darwin/network-stats.js +3 -2
- package/dist/darwin/process-focused.d.ts +3 -0
- package/dist/darwin/process-focused.js +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/linux/block-devices.js +3 -1
- package/dist/linux/displays.d.ts +8 -0
- package/dist/linux/displays.js +112 -3
- package/dist/linux/index.d.ts +1 -0
- package/dist/linux/index.js +4 -2
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +69 -2
- package/dist/linux/process-focused.d.ts +4 -0
- package/dist/linux/process-focused.js +32 -0
- package/dist/linux/process-load.js +2 -1
- package/dist/linux/services.js +5 -4
- package/dist/process-focused.d.ts +1 -0
- package/dist/process-focused.js +17 -0
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/displays.d.ts +5 -0
- package/dist/windows/displays.js +59 -5
- package/dist/windows/gpu.js +3 -2
- package/dist/windows/index.d.ts +1 -0
- package/dist/windows/index.js +3 -1
- package/dist/windows/network-interfaces.js +14 -1
- package/dist/windows/process-focused.d.ts +3 -0
- package/dist/windows/process-focused.js +36 -0
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +37 -15
- package/package.json +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processes = exports.calcProcStatWin = void 0;
|
|
3
|
+
exports.processes = exports.calcProcStatWin = exports.processStateWin = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
-
const mappings_1 = require("../common/mappings");
|
|
8
7
|
const windows_1 = require("../common/windows");
|
|
9
8
|
const parse_1 = require("../common/parse");
|
|
10
9
|
const _processes_cpu = {
|
|
@@ -15,6 +14,32 @@ const _processes_cpu = {
|
|
|
15
14
|
ms: 0,
|
|
16
15
|
result: {}
|
|
17
16
|
};
|
|
17
|
+
const processStateWin = (running, waiting, suspended) => {
|
|
18
|
+
if (running > 0) {
|
|
19
|
+
return 'running';
|
|
20
|
+
}
|
|
21
|
+
if (waiting > 0) {
|
|
22
|
+
return 'sleeping';
|
|
23
|
+
}
|
|
24
|
+
if (suspended > 0) {
|
|
25
|
+
return 'blocked';
|
|
26
|
+
}
|
|
27
|
+
return 'unknown';
|
|
28
|
+
};
|
|
29
|
+
exports.processStateWin = processStateWin;
|
|
30
|
+
const WIN_THREAD_STATES = 'Get-Process -ErrorAction SilentlyContinue | ForEach-Object { $r=0;$w=0;$u=0; try { foreach ($t in $_.Threads) { $s=[int]$t.ThreadState; ' +
|
|
31
|
+
'if ($s -eq 1 -or $s -eq 2 -or $s -eq 3 -or $s -eq 6) { $r++ } elseif ($s -eq 5) { if ([int]$t.WaitReason -eq 5) { $u++ } else { $w++ } } } } catch {}; ' +
|
|
32
|
+
'[PSCustomObject]@{i=$_.Id;r=$r;w=$w;u=$u} } | ConvertTo-Json -compress';
|
|
33
|
+
const getWindowsProcessStates = async () => {
|
|
34
|
+
const result = {};
|
|
35
|
+
try {
|
|
36
|
+
for (const entry of (0, windows_1.psArray)(await windows_1.ps.exec(WIN_THREAD_STATES))) {
|
|
37
|
+
result[entry.i] = (0, exports.processStateWin)(entry.r || 0, entry.w || 0, entry.u || 0);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
18
43
|
const calcProcStatWin = (procStat, all, _cpu_old) => {
|
|
19
44
|
let cpuu = 0;
|
|
20
45
|
let cpus = 0;
|
|
@@ -43,8 +68,12 @@ const processes = async () => {
|
|
|
43
68
|
if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
|
|
44
69
|
const cpuBaseline = { ..._processes_cpu };
|
|
45
70
|
try {
|
|
46
|
-
const
|
|
47
|
-
|
|
71
|
+
const [processList, states] = await Promise.all([
|
|
72
|
+
windows_1.ps.exec(`Get-CimInstance Win32_Process | select-Object ProcessId,ParentProcessId,Caption,CommandLine,ExecutablePath,UserModeTime,KernelModeTime,WorkingSetSize,Priority,PageFileUsage,
|
|
73
|
+
@{n="CreationDate";e={$_.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")}} | ConvertTo-Json -compress`),
|
|
74
|
+
getWindowsProcessStates()
|
|
75
|
+
]);
|
|
76
|
+
const processArray = (0, windows_1.psArray)(processList);
|
|
48
77
|
if (processArray.length) {
|
|
49
78
|
const procs = [];
|
|
50
79
|
const procStats = [];
|
|
@@ -54,7 +83,6 @@ const processes = async () => {
|
|
|
54
83
|
processArray.forEach((element) => {
|
|
55
84
|
const pid = element.ProcessId;
|
|
56
85
|
const parentPid = element.ParentProcessId;
|
|
57
|
-
const statusValue = element.ExecutionState || null;
|
|
58
86
|
const name = element.Caption;
|
|
59
87
|
const commandLine = element.CommandLine;
|
|
60
88
|
const commandPath = element.ExecutablePath;
|
|
@@ -65,15 +93,6 @@ const processes = async () => {
|
|
|
65
93
|
allcpuu += utime - (cpuOld ? cpuOld.utime : 0);
|
|
66
94
|
allcpus += stime - (cpuOld ? cpuOld.stime : 0);
|
|
67
95
|
result.all++;
|
|
68
|
-
if (!statusValue) {
|
|
69
|
-
result.unknown++;
|
|
70
|
-
}
|
|
71
|
-
if (statusValue === 3) {
|
|
72
|
-
result.running++;
|
|
73
|
-
}
|
|
74
|
-
if (statusValue === 4 || statusValue === 5) {
|
|
75
|
-
result.blocked++;
|
|
76
|
-
}
|
|
77
96
|
procStats.push({
|
|
78
97
|
pid: pid,
|
|
79
98
|
name: '',
|
|
@@ -97,7 +116,7 @@ const processes = async () => {
|
|
|
97
116
|
memRss: Math.floor((element.WorkingSetSize || 0) / 1024),
|
|
98
117
|
nice: 0,
|
|
99
118
|
started: element.CreationDate,
|
|
100
|
-
state:
|
|
119
|
+
state: states[pid] || 'unknown',
|
|
101
120
|
tty: '',
|
|
102
121
|
user: '',
|
|
103
122
|
command: commandLine || name,
|
|
@@ -105,6 +124,9 @@ const processes = async () => {
|
|
|
105
124
|
params: ''
|
|
106
125
|
});
|
|
107
126
|
});
|
|
127
|
+
result.running = procs.filter((proc) => proc.state === 'running').length;
|
|
128
|
+
result.blocked = procs.filter((proc) => proc.state === 'blocked').length;
|
|
129
|
+
result.unknown = procs.filter((proc) => proc.state === 'unknown').length;
|
|
108
130
|
result.sleeping = result.all - result.running - result.blocked - result.unknown;
|
|
109
131
|
result.list = procs;
|
|
110
132
|
procStats.forEach((element) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.13",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|