systeminformation 5.9.4 → 5.9.8
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/CHANGELOG.md +8 -4
- package/README.md +1 -1
- package/lib/audio.js +219 -219
- package/lib/battery.js +309 -309
- package/lib/bluetooth.js +183 -183
- package/lib/cpu.js +43 -41
- package/lib/dockerSocket.js +1 -1
- package/lib/filesystem.js +1265 -1264
- package/lib/graphics.js +41 -42
- package/lib/index.d.ts +1 -1
- package/lib/memory.js +24 -21
- package/lib/network.js +1589 -1589
- package/lib/osinfo.js +1150 -1150
- package/lib/printer.js +212 -212
- package/lib/processes.js +1240 -1240
- package/lib/system.js +839 -841
- package/lib/usb.js +305 -305
- package/lib/users.js +187 -81
- package/lib/util.js +21 -6
- package/lib/wifi.js +15 -8
- package/package.json +6 -3
package/lib/bluetooth.js
CHANGED
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// @ts-check
|
|
3
|
-
// ==================================================================================
|
|
4
|
-
// audio.js
|
|
5
|
-
// ----------------------------------------------------------------------------------
|
|
6
|
-
// Description: System Information - library
|
|
7
|
-
// for Node.js
|
|
8
|
-
// Copyright: (c) 2014 - 2021
|
|
9
|
-
// Author: Sebastian Hildebrandt
|
|
10
|
-
// ----------------------------------------------------------------------------------
|
|
11
|
-
// License: MIT
|
|
12
|
-
// ==================================================================================
|
|
13
|
-
// 17. bluetooth
|
|
14
|
-
// ----------------------------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
const exec = require('child_process').exec;
|
|
17
|
-
const execSync = require('child_process').execSync;
|
|
18
|
-
const path = require('path');
|
|
19
|
-
const util = require('./util');
|
|
20
|
-
const fs = require('fs');
|
|
21
|
-
|
|
22
|
-
let _platform = process.platform;
|
|
23
|
-
|
|
24
|
-
const _linux = (_platform === 'linux');
|
|
25
|
-
const _darwin = (_platform === 'darwin');
|
|
26
|
-
const _windows = (_platform === 'win32');
|
|
27
|
-
const _freebsd = (_platform === 'freebsd');
|
|
28
|
-
const _openbsd = (_platform === 'openbsd');
|
|
29
|
-
const _netbsd = (_platform === 'netbsd');
|
|
30
|
-
const _sunos = (_platform === 'sunos');
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
let result = '';
|
|
34
|
-
|
|
35
|
-
if (str.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
|
|
36
|
-
if (str.indexOf('mouse') >= 0) { result = 'Mouse'; }
|
|
37
|
-
if (str.indexOf('speaker') >= 0) { result = 'Speaker'; }
|
|
38
|
-
if (str.indexOf('headset') >= 0) { result = 'Headset'; }
|
|
39
|
-
if (str.indexOf('phone') >= 0) { result = 'Phone'; }
|
|
40
|
-
// to be continued ...
|
|
41
|
-
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function parseLinuxBluetoothInfo(lines, macAddr1, macAddr2) {
|
|
46
|
-
const result = {};
|
|
47
|
-
|
|
48
|
-
result.device = null;
|
|
49
|
-
result.name = util.getValue(lines, 'name', '=');
|
|
50
|
-
result.manufacturer = null;
|
|
51
|
-
result.macDevice = macAddr1;
|
|
52
|
-
result.macHost = macAddr2;
|
|
53
|
-
result.batteryPercent = null;
|
|
54
|
-
result.type =
|
|
55
|
-
result.connected = false;
|
|
56
|
-
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
|
|
61
|
-
const result = {};
|
|
62
|
-
const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || '') + (bluetoothObject.device_name || '')).toLowerCase();
|
|
63
|
-
|
|
64
|
-
result.device = bluetoothObject.device_services || '';
|
|
65
|
-
result.name = bluetoothObject.device_name || '';
|
|
66
|
-
result.manufacturer = bluetoothObject.device_manufacturer || '';
|
|
67
|
-
result.macDevice = (bluetoothObject.device_addr || '').toLowerCase().replace(/-/g, ':');
|
|
68
|
-
result.macHost = macAddr2;
|
|
69
|
-
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
|
|
70
|
-
result.type =
|
|
71
|
-
result.connected = bluetoothObject.device_isconnected === 'attrib_Yes' || false;
|
|
72
|
-
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function parseWindowsBluetooth(lines) {
|
|
77
|
-
const result = {};
|
|
78
|
-
|
|
79
|
-
result.device = null;
|
|
80
|
-
result.name = util.getValue(lines, 'name', '
|
|
81
|
-
result.manufacturer = util.getValue(lines, 'manufacturer', '
|
|
82
|
-
result.macDevice = null;
|
|
83
|
-
result.macHost = null;
|
|
84
|
-
result.batteryPercent = null;
|
|
85
|
-
result.type =
|
|
86
|
-
result.connected = null;
|
|
87
|
-
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function bluetoothDevices(callback) {
|
|
92
|
-
|
|
93
|
-
return new Promise((resolve) => {
|
|
94
|
-
process.nextTick(() => {
|
|
95
|
-
let result = [];
|
|
96
|
-
if (_linux) {
|
|
97
|
-
// get files in /var/lib/bluetooth/ recursive
|
|
98
|
-
const btFiles = util.getFilesInPath('/var/lib/bluetooth/');
|
|
99
|
-
for (let i = 0; i < btFiles.length; i++) {
|
|
100
|
-
const filename = path.basename(btFiles[i]);
|
|
101
|
-
const pathParts = btFiles[i].split('/');
|
|
102
|
-
const macAddr1 = pathParts.length >= 6 ? pathParts[pathParts.length - 2] : null;
|
|
103
|
-
const macAddr2 = pathParts.length >= 7 ? pathParts[pathParts.length - 3] : null;
|
|
104
|
-
if (filename === 'info') {
|
|
105
|
-
const infoFile = fs.readFileSync(btFiles[i], { encoding: 'utf8' }).split('\n');
|
|
106
|
-
result.push(parseLinuxBluetoothInfo(infoFile, macAddr1, macAddr2));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// determine "connected" with hcitool con
|
|
110
|
-
try {
|
|
111
|
-
const hdicon = execSync('hcitool con').toString().toLowerCase();
|
|
112
|
-
for (let i = 0; i < result.length; i++) {
|
|
113
|
-
if (result[i].macDevice && result[i].macDevice.length > 10 && hdicon.indexOf(result[i].macDevice.toLowerCase()) >= 0) {
|
|
114
|
-
result[i].connected = true;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
} catch (e) {
|
|
118
|
-
util.noop();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (callback) {
|
|
122
|
-
callback(result);
|
|
123
|
-
}
|
|
124
|
-
resolve(result);
|
|
125
|
-
}
|
|
126
|
-
if (_darwin) {
|
|
127
|
-
let cmd = 'system_profiler SPBluetoothDataType -json';
|
|
128
|
-
exec(cmd, function (error, stdout) {
|
|
129
|
-
if (!error) {
|
|
130
|
-
try {
|
|
131
|
-
const outObj = JSON.parse(stdout.toString());
|
|
132
|
-
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_title'] && outObj.SPBluetoothDataType[0]['device_title'].length) {
|
|
133
|
-
// missing: host BT Adapter macAddr ()
|
|
134
|
-
let macAddr2 = null;
|
|
135
|
-
if (outObj.SPBluetoothDataType[0]['local_device_title'] && outObj.SPBluetoothDataType[0].local_device_title.general_address) {
|
|
136
|
-
macAddr2 = outObj.SPBluetoothDataType[0].local_device_title.general_address.toLowerCase().replace(/-/g, ':');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
for (let i = 0; i < outObj.SPBluetoothDataType[0]['device_title'].length; i++) {
|
|
140
|
-
const obj = outObj.SPBluetoothDataType[0]['device_title'][i];
|
|
141
|
-
const objKey = Object.keys(obj);
|
|
142
|
-
if (objKey && objKey.length === 1) {
|
|
143
|
-
const innerObject = obj[objKey[0]];
|
|
144
|
-
innerObject.device_name = objKey[0];
|
|
145
|
-
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
|
146
|
-
result.push(bluetoothDevice);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
} catch (e) {
|
|
151
|
-
util.noop();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (callback) {
|
|
155
|
-
callback(result);
|
|
156
|
-
}
|
|
157
|
-
resolve(result);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
if (_windows) {
|
|
161
|
-
util.
|
|
162
|
-
if (!error) {
|
|
163
|
-
const parts = stdout.toString().split(/\n\s*\n/);
|
|
164
|
-
for (let i = 0; i < parts.length; i++) {
|
|
165
|
-
if (util.getValue(parts[i].split('\n'), 'PNPClass', '
|
|
166
|
-
result.push(parseWindowsBluetooth(parts[i].split('\n')));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (callback) {
|
|
171
|
-
callback(result);
|
|
172
|
-
}
|
|
173
|
-
resolve(result);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
if (_freebsd || _netbsd || _openbsd || _sunos) {
|
|
177
|
-
resolve(null);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
exports.bluetoothDevices = bluetoothDevices;
|
|
1
|
+
'use strict';
|
|
2
|
+
// @ts-check
|
|
3
|
+
// ==================================================================================
|
|
4
|
+
// audio.js
|
|
5
|
+
// ----------------------------------------------------------------------------------
|
|
6
|
+
// Description: System Information - library
|
|
7
|
+
// for Node.js
|
|
8
|
+
// Copyright: (c) 2014 - 2021
|
|
9
|
+
// Author: Sebastian Hildebrandt
|
|
10
|
+
// ----------------------------------------------------------------------------------
|
|
11
|
+
// License: MIT
|
|
12
|
+
// ==================================================================================
|
|
13
|
+
// 17. bluetooth
|
|
14
|
+
// ----------------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
const exec = require('child_process').exec;
|
|
17
|
+
const execSync = require('child_process').execSync;
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const util = require('./util');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
let _platform = process.platform;
|
|
23
|
+
|
|
24
|
+
const _linux = (_platform === 'linux');
|
|
25
|
+
const _darwin = (_platform === 'darwin');
|
|
26
|
+
const _windows = (_platform === 'win32');
|
|
27
|
+
const _freebsd = (_platform === 'freebsd');
|
|
28
|
+
const _openbsd = (_platform === 'openbsd');
|
|
29
|
+
const _netbsd = (_platform === 'netbsd');
|
|
30
|
+
const _sunos = (_platform === 'sunos');
|
|
31
|
+
|
|
32
|
+
function parseBluetoothType(str) {
|
|
33
|
+
let result = '';
|
|
34
|
+
|
|
35
|
+
if (str.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
|
|
36
|
+
if (str.indexOf('mouse') >= 0) { result = 'Mouse'; }
|
|
37
|
+
if (str.indexOf('speaker') >= 0) { result = 'Speaker'; }
|
|
38
|
+
if (str.indexOf('headset') >= 0) { result = 'Headset'; }
|
|
39
|
+
if (str.indexOf('phone') >= 0) { result = 'Phone'; }
|
|
40
|
+
// to be continued ...
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseLinuxBluetoothInfo(lines, macAddr1, macAddr2) {
|
|
46
|
+
const result = {};
|
|
47
|
+
|
|
48
|
+
result.device = null;
|
|
49
|
+
result.name = util.getValue(lines, 'name', '=');
|
|
50
|
+
result.manufacturer = null;
|
|
51
|
+
result.macDevice = macAddr1;
|
|
52
|
+
result.macHost = macAddr2;
|
|
53
|
+
result.batteryPercent = null;
|
|
54
|
+
result.type = parseBluetoothType(result.name.toLowerCase());
|
|
55
|
+
result.connected = false;
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
|
|
61
|
+
const result = {};
|
|
62
|
+
const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || '') + (bluetoothObject.device_name || '')).toLowerCase();
|
|
63
|
+
|
|
64
|
+
result.device = bluetoothObject.device_services || '';
|
|
65
|
+
result.name = bluetoothObject.device_name || '';
|
|
66
|
+
result.manufacturer = bluetoothObject.device_manufacturer || '';
|
|
67
|
+
result.macDevice = (bluetoothObject.device_addr || '').toLowerCase().replace(/-/g, ':');
|
|
68
|
+
result.macHost = macAddr2;
|
|
69
|
+
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
|
|
70
|
+
result.type = parseBluetoothType(typeStr);
|
|
71
|
+
result.connected = bluetoothObject.device_isconnected === 'attrib_Yes' || false;
|
|
72
|
+
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function parseWindowsBluetooth(lines) {
|
|
77
|
+
const result = {};
|
|
78
|
+
|
|
79
|
+
result.device = null;
|
|
80
|
+
result.name = util.getValue(lines, 'name', ':');
|
|
81
|
+
result.manufacturer = util.getValue(lines, 'manufacturer', ':');
|
|
82
|
+
result.macDevice = null;
|
|
83
|
+
result.macHost = null;
|
|
84
|
+
result.batteryPercent = null;
|
|
85
|
+
result.type = parseBluetoothType(result.name.toLowerCase());
|
|
86
|
+
result.connected = null;
|
|
87
|
+
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function bluetoothDevices(callback) {
|
|
92
|
+
|
|
93
|
+
return new Promise((resolve) => {
|
|
94
|
+
process.nextTick(() => {
|
|
95
|
+
let result = [];
|
|
96
|
+
if (_linux) {
|
|
97
|
+
// get files in /var/lib/bluetooth/ recursive
|
|
98
|
+
const btFiles = util.getFilesInPath('/var/lib/bluetooth/');
|
|
99
|
+
for (let i = 0; i < btFiles.length; i++) {
|
|
100
|
+
const filename = path.basename(btFiles[i]);
|
|
101
|
+
const pathParts = btFiles[i].split('/');
|
|
102
|
+
const macAddr1 = pathParts.length >= 6 ? pathParts[pathParts.length - 2] : null;
|
|
103
|
+
const macAddr2 = pathParts.length >= 7 ? pathParts[pathParts.length - 3] : null;
|
|
104
|
+
if (filename === 'info') {
|
|
105
|
+
const infoFile = fs.readFileSync(btFiles[i], { encoding: 'utf8' }).split('\n');
|
|
106
|
+
result.push(parseLinuxBluetoothInfo(infoFile, macAddr1, macAddr2));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// determine "connected" with hcitool con
|
|
110
|
+
try {
|
|
111
|
+
const hdicon = execSync('hcitool con').toString().toLowerCase();
|
|
112
|
+
for (let i = 0; i < result.length; i++) {
|
|
113
|
+
if (result[i].macDevice && result[i].macDevice.length > 10 && hdicon.indexOf(result[i].macDevice.toLowerCase()) >= 0) {
|
|
114
|
+
result[i].connected = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch (e) {
|
|
118
|
+
util.noop();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (callback) {
|
|
122
|
+
callback(result);
|
|
123
|
+
}
|
|
124
|
+
resolve(result);
|
|
125
|
+
}
|
|
126
|
+
if (_darwin) {
|
|
127
|
+
let cmd = 'system_profiler SPBluetoothDataType -json';
|
|
128
|
+
exec(cmd, function (error, stdout) {
|
|
129
|
+
if (!error) {
|
|
130
|
+
try {
|
|
131
|
+
const outObj = JSON.parse(stdout.toString());
|
|
132
|
+
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_title'] && outObj.SPBluetoothDataType[0]['device_title'].length) {
|
|
133
|
+
// missing: host BT Adapter macAddr ()
|
|
134
|
+
let macAddr2 = null;
|
|
135
|
+
if (outObj.SPBluetoothDataType[0]['local_device_title'] && outObj.SPBluetoothDataType[0].local_device_title.general_address) {
|
|
136
|
+
macAddr2 = outObj.SPBluetoothDataType[0].local_device_title.general_address.toLowerCase().replace(/-/g, ':');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (let i = 0; i < outObj.SPBluetoothDataType[0]['device_title'].length; i++) {
|
|
140
|
+
const obj = outObj.SPBluetoothDataType[0]['device_title'][i];
|
|
141
|
+
const objKey = Object.keys(obj);
|
|
142
|
+
if (objKey && objKey.length === 1) {
|
|
143
|
+
const innerObject = obj[objKey[0]];
|
|
144
|
+
innerObject.device_name = objKey[0];
|
|
145
|
+
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
|
146
|
+
result.push(bluetoothDevice);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
} catch (e) {
|
|
151
|
+
util.noop();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (callback) {
|
|
155
|
+
callback(result);
|
|
156
|
+
}
|
|
157
|
+
resolve(result);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (_windows) {
|
|
161
|
+
util.powerShell('Get-WmiObject Win32_PNPEntity | fl *').then((stdout, error) => {
|
|
162
|
+
if (!error) {
|
|
163
|
+
const parts = stdout.toString().split(/\n\s*\n/);
|
|
164
|
+
for (let i = 0; i < parts.length; i++) {
|
|
165
|
+
if (util.getValue(parts[i].split('\n'), 'PNPClass', ':') === 'Bluetooth') {
|
|
166
|
+
result.push(parseWindowsBluetooth(parts[i].split('\n')));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (callback) {
|
|
171
|
+
callback(result);
|
|
172
|
+
}
|
|
173
|
+
resolve(result);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
if (_freebsd || _netbsd || _openbsd || _sunos) {
|
|
177
|
+
resolve(null);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
exports.bluetoothDevices = bluetoothDevices;
|
package/lib/cpu.js
CHANGED
|
@@ -751,8 +751,8 @@ function getCpu() {
|
|
|
751
751
|
if (_windows) {
|
|
752
752
|
try {
|
|
753
753
|
const workload = [];
|
|
754
|
-
workload.push(util.
|
|
755
|
-
workload.push(util.
|
|
754
|
+
workload.push(util.powerShell('Get-WmiObject Win32_processor | fl *'));
|
|
755
|
+
workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Purpose | fl *'));
|
|
756
756
|
// workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
|
|
757
757
|
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
|
|
758
758
|
|
|
@@ -760,7 +760,7 @@ function getCpu() {
|
|
|
760
760
|
workload
|
|
761
761
|
).then(data => {
|
|
762
762
|
let lines = data[0].split('\r\n');
|
|
763
|
-
let name = util.getValue(lines, 'name', '
|
|
763
|
+
let name = util.getValue(lines, 'name', ':') || '';
|
|
764
764
|
if (name.indexOf('@') >= 0) {
|
|
765
765
|
result.brand = name.split('@')[0].trim();
|
|
766
766
|
result.speed = name.split('@')[1] ? parseFloat(name.split('@')[1].trim()) : 0;
|
|
@@ -770,15 +770,15 @@ function getCpu() {
|
|
|
770
770
|
result.speed = 0;
|
|
771
771
|
}
|
|
772
772
|
result = cpuBrandManufacturer(result);
|
|
773
|
-
result.revision = util.getValue(lines, 'revision', '
|
|
773
|
+
result.revision = util.getValue(lines, 'revision', ':');
|
|
774
774
|
result.cache.l1d = 0;
|
|
775
775
|
result.cache.l1i = 0;
|
|
776
|
-
result.cache.l2 = util.getValue(lines, 'l2cachesize', '
|
|
777
|
-
result.cache.l3 = util.getValue(lines, 'l3cachesize', '
|
|
776
|
+
result.cache.l2 = util.getValue(lines, 'l2cachesize', ':');
|
|
777
|
+
result.cache.l3 = util.getValue(lines, 'l3cachesize', ':');
|
|
778
778
|
if (result.cache.l2) { result.cache.l2 = parseInt(result.cache.l2, 10) * 1024; }
|
|
779
779
|
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3, 10) * 1024; }
|
|
780
|
-
result.vendor = util.getValue(lines, 'manufacturer', '
|
|
781
|
-
result.speedMax = Math.round(parseFloat(util.getValue(lines, 'maxclockspeed', '
|
|
780
|
+
result.vendor = util.getValue(lines, 'manufacturer', ':');
|
|
781
|
+
result.speedMax = Math.round(parseFloat(util.getValue(lines, 'maxclockspeed', ':').replace(/,/g, '.')) / 10.0) / 100;
|
|
782
782
|
if (result.speed === 0 && (result.brand.indexOf('AMD') > -1 || result.brand.toLowerCase().indexOf('ryzen') > -1)) {
|
|
783
783
|
result.speed = getAMDSpeed(result.brand);
|
|
784
784
|
}
|
|
@@ -787,7 +787,7 @@ function getCpu() {
|
|
|
787
787
|
}
|
|
788
788
|
result.speedMin = result.speed;
|
|
789
789
|
|
|
790
|
-
let description = util.getValue(lines, 'description', '
|
|
790
|
+
let description = util.getValue(lines, 'description', ':').split(' ');
|
|
791
791
|
for (let i = 0; i < description.length; i++) {
|
|
792
792
|
if (description[i].toLowerCase().startsWith('family') && (i + 1) < description.length && description[i + 1]) {
|
|
793
793
|
result.family = description[i + 1];
|
|
@@ -800,14 +800,14 @@ function getCpu() {
|
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
802
|
// socket type
|
|
803
|
-
const socketId = util.getValue(lines, 'UpgradeMethod', '
|
|
803
|
+
const socketId = util.getValue(lines, 'UpgradeMethod', ':');
|
|
804
804
|
if (socketTypes[socketId]) {
|
|
805
805
|
result.socket = socketTypes[socketId];
|
|
806
806
|
}
|
|
807
807
|
// # threads / # cores
|
|
808
808
|
const countProcessors = util.countLines(lines, 'Caption');
|
|
809
|
-
const countThreads = util.getValue(lines, 'NumberOfLogicalProcessors', '
|
|
810
|
-
const countCores = util.getValue(lines, 'NumberOfCores', '
|
|
809
|
+
const countThreads = util.getValue(lines, 'NumberOfLogicalProcessors', ':');
|
|
810
|
+
const countCores = util.getValue(lines, 'NumberOfCores', ':');
|
|
811
811
|
if (countProcessors) {
|
|
812
812
|
result.processors = parseInt(countProcessors) || 1;
|
|
813
813
|
}
|
|
@@ -819,18 +819,19 @@ function getCpu() {
|
|
|
819
819
|
result.cores = result.cores * countProcessors;
|
|
820
820
|
result.physicalCores = result.physicalCores * countProcessors;
|
|
821
821
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
822
|
+
const parts = data[1].split(/\n\s*\n/);
|
|
823
|
+
parts.forEach(function (part) {
|
|
824
|
+
lines = part.split('\r\n');
|
|
825
|
+
const cacheType = util.getValue(lines, 'CacheType');
|
|
826
|
+
const purpose = util.getValue(lines, 'Purpose');
|
|
827
|
+
const installedSize = util.getValue(lines, 'InstalledSize');
|
|
828
|
+
// L1 Instructions
|
|
829
|
+
if (purpose === 'L1 Cache' && cacheType === '3') {
|
|
830
|
+
result.cache.l1i = parseInt(installedSize, 10);
|
|
831
|
+
}
|
|
832
|
+
// L1 Data
|
|
833
|
+
if (purpose === 'L1 Cache' && cacheType === '4') {
|
|
834
|
+
result.cache.l1d = parseInt(installedSize, 10);
|
|
834
835
|
}
|
|
835
836
|
});
|
|
836
837
|
// lines = data[2].split('\r\n');
|
|
@@ -1134,7 +1135,7 @@ function cpuTemperature(callback) {
|
|
|
1134
1135
|
}
|
|
1135
1136
|
if (_windows) {
|
|
1136
1137
|
try {
|
|
1137
|
-
util.
|
|
1138
|
+
util.powerShell('Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi" | Select CurrentTemperature').then((stdout, error) => {
|
|
1138
1139
|
if (!error) {
|
|
1139
1140
|
let sum = 0;
|
|
1140
1141
|
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
|
@@ -1373,30 +1374,31 @@ function cpuCache(callback) {
|
|
|
1373
1374
|
}
|
|
1374
1375
|
if (_windows) {
|
|
1375
1376
|
try {
|
|
1376
|
-
util.
|
|
1377
|
+
util.powerShell('Get-WmiObject Win32_processor | fl *').then((stdout, error) => {
|
|
1377
1378
|
if (!error) {
|
|
1378
1379
|
let lines = stdout.split('\r\n');
|
|
1379
1380
|
result.l1d = 0;
|
|
1380
1381
|
result.l1i = 0;
|
|
1381
|
-
result.l2 = util.getValue(lines, 'l2cachesize', '
|
|
1382
|
-
result.l3 = util.getValue(lines, 'l3cachesize', '
|
|
1382
|
+
result.l2 = util.getValue(lines, 'l2cachesize', ':');
|
|
1383
|
+
result.l3 = util.getValue(lines, 'l3cachesize', ':');
|
|
1383
1384
|
if (result.l2) { result.l2 = parseInt(result.l2, 10) * 1024; }
|
|
1384
1385
|
if (result.l3) { result.l3 = parseInt(result.l3, 10) * 1024; }
|
|
1385
1386
|
}
|
|
1386
|
-
util.
|
|
1387
|
+
util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Purpose | fl ').then((stdout, error) => {
|
|
1387
1388
|
if (!error) {
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1389
|
+
const parts = stdout.split(/\n\s*\n/);
|
|
1390
|
+
parts.forEach(function (part) {
|
|
1391
|
+
const lines = part.split('\r\n');
|
|
1392
|
+
const cacheType = util.getValue(lines, 'CacheType');
|
|
1393
|
+
const purpose = util.getValue(lines, 'Purpose');
|
|
1394
|
+
const installedSize = util.getValue(lines, 'InstalledSize');
|
|
1395
|
+
// L1 Instructions
|
|
1396
|
+
if (purpose === 'L1 Cache' && cacheType === '3') {
|
|
1397
|
+
result.l1i = parseInt(installedSize, 10);
|
|
1398
|
+
}
|
|
1399
|
+
// L1 Data
|
|
1400
|
+
if (purpose === 'L1 Cache' && cacheType === '4') {
|
|
1401
|
+
result.l1d = parseInt(installedSize, 10);
|
|
1400
1402
|
}
|
|
1401
1403
|
});
|
|
1402
1404
|
}
|