systeminformation 5.9.16 → 5.10.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/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 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;
1
+ 'use strict';
2
+ // @ts-check
3
+ // ==================================================================================
4
+ // audio.js
5
+ // ----------------------------------------------------------------------------------
6
+ // Description: System Information - library
7
+ // for Node.js
8
+ // Copyright: (c) 2014 - 2022
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' || _platform === 'android');
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/cli.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------------
8
8
  // Description: System Information - library
9
9
  // for Node.js
10
- // Copyright: (c) 2014 - 2021
10
+ // Copyright: (c) 2014 - 2022
11
11
  // Author: Sebastian Hildebrandt
12
12
  // ----------------------------------------------------------------------------------
13
13
  // License: MIT
@@ -21,7 +21,7 @@ const si = require('./index');
21
21
  // ----------------------------------------------------------------------------------
22
22
  // Main
23
23
  // ----------------------------------------------------------------------------------
24
- (function() {
24
+ (function () {
25
25
  si.getStaticData().then(
26
26
  (data => {
27
27
  data.time = si.time();
package/lib/cpu.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // ----------------------------------------------------------------------------------
6
6
  // Description: System Information - library
7
7
  // for Node.js
8
- // Copyright: (c) 2014 - 2021
8
+ // Copyright: (c) 2014 - 2022
9
9
  // Author: Sebastian Hildebrandt
10
10
  // ----------------------------------------------------------------------------------
11
11
  // License: MIT
@@ -21,7 +21,7 @@ const util = require('./util');
21
21
 
22
22
  let _platform = process.platform;
23
23
 
24
- const _linux = (_platform === 'linux');
24
+ const _linux = (_platform === 'linux' || _platform === 'android');
25
25
  const _darwin = (_platform === 'darwin');
26
26
  const _windows = (_platform === 'win32');
27
27
  const _freebsd = (_platform === 'freebsd');
@@ -515,12 +515,29 @@ const socketTypes = {
515
515
  63: 'LGA4677',
516
516
  };
517
517
 
518
+ function cpuManufacturer(str) {
519
+ let result = str;
520
+ str = str.toLowerCase();
521
+
522
+ if (str.indexOf('intel') >= 0) { result = 'Intel'; }
523
+ if (str.indexOf('amd') >= 0) { result = 'AMD'; }
524
+ if (str.indexOf('qemu') >= 0) { result = 'QEMU'; }
525
+ if (str.indexOf('hygon') >= 0) { result = 'Hygon'; }
526
+ if (str.indexOf('centaur') >= 0) { result = 'WinChip/Via'; }
527
+ if (str.indexOf('vmware') >= 0) { result = 'VMware'; }
528
+ if (str.indexOf('Xen') >= 0) { result = 'Xen Hypervisor'; }
529
+ if (str.indexOf('tcg') >= 0) { result = 'QEMU'; }
530
+ if (str.indexOf('apple') >= 0) { result = 'Apple'; }
531
+
532
+ return result;
533
+ }
534
+
518
535
  function cpuBrandManufacturer(res) {
519
536
  res.brand = res.brand.replace(/\(R\)+/g, '®').replace(/\s+/g, ' ').trim();
520
537
  res.brand = res.brand.replace(/\(TM\)+/g, '™').replace(/\s+/g, ' ').trim();
521
538
  res.brand = res.brand.replace(/\(C\)+/g, '©').replace(/\s+/g, ' ').trim();
522
539
  res.brand = res.brand.replace(/CPU+/g, '').replace(/\s+/g, ' ').trim();
523
- res.manufacturer = res.brand.split(' ')[0];
540
+ res.manufacturer = cpuManufacturer(res.brand);
524
541
 
525
542
  let parts = res.brand.split(' ');
526
543
  parts.shift();
@@ -655,7 +672,7 @@ function getCpu() {
655
672
  result.speedMax = Math.round(parseFloat(util.getValue(lines, 'cpu max mhz').replace(/,/g, '.')) / 10.0) / 100;
656
673
 
657
674
  result = cpuBrandManufacturer(result);
658
- result.vendor = util.getValue(lines, 'vendor id');
675
+ result.vendor = cpuManufacturer(util.getValue(lines, 'vendor id'));
659
676
  // if (!result.vendor) { result.vendor = util.getValue(lines, 'anbieterkennung'); }
660
677
 
661
678
  result.family = util.getValue(lines, 'cpu family');
@@ -733,7 +750,7 @@ function getCpu() {
733
750
  result.speedMax = Math.round(parseFloat(util.getValue(lines, 'max speed').replace(/Mhz/g, '')) / 10.0) / 100;
734
751
 
735
752
  result = cpuBrandManufacturer(result);
736
- result.vendor = util.getValue(lines, 'manufacturer');
753
+ result.vendor = cpuManufacturer(util.getValue(lines, 'manufacturer'));
737
754
  let sig = util.getValue(lines, 'signature');
738
755
  sig = sig.split(',');
739
756
  for (var i = 0; i < sig.length; i++) {
package/lib/docker.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // ----------------------------------------------------------------------------------
6
6
  // Description: System Information - library
7
7
  // for Node.js
8
- // Copyright: (c) 2014 - 2021
8
+ // Copyright: (c) 2014 - 2022
9
9
  // Author: Sebastian Hildebrandt
10
10
  // ----------------------------------------------------------------------------------
11
11
  // License: MIT
@@ -5,7 +5,7 @@
5
5
  // ----------------------------------------------------------------------------------
6
6
  // Description: System Information - library
7
7
  // for Node.js
8
- // Copyright: (c) 2014 - 2021
8
+ // Copyright: (c) 2014 - 2022
9
9
  // Author: Sebastian Hildebrandt
10
10
  // ----------------------------------------------------------------------------------
11
11
  // License: MIT
package/lib/filesystem.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // ----------------------------------------------------------------------------------
6
6
  // Description: System Information - library
7
7
  // for Node.js
8
- // Copyright: (c) 2014 - 2021
8
+ // Copyright: (c) 2014 - 2022
9
9
  // Author: Sebastian Hildebrandt
10
10
  // ----------------------------------------------------------------------------------
11
11
  // License: MIT
@@ -22,7 +22,7 @@ const execPromiseSave = util.promisifySave(require('child_process').exec);
22
22
 
23
23
  let _platform = process.platform;
24
24
 
25
- const _linux = (_platform === 'linux');
25
+ const _linux = (_platform === 'linux' || _platform === 'android');
26
26
  const _darwin = (_platform === 'darwin');
27
27
  const _windows = (_platform === 'win32');
28
28
  const _freebsd = (_platform === 'freebsd');
package/lib/graphics.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // ----------------------------------------------------------------------------------
6
6
  // Description: System Information - library
7
7
  // for Node.js
8
- // Copyright: (c) 2014 - 2021
8
+ // Copyright: (c) 2014 - 2022
9
9
  // Author: Sebastian Hildebrandt
10
10
  // ----------------------------------------------------------------------------------
11
11
  // License: MIT
@@ -21,7 +21,7 @@ const util = require('./util');
21
21
  let _platform = process.platform;
22
22
  let _nvidiaSmiPath = '';
23
23
 
24
- const _linux = (_platform === 'linux');
24
+ const _linux = (_platform === 'linux' || _platform === 'android');
25
25
  const _darwin = (_platform === 'darwin');
26
26
  const _windows = (_platform === 'win32');
27
27
  const _freebsd = (_platform === 'freebsd');