systeminformation 5.29.1 → 5.30.1
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/network.js +3 -2
- package/lib/processes.js +7 -2
- package/lib/users.js +69 -52
- 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/network.js
CHANGED
|
@@ -425,8 +425,9 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
|
|
|
425
425
|
ifaceSanitized = ifaceSanitized + s[i];
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
const profiles = execSync(`netsh wlan show profiles "${ifaceSanitized}"`, util.execOptsWin).split('\r\n');
|
|
429
|
+
i8021xState = (profiles.find((l) => l.indexOf('802.1X') >= 0) || '').trim();
|
|
430
|
+
i8021xProtocol = (profiles.find((l) => l.indexOf('EAP') >= 0) || '').trim();
|
|
430
431
|
}
|
|
431
432
|
|
|
432
433
|
if (i8021xState.includes(':') && i8021xProtocol.includes(':')) {
|
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';
|
|
@@ -26,40 +26,63 @@ const _openbsd = _platform === 'openbsd';
|
|
|
26
26
|
const _netbsd = _platform === 'netbsd';
|
|
27
27
|
const _sunos = _platform === 'sunos';
|
|
28
28
|
|
|
29
|
+
function parseDate(dtMon, dtDay) {
|
|
30
|
+
let dt = new Date().toISOString().slice(0, 10);
|
|
31
|
+
try {
|
|
32
|
+
dt = '' + new Date().getFullYear() + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(dtMon.toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + dtDay).slice(-2);
|
|
33
|
+
if (new Date(dt) > new Date()) {
|
|
34
|
+
dt = '' + (new Date().getFullYear() - 1) + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(dtMon.toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + dtDay).slice(-2);
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
util.noop();
|
|
38
|
+
}
|
|
39
|
+
return dt;
|
|
40
|
+
}
|
|
41
|
+
|
|
29
42
|
function parseUsersLinux(lines, phase) {
|
|
30
|
-
|
|
43
|
+
const result = [];
|
|
31
44
|
let result_who = [];
|
|
32
|
-
|
|
45
|
+
const result_w = {};
|
|
33
46
|
let w_first = true;
|
|
34
47
|
let w_header = [];
|
|
35
|
-
|
|
48
|
+
const w_pos = [];
|
|
36
49
|
let who_line = {};
|
|
37
50
|
|
|
38
51
|
let is_whopart = true;
|
|
39
|
-
|
|
52
|
+
let is_whoerror = false;
|
|
53
|
+
lines.forEach((line) => {
|
|
40
54
|
if (line === '---') {
|
|
41
55
|
is_whopart = false;
|
|
42
56
|
} else {
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
const l = line.replace(/ +/g, ' ').split(' ');
|
|
45
58
|
// who part
|
|
46
59
|
if (is_whopart) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
if (line.toLowerCase().indexOf('unexpected') >= 0 || line.toLowerCase().indexOf('unrecognized') >= 0) {
|
|
61
|
+
is_whoerror = true;
|
|
62
|
+
result_who = [];
|
|
63
|
+
}
|
|
64
|
+
if (!is_whoerror) {
|
|
65
|
+
const timePos = l && l.length > 4 && l[4].indexOf(':') > 0 ? 4 : 3;
|
|
66
|
+
result_who.push({
|
|
67
|
+
user: l[0],
|
|
68
|
+
tty: l[1],
|
|
69
|
+
date: timePos === 4 ? parseDate(l[2], l[3]) : l[2],
|
|
70
|
+
time: l[timePos],
|
|
71
|
+
ip: l && l.length > timePos + 1 ? l[timePos + 1].replace(/\(/g, '').replace(/\)/g, '') : '',
|
|
72
|
+
command: ''
|
|
73
|
+
});
|
|
74
|
+
}
|
|
54
75
|
} else {
|
|
55
76
|
// w part
|
|
56
77
|
if (w_first) {
|
|
57
78
|
// header
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
if (line[0] !== ' ') {
|
|
80
|
+
w_header = l;
|
|
81
|
+
w_header.forEach((item) => {
|
|
82
|
+
w_pos.push(line.indexOf(item));
|
|
83
|
+
});
|
|
84
|
+
w_first = false;
|
|
85
|
+
}
|
|
63
86
|
} else {
|
|
64
87
|
// split by w_pos
|
|
65
88
|
result_w.user = line.substring(w_pos[0], w_pos[1] - 1).trim();
|
|
@@ -71,10 +94,14 @@ function parseUsersLinux(lines, phase) {
|
|
|
71
94
|
.trim();
|
|
72
95
|
result_w.command = line.substring(w_pos[7], 1000).trim();
|
|
73
96
|
// find corresponding 'who' line
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
97
|
+
if (result_who.length || phase === 1) {
|
|
98
|
+
who_line = result_who.filter((obj) => {
|
|
99
|
+
return obj.user.substring(0, 8).trim() === result_w.user && obj.tty === result_w.tty;
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
who_line = [{ user: result_w.user, tty: result_w.tty, date: '', time: '', ip: '' }];
|
|
103
|
+
}
|
|
104
|
+
if (who_line.length === 1 && who_line[0].user !== '') {
|
|
78
105
|
result.push({
|
|
79
106
|
user: who_line[0].user,
|
|
80
107
|
tty: who_line[0].tty,
|
|
@@ -96,32 +123,24 @@ function parseUsersLinux(lines, phase) {
|
|
|
96
123
|
}
|
|
97
124
|
|
|
98
125
|
function parseUsersDarwin(lines) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
126
|
+
const result = [];
|
|
127
|
+
const result_who = [];
|
|
128
|
+
const result_w = {};
|
|
102
129
|
let who_line = {};
|
|
103
130
|
|
|
104
131
|
let is_whopart = true;
|
|
105
|
-
lines.forEach(
|
|
132
|
+
lines.forEach((line) => {
|
|
106
133
|
if (line === '---') {
|
|
107
134
|
is_whopart = false;
|
|
108
135
|
} else {
|
|
109
|
-
|
|
136
|
+
const l = line.replace(/ +/g, ' ').split(' ');
|
|
110
137
|
|
|
111
138
|
// who part
|
|
112
139
|
if (is_whopart) {
|
|
113
|
-
let dt = '' + new Date().getFullYear() + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(l[2].toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + l[3]).slice(-2);
|
|
114
|
-
try {
|
|
115
|
-
if (new Date(dt) > new Date()) {
|
|
116
|
-
dt = '' + (new Date().getFullYear() - 1) + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(l[2].toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + l[3]).slice(-2);
|
|
117
|
-
}
|
|
118
|
-
} catch {
|
|
119
|
-
util.noop();
|
|
120
|
-
}
|
|
121
140
|
result_who.push({
|
|
122
141
|
user: l[0],
|
|
123
142
|
tty: l[1],
|
|
124
|
-
date:
|
|
143
|
+
date: parseDate(l[2], l[3]),
|
|
125
144
|
time: l[4]
|
|
126
145
|
});
|
|
127
146
|
} else {
|
|
@@ -132,9 +151,7 @@ function parseUsersDarwin(lines) {
|
|
|
132
151
|
result_w.ip = l[2] !== '-' ? l[2] : '';
|
|
133
152
|
result_w.command = l.slice(5, 1000).join(' ');
|
|
134
153
|
// 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
|
-
});
|
|
154
|
+
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
155
|
if (who_line.length === 1) {
|
|
139
156
|
result.push({
|
|
140
157
|
user: who_line[0].user,
|
|
@@ -158,13 +175,13 @@ function users(callback) {
|
|
|
158
175
|
|
|
159
176
|
// linux
|
|
160
177
|
if (_linux) {
|
|
161
|
-
exec('export LC_ALL=C; who --ips; echo "---"; w; unset LC_ALL | tail -n +2',
|
|
178
|
+
exec('export LC_ALL=C; who --ips; echo "---"; w; unset LC_ALL | tail -n +2', (error, stdout) => {
|
|
162
179
|
if (!error) {
|
|
163
180
|
// lines / split
|
|
164
181
|
let lines = stdout.toString().split('\n');
|
|
165
182
|
result = parseUsersLinux(lines, 1);
|
|
166
183
|
if (result.length === 0) {
|
|
167
|
-
exec('who; echo "---"; w | tail -n +2',
|
|
184
|
+
exec('who; echo "---"; w | tail -n +2', (error, stdout) => {
|
|
168
185
|
if (!error) {
|
|
169
186
|
// lines / split
|
|
170
187
|
lines = stdout.toString().split('\n');
|
|
@@ -190,10 +207,10 @@ function users(callback) {
|
|
|
190
207
|
});
|
|
191
208
|
}
|
|
192
209
|
if (_freebsd || _openbsd || _netbsd) {
|
|
193
|
-
exec('who; echo "---"; w -ih',
|
|
210
|
+
exec('who; echo "---"; w -ih', (error, stdout) => {
|
|
194
211
|
if (!error) {
|
|
195
212
|
// lines / split
|
|
196
|
-
|
|
213
|
+
const lines = stdout.toString().split('\n');
|
|
197
214
|
result = parseUsersDarwin(lines);
|
|
198
215
|
}
|
|
199
216
|
if (callback) {
|
|
@@ -203,10 +220,10 @@ function users(callback) {
|
|
|
203
220
|
});
|
|
204
221
|
}
|
|
205
222
|
if (_sunos) {
|
|
206
|
-
exec('who; echo "---"; w -h',
|
|
223
|
+
exec('who; echo "---"; w -h', (error, stdout) => {
|
|
207
224
|
if (!error) {
|
|
208
225
|
// lines / split
|
|
209
|
-
|
|
226
|
+
const lines = stdout.toString().split('\n');
|
|
210
227
|
result = parseUsersDarwin(lines);
|
|
211
228
|
}
|
|
212
229
|
if (callback) {
|
|
@@ -217,10 +234,10 @@ function users(callback) {
|
|
|
217
234
|
}
|
|
218
235
|
|
|
219
236
|
if (_darwin) {
|
|
220
|
-
exec('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL',
|
|
237
|
+
exec('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL', (error, stdout) => {
|
|
221
238
|
if (!error) {
|
|
222
239
|
// lines / split
|
|
223
|
-
|
|
240
|
+
const lines = stdout.toString().split('\n');
|
|
224
241
|
result = parseUsersDarwin(lines);
|
|
225
242
|
}
|
|
226
243
|
if (callback) {
|
|
@@ -239,10 +256,10 @@ function users(callback) {
|
|
|
239
256
|
util.powerShell(cmd).then((data) => {
|
|
240
257
|
if (data) {
|
|
241
258
|
data = data.split('#-#-#-#');
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
259
|
+
const sessions = parseWinSessions((data[0] || '').split(/\n\s*\n/));
|
|
260
|
+
const loggedons = parseWinLoggedOn((data[1] || '').split(/\n\s*\n/));
|
|
261
|
+
const queryUser = parseWinUsersQuery((data[3] || '').split('\r\n'));
|
|
262
|
+
const users = parseWinUsers((data[2] || '').split(/\n\s*\n/), queryUser);
|
|
246
263
|
for (let id in loggedons) {
|
|
247
264
|
if ({}.hasOwnProperty.call(loggedons, id)) {
|
|
248
265
|
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.1",
|
|
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)",
|