code-poltergeist-system-monitor 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of code-poltergeist-system-monitor might be problematic. Click here for more details.
- package/index.js +74 -0
- package/package.json +21 -0
- package/te/node_modules/.package-lock.json +44 -0
- package/te/node_modules/code-poltergeist-system-monitor/index.js +74 -0
- package/te/node_modules/code-poltergeist-system-monitor/package.json +21 -0
- package/te/node_modules/systeminformation/LICENSE +20 -0
- package/te/node_modules/systeminformation/README.md +1116 -0
- package/te/node_modules/systeminformation/lib/audio.js +222 -0
- package/te/node_modules/systeminformation/lib/battery.js +311 -0
- package/te/node_modules/systeminformation/lib/bluetooth.js +231 -0
- package/te/node_modules/systeminformation/lib/cli.js +91 -0
- package/te/node_modules/systeminformation/lib/cpu.js +1834 -0
- package/te/node_modules/systeminformation/lib/docker.js +758 -0
- package/te/node_modules/systeminformation/lib/dockerSocket.js +327 -0
- package/te/node_modules/systeminformation/lib/filesystem.js +1510 -0
- package/te/node_modules/systeminformation/lib/graphics.js +1125 -0
- package/te/node_modules/systeminformation/lib/index.d.ts +1041 -0
- package/te/node_modules/systeminformation/lib/index.js +504 -0
- package/te/node_modules/systeminformation/lib/internet.js +237 -0
- package/te/node_modules/systeminformation/lib/memory.js +575 -0
- package/te/node_modules/systeminformation/lib/network.js +1783 -0
- package/te/node_modules/systeminformation/lib/osinfo.js +1179 -0
- package/te/node_modules/systeminformation/lib/printer.js +210 -0
- package/te/node_modules/systeminformation/lib/processes.js +1296 -0
- package/te/node_modules/systeminformation/lib/system.js +742 -0
- package/te/node_modules/systeminformation/lib/usb.js +279 -0
- package/te/node_modules/systeminformation/lib/users.js +363 -0
- package/te/node_modules/systeminformation/lib/util.js +1373 -0
- package/te/node_modules/systeminformation/lib/virtualbox.js +107 -0
- package/te/node_modules/systeminformation/lib/wifi.js +834 -0
- package/te/node_modules/systeminformation/package.json +99 -0
- package/te/package-lock.json +52 -0
- package/te/package.json +15 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
'use strict';
|
2
|
+
// @ts-check
|
3
|
+
// ==================================================================================
|
4
|
+
// audio.js
|
5
|
+
// ----------------------------------------------------------------------------------
|
6
|
+
// Description: System Information - library
|
7
|
+
// for Node.js
|
8
|
+
// Copyright: (c) 2014 - 2024
|
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('trackpad') >= 0) { result = 'Trackpad'; }
|
38
|
+
if (str.indexOf('speaker') >= 0) { result = 'Speaker'; }
|
39
|
+
if (str.indexOf('headset') >= 0) { result = 'Headset'; }
|
40
|
+
if (str.indexOf('phone') >= 0) { result = 'Phone'; }
|
41
|
+
if (str.indexOf('macbook') >= 0) { result = 'Computer'; }
|
42
|
+
if (str.indexOf('imac') >= 0) { result = 'Computer'; }
|
43
|
+
if (str.indexOf('ipad') >= 0) { result = 'Tablet'; }
|
44
|
+
if (str.indexOf('watch') >= 0) { result = 'Watch'; }
|
45
|
+
if (str.indexOf('headphone') >= 0) { result = 'Headset'; }
|
46
|
+
// to be continued ...
|
47
|
+
|
48
|
+
return result;
|
49
|
+
}
|
50
|
+
|
51
|
+
function parseBluetoothManufacturer(str) {
|
52
|
+
let result = str.split(' ')[0];
|
53
|
+
str = str.toLowerCase();
|
54
|
+
if (str.indexOf('apple') >= 0) { result = 'Apple'; }
|
55
|
+
if (str.indexOf('ipad') >= 0) { result = 'Apple'; }
|
56
|
+
if (str.indexOf('imac') >= 0) { result = 'Apple'; }
|
57
|
+
if (str.indexOf('iphone') >= 0) { result = 'Apple'; }
|
58
|
+
if (str.indexOf('magic mouse') >= 0) { result = 'Apple'; }
|
59
|
+
if (str.indexOf('magic track') >= 0) { result = 'Apple'; }
|
60
|
+
if (str.indexOf('macbook') >= 0) { result = 'Apple'; }
|
61
|
+
// to be continued ...
|
62
|
+
|
63
|
+
return result;
|
64
|
+
}
|
65
|
+
|
66
|
+
function parseLinuxBluetoothInfo(lines, macAddr1, macAddr2) {
|
67
|
+
const result = {};
|
68
|
+
|
69
|
+
result.device = null;
|
70
|
+
result.name = util.getValue(lines, 'name', '=');
|
71
|
+
result.manufacturer = null;
|
72
|
+
result.macDevice = macAddr1;
|
73
|
+
result.macHost = macAddr2;
|
74
|
+
result.batteryPercent = null;
|
75
|
+
result.type = parseBluetoothType(result.name.toLowerCase());
|
76
|
+
result.connected = false;
|
77
|
+
|
78
|
+
return result;
|
79
|
+
}
|
80
|
+
|
81
|
+
function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
|
82
|
+
const result = {};
|
83
|
+
const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || bluetoothObject.device_minorType || '') + (bluetoothObject.device_name || '')).toLowerCase();
|
84
|
+
|
85
|
+
result.device = bluetoothObject.device_services || '';
|
86
|
+
result.name = bluetoothObject.device_name || '';
|
87
|
+
result.manufacturer = bluetoothObject.device_manufacturer || parseBluetoothManufacturer(bluetoothObject.device_name || '') || '';
|
88
|
+
result.macDevice = (bluetoothObject.device_addr || bluetoothObject.device_address || '').toLowerCase().replace(/-/g, ':');
|
89
|
+
result.macHost = macAddr2;
|
90
|
+
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
|
91
|
+
result.type = parseBluetoothType(typeStr);
|
92
|
+
result.connected = bluetoothObject.device_isconnected === 'attrib_Yes' || false;
|
93
|
+
|
94
|
+
return result;
|
95
|
+
}
|
96
|
+
|
97
|
+
function parseWindowsBluetooth(lines) {
|
98
|
+
const result = {};
|
99
|
+
|
100
|
+
result.device = null;
|
101
|
+
result.name = util.getValue(lines, 'name', ':');
|
102
|
+
result.manufacturer = util.getValue(lines, 'manufacturer', ':');
|
103
|
+
result.macDevice = null;
|
104
|
+
result.macHost = null;
|
105
|
+
result.batteryPercent = null;
|
106
|
+
result.type = parseBluetoothType(result.name.toLowerCase());
|
107
|
+
result.connected = null;
|
108
|
+
|
109
|
+
return result;
|
110
|
+
}
|
111
|
+
|
112
|
+
function bluetoothDevices(callback) {
|
113
|
+
|
114
|
+
return new Promise((resolve) => {
|
115
|
+
process.nextTick(() => {
|
116
|
+
let result = [];
|
117
|
+
if (_linux) {
|
118
|
+
// get files in /var/lib/bluetooth/ recursive
|
119
|
+
const btFiles = util.getFilesInPath('/var/lib/bluetooth/');
|
120
|
+
btFiles.forEach((element) => {
|
121
|
+
const filename = path.basename(element);
|
122
|
+
const pathParts = element.split('/');
|
123
|
+
const macAddr1 = pathParts.length >= 6 ? pathParts[pathParts.length - 2] : null;
|
124
|
+
const macAddr2 = pathParts.length >= 7 ? pathParts[pathParts.length - 3] : null;
|
125
|
+
if (filename === 'info') {
|
126
|
+
const infoFile = fs.readFileSync(element, { encoding: 'utf8' }).split('\n');
|
127
|
+
result.push(parseLinuxBluetoothInfo(infoFile, macAddr1, macAddr2));
|
128
|
+
}
|
129
|
+
});
|
130
|
+
// determine "connected" with hcitool con
|
131
|
+
try {
|
132
|
+
const hdicon = execSync('hcitool con', util.execOptsLinux).toString().toLowerCase();
|
133
|
+
for (let i = 0; i < result.length; i++) {
|
134
|
+
if (result[i].macDevice && result[i].macDevice.length > 10 && hdicon.indexOf(result[i].macDevice.toLowerCase()) >= 0) {
|
135
|
+
result[i].connected = true;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
} catch (e) {
|
139
|
+
util.noop();
|
140
|
+
}
|
141
|
+
|
142
|
+
if (callback) {
|
143
|
+
callback(result);
|
144
|
+
}
|
145
|
+
resolve(result);
|
146
|
+
}
|
147
|
+
if (_darwin) {
|
148
|
+
let cmd = 'system_profiler SPBluetoothDataType -json';
|
149
|
+
exec(cmd, function (error, stdout) {
|
150
|
+
if (!error) {
|
151
|
+
try {
|
152
|
+
const outObj = JSON.parse(stdout.toString());
|
153
|
+
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_title'] && outObj.SPBluetoothDataType[0]['device_title'].length) {
|
154
|
+
// missing: host BT Adapter macAddr ()
|
155
|
+
let macAddr2 = null;
|
156
|
+
if (outObj.SPBluetoothDataType[0]['local_device_title'] && outObj.SPBluetoothDataType[0].local_device_title.general_address) {
|
157
|
+
macAddr2 = outObj.SPBluetoothDataType[0].local_device_title.general_address.toLowerCase().replace(/-/g, ':');
|
158
|
+
}
|
159
|
+
outObj.SPBluetoothDataType[0]['device_title'].forEach((element) => {
|
160
|
+
const obj = element;
|
161
|
+
const objKey = Object.keys(obj);
|
162
|
+
if (objKey && objKey.length === 1) {
|
163
|
+
const innerObject = obj[objKey[0]];
|
164
|
+
innerObject.device_name = objKey[0];
|
165
|
+
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
166
|
+
result.push(bluetoothDevice);
|
167
|
+
}
|
168
|
+
});
|
169
|
+
}
|
170
|
+
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_connected'] && outObj.SPBluetoothDataType[0]['device_connected'].length) {
|
171
|
+
const macAddr2 = outObj.SPBluetoothDataType[0].controller_properties && outObj.SPBluetoothDataType[0].controller_properties.controller_address ? outObj.SPBluetoothDataType[0].controller_properties.controller_address.toLowerCase().replace(/-/g, ':') : null;
|
172
|
+
outObj.SPBluetoothDataType[0]['device_connected'].forEach((element) => {
|
173
|
+
const obj = element;
|
174
|
+
const objKey = Object.keys(obj);
|
175
|
+
if (objKey && objKey.length === 1) {
|
176
|
+
const innerObject = obj[objKey[0]];
|
177
|
+
innerObject.device_name = objKey[0];
|
178
|
+
innerObject.device_isconnected = 'attrib_Yes';
|
179
|
+
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
180
|
+
result.push(bluetoothDevice);
|
181
|
+
}
|
182
|
+
});
|
183
|
+
}
|
184
|
+
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_not_connected'] && outObj.SPBluetoothDataType[0]['device_not_connected'].length) {
|
185
|
+
const macAddr2 = outObj.SPBluetoothDataType[0].controller_properties && outObj.SPBluetoothDataType[0].controller_properties.controller_address ? outObj.SPBluetoothDataType[0].controller_properties.controller_address.toLowerCase().replace(/-/g, ':') : null;
|
186
|
+
outObj.SPBluetoothDataType[0]['device_not_connected'].forEach((element) => {
|
187
|
+
const obj = element;
|
188
|
+
const objKey = Object.keys(obj);
|
189
|
+
if (objKey && objKey.length === 1) {
|
190
|
+
const innerObject = obj[objKey[0]];
|
191
|
+
innerObject.device_name = objKey[0];
|
192
|
+
innerObject.device_isconnected = 'attrib_No';
|
193
|
+
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
194
|
+
result.push(bluetoothDevice);
|
195
|
+
}
|
196
|
+
});
|
197
|
+
}
|
198
|
+
} catch (e) {
|
199
|
+
util.noop();
|
200
|
+
}
|
201
|
+
}
|
202
|
+
if (callback) {
|
203
|
+
callback(result);
|
204
|
+
}
|
205
|
+
resolve(result);
|
206
|
+
});
|
207
|
+
}
|
208
|
+
if (_windows) {
|
209
|
+
util.powerShell('Get-CimInstance Win32_PNPEntity | select PNPClass, Name, Manufacturer | fl').then((stdout, error) => {
|
210
|
+
if (!error) {
|
211
|
+
const parts = stdout.toString().split(/\n\s*\n/);
|
212
|
+
parts.forEach((part) => {
|
213
|
+
if (util.getValue(part.split('\n'), 'PNPClass', ':') === 'Bluetooth') {
|
214
|
+
result.push(parseWindowsBluetooth(part.split('\n')));
|
215
|
+
}
|
216
|
+
});
|
217
|
+
}
|
218
|
+
if (callback) {
|
219
|
+
callback(result);
|
220
|
+
}
|
221
|
+
resolve(result);
|
222
|
+
});
|
223
|
+
}
|
224
|
+
if (_freebsd || _netbsd || _openbsd || _sunos) {
|
225
|
+
resolve(null);
|
226
|
+
}
|
227
|
+
});
|
228
|
+
});
|
229
|
+
}
|
230
|
+
|
231
|
+
exports.bluetoothDevices = bluetoothDevices;
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
'use strict';
|
4
|
+
// @ts-check
|
5
|
+
// ==================================================================================
|
6
|
+
// cli.js
|
7
|
+
// ----------------------------------------------------------------------------------
|
8
|
+
// Description: System Information - library
|
9
|
+
// for Node.js
|
10
|
+
// Copyright: (c) 2014 - 2024
|
11
|
+
// Author: Sebastian Hildebrandt
|
12
|
+
// ----------------------------------------------------------------------------------
|
13
|
+
// License: MIT
|
14
|
+
// ==================================================================================
|
15
|
+
|
16
|
+
// ----------------------------------------------------------------------------------
|
17
|
+
// Dependencies
|
18
|
+
// ----------------------------------------------------------------------------------
|
19
|
+
const si = require('./index');
|
20
|
+
const lib_version = require('../package.json').version;
|
21
|
+
|
22
|
+
function capFirst(string) {
|
23
|
+
return string[0].toUpperCase() + string.slice(1);
|
24
|
+
}
|
25
|
+
|
26
|
+
function printLines(obj) {
|
27
|
+
for (const property in obj) {
|
28
|
+
console.log(capFirst(property) + ' '.substring(0, 17 - property.length) + ': ' + (obj[property] || ''));
|
29
|
+
}
|
30
|
+
console.log();
|
31
|
+
}
|
32
|
+
|
33
|
+
function info() {
|
34
|
+
console.log('┌─────────────────────────────────────────────────────────────────────────────────────────┐');
|
35
|
+
console.log('│ SYSTEMINFORMATION '.substring(0, 80 - lib_version.length) + 'Version: ' + lib_version + ' │');
|
36
|
+
console.log('└─────────────────────────────────────────────────────────────────────────────────────────┘');
|
37
|
+
|
38
|
+
si.osInfo().then(res => {
|
39
|
+
console.log();
|
40
|
+
console.log('Operating System:');
|
41
|
+
console.log('──────────────────────────────────────────────────────────────────────────────────────────');
|
42
|
+
delete res.serial;
|
43
|
+
delete res.servicepack;
|
44
|
+
delete res.logofile;
|
45
|
+
delete res.fqdn;
|
46
|
+
delete res.uefi;
|
47
|
+
printLines(res);
|
48
|
+
si.system().then(res => {
|
49
|
+
console.log('System:');
|
50
|
+
console.log('──────────────────────────────────────────────────────────────────────────────────────────');
|
51
|
+
delete res.serial;
|
52
|
+
delete res.uuid;
|
53
|
+
delete res.sku;
|
54
|
+
delete res.uuid;
|
55
|
+
printLines(res);
|
56
|
+
si.cpu().then(res => {
|
57
|
+
console.log('CPU:');
|
58
|
+
console.log('──────────────────────────────────────────────────────────────────────────────────────────');
|
59
|
+
delete res.cache;
|
60
|
+
delete res.governor;
|
61
|
+
delete res.flags;
|
62
|
+
delete res.virtualization;
|
63
|
+
delete res.revision;
|
64
|
+
delete res.voltage;
|
65
|
+
delete res.vendor;
|
66
|
+
delete res.speedMin;
|
67
|
+
delete res.speedMax;
|
68
|
+
printLines(res);
|
69
|
+
});
|
70
|
+
});
|
71
|
+
});
|
72
|
+
}
|
73
|
+
|
74
|
+
// ----------------------------------------------------------------------------------
|
75
|
+
// Main
|
76
|
+
// ----------------------------------------------------------------------------------
|
77
|
+
(function () {
|
78
|
+
const args = process.argv.slice(2);
|
79
|
+
|
80
|
+
if (args[0] === 'info') {
|
81
|
+
info();
|
82
|
+
} else {
|
83
|
+
si.getStaticData().then(
|
84
|
+
((data) => {
|
85
|
+
data.time = si.time();
|
86
|
+
console.log(JSON.stringify(data, null, 2));
|
87
|
+
}
|
88
|
+
));
|
89
|
+
}
|
90
|
+
|
91
|
+
})();
|