systeminformation 5.29.1 → 5.30.0
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 +1 -0
- package/lib/processes.js +7 -2
- package/lib/users.js +40 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,6 +185,7 @@ si.cpu()
|
|
|
185
185
|
|
|
186
186
|
(last 7 major and minor version releases)
|
|
187
187
|
|
|
188
|
+
- Version 5.30.0: `processes()` added user (windows)
|
|
188
189
|
- Version 5.29.0: `osInfo()` added OS code name (windows)
|
|
189
190
|
- Version 5.28.0: `cpuTemperature()` added suppurt for macos-temperature-sensor (macOS)
|
|
190
191
|
- Version 5.27.0: `mem()` added reclaimable memory
|
package/lib/processes.js
CHANGED
|
@@ -934,7 +934,11 @@ function processes(callback) {
|
|
|
934
934
|
try {
|
|
935
935
|
util
|
|
936
936
|
.powerShell(
|
|
937
|
-
|
|
937
|
+
`Get-CimInstance Win32_Process | select-Object ProcessId,ParentProcessId,ExecutionState,Caption,CommandLine,ExecutablePath,UserModeTime,KernelModeTime,WorkingSetSize,Priority,PageFileUsage,
|
|
938
|
+
@{n="CreationDate";e={$_.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")}},
|
|
939
|
+
@{n="User";e={$OwnerInfo = Invoke-CimMethod -InputObject $_ -MethodName GetOwner
|
|
940
|
+
if($OwnerInfo.ReturnValue -eq 0) {"$($OwnerInfo.Domain)\\$($OwnerInfo.User)"} else {""}
|
|
941
|
+
}} | ConvertTo-Json -compress`
|
|
938
942
|
)
|
|
939
943
|
.then((stdout, error) => {
|
|
940
944
|
if (!error) {
|
|
@@ -959,6 +963,7 @@ function processes(callback) {
|
|
|
959
963
|
const utime = element.UserModeTime;
|
|
960
964
|
const stime = element.KernelModeTime;
|
|
961
965
|
const memw = element.WorkingSetSize;
|
|
966
|
+
const user = element.User;
|
|
962
967
|
allcpuu = allcpuu + utime;
|
|
963
968
|
allcpus = allcpus + stime;
|
|
964
969
|
result.all++;
|
|
@@ -995,7 +1000,7 @@ function processes(callback) {
|
|
|
995
1000
|
started: element.CreationDate,
|
|
996
1001
|
state: statusValue ? _winStatusValues[statusValue] : _winStatusValues[0],
|
|
997
1002
|
tty: '',
|
|
998
|
-
user
|
|
1003
|
+
user,
|
|
999
1004
|
command: commandLine || name,
|
|
1000
1005
|
path: commandPath,
|
|
1001
1006
|
params: ''
|
package/lib/users.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
const exec = require('child_process').exec;
|
|
17
17
|
const util = require('./util');
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const _platform = process.platform;
|
|
20
20
|
|
|
21
21
|
const _linux = _platform === 'linux' || _platform === 'android';
|
|
22
22
|
const _darwin = _platform === 'darwin';
|
|
@@ -27,20 +27,20 @@ const _netbsd = _platform === 'netbsd';
|
|
|
27
27
|
const _sunos = _platform === 'sunos';
|
|
28
28
|
|
|
29
29
|
function parseUsersLinux(lines, phase) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const result = [];
|
|
31
|
+
const result_who = [];
|
|
32
|
+
const result_w = {};
|
|
33
33
|
let w_first = true;
|
|
34
34
|
let w_header = [];
|
|
35
|
-
|
|
35
|
+
const w_pos = [];
|
|
36
36
|
let who_line = {};
|
|
37
37
|
|
|
38
38
|
let is_whopart = true;
|
|
39
|
-
lines.forEach(
|
|
39
|
+
lines.forEach((line) => {
|
|
40
40
|
if (line === '---') {
|
|
41
41
|
is_whopart = false;
|
|
42
42
|
} else {
|
|
43
|
-
|
|
43
|
+
const l = line.replace(/ +/g, ' ').split(' ');
|
|
44
44
|
|
|
45
45
|
// who part
|
|
46
46
|
if (is_whopart) {
|
|
@@ -55,11 +55,13 @@ function parseUsersLinux(lines, phase) {
|
|
|
55
55
|
// w part
|
|
56
56
|
if (w_first) {
|
|
57
57
|
// header
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
if (line[0] !== ' ') {
|
|
59
|
+
w_header = l;
|
|
60
|
+
w_header.forEach((item) => {
|
|
61
|
+
w_pos.push(line.indexOf(item));
|
|
62
|
+
});
|
|
63
|
+
w_first = false;
|
|
64
|
+
}
|
|
63
65
|
} else {
|
|
64
66
|
// split by w_pos
|
|
65
67
|
result_w.user = line.substring(w_pos[0], w_pos[1] - 1).trim();
|
|
@@ -71,10 +73,14 @@ function parseUsersLinux(lines, phase) {
|
|
|
71
73
|
.trim();
|
|
72
74
|
result_w.command = line.substring(w_pos[7], 1000).trim();
|
|
73
75
|
// find corresponding 'who' line
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if (result_who.length || phase === 1) {
|
|
77
|
+
who_line = result_who.filter((obj) => {
|
|
78
|
+
return obj.user.substring(0, 8).trim() === result_w.user && obj.tty === result_w.tty;
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
who_line = [{ user: result_w.user, tty: result_w.tty, date: '', time: '', ip: '' }];
|
|
82
|
+
}
|
|
83
|
+
if (who_line.length === 1 && who_line[0].user !== '') {
|
|
78
84
|
result.push({
|
|
79
85
|
user: who_line[0].user,
|
|
80
86
|
tty: who_line[0].tty,
|
|
@@ -96,17 +102,17 @@ function parseUsersLinux(lines, phase) {
|
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
function parseUsersDarwin(lines) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
const result = [];
|
|
106
|
+
const result_who = [];
|
|
107
|
+
const result_w = {};
|
|
102
108
|
let who_line = {};
|
|
103
109
|
|
|
104
110
|
let is_whopart = true;
|
|
105
|
-
lines.forEach(
|
|
111
|
+
lines.forEach((line) => {
|
|
106
112
|
if (line === '---') {
|
|
107
113
|
is_whopart = false;
|
|
108
114
|
} else {
|
|
109
|
-
|
|
115
|
+
const l = line.replace(/ +/g, ' ').split(' ');
|
|
110
116
|
|
|
111
117
|
// who part
|
|
112
118
|
if (is_whopart) {
|
|
@@ -132,9 +138,7 @@ function parseUsersDarwin(lines) {
|
|
|
132
138
|
result_w.ip = l[2] !== '-' ? l[2] : '';
|
|
133
139
|
result_w.command = l.slice(5, 1000).join(' ');
|
|
134
140
|
// find corresponding 'who' line
|
|
135
|
-
who_line = result_who.filter(
|
|
136
|
-
return obj.user.substring(0, 10) === result_w.user.substring(0, 10) && (obj.tty.substring(3, 1000) === result_w.tty || obj.tty === result_w.tty);
|
|
137
|
-
});
|
|
141
|
+
who_line = result_who.filter((obj) => obj.user.substring(0, 10) === result_w.user.substring(0, 10) && (obj.tty.substring(3, 1000) === result_w.tty || obj.tty === result_w.tty));
|
|
138
142
|
if (who_line.length === 1) {
|
|
139
143
|
result.push({
|
|
140
144
|
user: who_line[0].user,
|
|
@@ -158,13 +162,13 @@ function users(callback) {
|
|
|
158
162
|
|
|
159
163
|
// linux
|
|
160
164
|
if (_linux) {
|
|
161
|
-
exec('export LC_ALL=C; who --ips; echo "---"; w; unset LC_ALL | tail -n +2',
|
|
165
|
+
exec('export LC_ALL=C; who --ips; echo "---"; w; unset LC_ALL | tail -n +2', (error, stdout) => {
|
|
162
166
|
if (!error) {
|
|
163
167
|
// lines / split
|
|
164
168
|
let lines = stdout.toString().split('\n');
|
|
165
169
|
result = parseUsersLinux(lines, 1);
|
|
166
170
|
if (result.length === 0) {
|
|
167
|
-
exec('who; echo "---"; w | tail -n +2',
|
|
171
|
+
exec('who; echo "---"; w | tail -n +2', (error, stdout) => {
|
|
168
172
|
if (!error) {
|
|
169
173
|
// lines / split
|
|
170
174
|
lines = stdout.toString().split('\n');
|
|
@@ -190,10 +194,10 @@ function users(callback) {
|
|
|
190
194
|
});
|
|
191
195
|
}
|
|
192
196
|
if (_freebsd || _openbsd || _netbsd) {
|
|
193
|
-
exec('who; echo "---"; w -ih',
|
|
197
|
+
exec('who; echo "---"; w -ih', (error, stdout) => {
|
|
194
198
|
if (!error) {
|
|
195
199
|
// lines / split
|
|
196
|
-
|
|
200
|
+
const lines = stdout.toString().split('\n');
|
|
197
201
|
result = parseUsersDarwin(lines);
|
|
198
202
|
}
|
|
199
203
|
if (callback) {
|
|
@@ -203,10 +207,10 @@ function users(callback) {
|
|
|
203
207
|
});
|
|
204
208
|
}
|
|
205
209
|
if (_sunos) {
|
|
206
|
-
exec('who; echo "---"; w -h',
|
|
210
|
+
exec('who; echo "---"; w -h', (error, stdout) => {
|
|
207
211
|
if (!error) {
|
|
208
212
|
// lines / split
|
|
209
|
-
|
|
213
|
+
const lines = stdout.toString().split('\n');
|
|
210
214
|
result = parseUsersDarwin(lines);
|
|
211
215
|
}
|
|
212
216
|
if (callback) {
|
|
@@ -217,10 +221,10 @@ function users(callback) {
|
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
if (_darwin) {
|
|
220
|
-
exec('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL',
|
|
224
|
+
exec('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL', (error, stdout) => {
|
|
221
225
|
if (!error) {
|
|
222
226
|
// lines / split
|
|
223
|
-
|
|
227
|
+
const lines = stdout.toString().split('\n');
|
|
224
228
|
result = parseUsersDarwin(lines);
|
|
225
229
|
}
|
|
226
230
|
if (callback) {
|
|
@@ -239,10 +243,10 @@ function users(callback) {
|
|
|
239
243
|
util.powerShell(cmd).then((data) => {
|
|
240
244
|
if (data) {
|
|
241
245
|
data = data.split('#-#-#-#');
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
+
const sessions = parseWinSessions((data[0] || '').split(/\n\s*\n/));
|
|
247
|
+
const loggedons = parseWinLoggedOn((data[1] || '').split(/\n\s*\n/));
|
|
248
|
+
const queryUser = parseWinUsersQuery((data[3] || '').split('\r\n'));
|
|
249
|
+
const users = parseWinUsers((data[2] || '').split(/\n\s*\n/), queryUser);
|
|
246
250
|
for (let id in loggedons) {
|
|
247
251
|
if ({}.hasOwnProperty.call(loggedons, id)) {
|
|
248
252
|
loggedons[id].dateTime = {}.hasOwnProperty.call(sessions, id) ? sessions[id] : '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.30.0",
|
|
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)",
|