systeminformation 5.33.9 → 5.33.11
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/battery.js +32 -11
- package/lib/filesystem.js +89 -15
- package/lib/network.js +2 -0
- package/lib/osinfo.js +17 -3
- package/package.json +1 -1
package/lib/battery.js
CHANGED
|
@@ -29,7 +29,7 @@ const _sunos = _platform === 'sunos';
|
|
|
29
29
|
|
|
30
30
|
function parseWinBatteryPart(lines, designedCapacity, fullChargeCapacity) {
|
|
31
31
|
const result = {};
|
|
32
|
-
|
|
32
|
+
const status = parseInt(util.getValue(lines, 'BatteryStatus', ':').trim(), 10) || 0;
|
|
33
33
|
// let status = util.getValue(lines, 'BatteryStatus', ':').trim();
|
|
34
34
|
// 1 = "Discharging"
|
|
35
35
|
// 2 = "On A/C"
|
|
@@ -111,7 +111,7 @@ module.exports = (callback) =>
|
|
|
111
111
|
if (battery_path) {
|
|
112
112
|
fs.readFile(battery_path + 'uevent', (error, stdout) => {
|
|
113
113
|
if (!error) {
|
|
114
|
-
|
|
114
|
+
const lines = stdout.toString().split('\n');
|
|
115
115
|
|
|
116
116
|
result.isCharging = util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging';
|
|
117
117
|
result.acConnected = acConnected || result.isCharging;
|
|
@@ -176,7 +176,7 @@ module.exports = (callback) =>
|
|
|
176
176
|
}
|
|
177
177
|
if (_freebsd || _openbsd || _netbsd) {
|
|
178
178
|
exec('sysctl -i hw.acpi.battery hw.acpi.acline', (error, stdout) => {
|
|
179
|
-
|
|
179
|
+
const lines = stdout.toString().split('\n');
|
|
180
180
|
const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10);
|
|
181
181
|
const percent = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.life'), 10);
|
|
182
182
|
result.hasBattery = batteries > 0;
|
|
@@ -196,24 +196,45 @@ module.exports = (callback) =>
|
|
|
196
196
|
|
|
197
197
|
if (_darwin) {
|
|
198
198
|
exec(
|
|
199
|
-
'ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage"; pmset -g batt | grep %',
|
|
199
|
+
'ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage|BatteryData|NominalChargeCapacity"; pmset -g batt | grep %',
|
|
200
200
|
(error, stdout) => {
|
|
201
201
|
if (stdout) {
|
|
202
|
-
|
|
202
|
+
const lines = stdout
|
|
203
|
+
.toString()
|
|
204
|
+
.replace(/^[ |]+/gm, '')
|
|
205
|
+
.replace(/ +/g, '')
|
|
206
|
+
.replace(/"+/g, '')
|
|
207
|
+
.replace(/-/g, '')
|
|
208
|
+
.split('\n');
|
|
209
|
+
const voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
|
|
210
|
+
const batteryData = util.getValue(lines, 'BatteryData', '=').replace(/^\{/, '').replace(/\}$/, '').split(',');
|
|
211
|
+
const maxCapacity = Math.round(
|
|
212
|
+
parseInt(
|
|
213
|
+
'0' +
|
|
214
|
+
(util.getValue(lines, 'AppleRawMaxCapacity', '=') ||
|
|
215
|
+
util.getValue(lines, 'NominalChargeCapacity', '=') ||
|
|
216
|
+
util.getValue(batteryData, 'FullChargeCapacity', '=') ||
|
|
217
|
+
util.getValue(batteryData, 'NominalChargeCapacity', '=')),
|
|
218
|
+
10
|
|
219
|
+
) * (voltage || 1)
|
|
220
|
+
);
|
|
221
|
+
const currentCapacity = Math.round(parseInt('0' + (util.getValue(lines, 'AppleRawCurrentCapacity', '=') || util.getValue(batteryData, 'RemainingCapacity', '=')), 10) * (voltage || 1));
|
|
222
|
+
const designedCapacity = Math.round(parseInt('0' + (util.getValue(lines, 'DesignCapacity', '=') || util.getValue(batteryData, 'DesignCapacity', '=')), 10) * (voltage || 1));
|
|
223
|
+
|
|
203
224
|
result.cycleCount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
|
204
|
-
result.voltage =
|
|
225
|
+
result.voltage = voltage;
|
|
205
226
|
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
|
206
|
-
result.maxCapacity =
|
|
207
|
-
result.currentCapacity =
|
|
208
|
-
result.designedCapacity =
|
|
227
|
+
result.maxCapacity = maxCapacity;
|
|
228
|
+
result.currentCapacity = currentCapacity;
|
|
229
|
+
result.designedCapacity = designedCapacity;
|
|
209
230
|
result.manufacturer = 'Apple';
|
|
210
231
|
result.serial = util.getValue(lines, 'BatterySerialNumber', '=') || util.getValue(lines, 'Serial', '=');
|
|
211
232
|
result.model = util.getValue(lines, 'DeviceName', '=');
|
|
212
233
|
let percent = null;
|
|
213
234
|
const line = util.getValue(lines, 'internal', 'Battery');
|
|
214
|
-
|
|
235
|
+
const parts = line.split(';');
|
|
215
236
|
if (parts && parts[0]) {
|
|
216
|
-
|
|
237
|
+
const parts2 = parts[0].split('\t');
|
|
217
238
|
if (parts2 && parts2[1]) {
|
|
218
239
|
percent = parseFloat(parts2[1].trim().replace(/%/g, ''));
|
|
219
240
|
}
|
package/lib/filesystem.js
CHANGED
|
@@ -43,8 +43,20 @@ function fsSize(drive, callback) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
let macOsDisks = [];
|
|
46
|
+
const macOsFsTypes = new Map();
|
|
46
47
|
let osMounts = [];
|
|
47
48
|
|
|
49
|
+
// macOS df has no type column, so the type used to be guessed from diskutil - which only ever
|
|
50
|
+
// produced APFS, HFS or NFS and therefore never recognised zfs, exfat, msdos or smbfs. mount
|
|
51
|
+
// knows the real type, so prefer it and keep the old names for the three it could produce.
|
|
52
|
+
function macOsFsType(fs) {
|
|
53
|
+
const type = macOsFsTypes.get(fs);
|
|
54
|
+
if (!type) {
|
|
55
|
+
return getmacOsFsType(fs);
|
|
56
|
+
}
|
|
57
|
+
return type === 'apfs' ? 'APFS' : type === 'hfs' ? 'HFS' : type === 'nfs' ? 'NFS' : type;
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
function getmacOsFsType(fs) {
|
|
49
61
|
if (!fs.startsWith('/')) {
|
|
50
62
|
return 'NFS';
|
|
@@ -86,6 +98,59 @@ function fsSize(drive, callback) {
|
|
|
86
98
|
return lines;
|
|
87
99
|
}
|
|
88
100
|
|
|
101
|
+
// ZFS datasets share the pool, so df only reports what a dataset references itself - a parent
|
|
102
|
+
// holding its data in child datasets looks empty (#1017). Only `zfs list` knows the
|
|
103
|
+
// hierarchical usage, so query it once when a zfs mount is present.
|
|
104
|
+
function applyZfsUsage(data, cb) {
|
|
105
|
+
if (!data.some((item) => item.type === 'zfs')) {
|
|
106
|
+
return cb(data);
|
|
107
|
+
}
|
|
108
|
+
exec('zfs list -H -p -o name,used,avail,mountpoint', { ...util.execOptsLinux, timeout: 5000 }, (error, stdout) => {
|
|
109
|
+
if (error) {
|
|
110
|
+
// a truncated or timed out listing would correct only part of the datasets and leave the
|
|
111
|
+
// rest on their df values - correct none instead, so the result stays consistent
|
|
112
|
+
return cb(data);
|
|
113
|
+
}
|
|
114
|
+
const byMount = Object.create(null);
|
|
115
|
+
const byName = Object.create(null);
|
|
116
|
+
(stdout || '')
|
|
117
|
+
.toString()
|
|
118
|
+
.split('\n')
|
|
119
|
+
.forEach((line) => {
|
|
120
|
+
const parts = line.split('\t');
|
|
121
|
+
if (parts.length < 4) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const entry = { used: parseInt(parts[1], 10), available: parseInt(parts[2], 10) };
|
|
125
|
+
if (isNaN(entry.used) || isNaN(entry.available)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
byName[parts[0]] = entry;
|
|
129
|
+
const mount = parts[3].trim();
|
|
130
|
+
// several datasets can carry the same mountpoint (root-on-zfs boot environments all
|
|
131
|
+
// declare "/"), so the mount index is only a fallback - keep the first one
|
|
132
|
+
if (mount.startsWith('/') && !byMount[mount]) {
|
|
133
|
+
byMount[mount] = entry;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
data.forEach((item) => {
|
|
137
|
+
if (item.type !== 'zfs') {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// the fs column is the exact dataset name and therefore unambiguous, unlike the mountpoint
|
|
141
|
+
const dataset = byName[item.fs] || byMount[item.mount];
|
|
142
|
+
if (!dataset || !(dataset.used + dataset.available)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
item.used = dataset.used;
|
|
146
|
+
item.available = dataset.available;
|
|
147
|
+
item.size = dataset.used + dataset.available;
|
|
148
|
+
item.use = parseFloat(((100.0 * dataset.used) / item.size).toFixed(2));
|
|
149
|
+
});
|
|
150
|
+
cb(data);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
89
154
|
function parseDf(lines) {
|
|
90
155
|
const data = [];
|
|
91
156
|
// filesystem (first column) and mount point (last column) may contain spaces:
|
|
@@ -98,7 +163,7 @@ function fsSize(drive, callback) {
|
|
|
98
163
|
const parts = line.trim().match(hasType ? dfWithType : dfNoType);
|
|
99
164
|
if (parts && (parts[1].startsWith('/') || parts[hasType ? 6 : 5] === '/' || parts[1].indexOf('/') > 0 || parts[1].indexOf(':') === 1 || (!_darwin && !isLinuxTmpFs(parts[2])))) {
|
|
100
165
|
const fs = parts[1];
|
|
101
|
-
const fsType = hasType ? parts[2] :
|
|
166
|
+
const fsType = hasType ? parts[2] : macOsFsType(parts[1]);
|
|
102
167
|
const size = parseInt(parts[hasType ? 3 : 2], 10) * 1024;
|
|
103
168
|
const used = parseInt(parts[hasType ? 4 : 3], 10) * 1024;
|
|
104
169
|
const available = parseInt(parts[hasType ? 5 : 4], 10) * 1024;
|
|
@@ -142,11 +207,16 @@ function fsSize(drive, callback) {
|
|
|
142
207
|
execSync('mount')
|
|
143
208
|
.toString()
|
|
144
209
|
.split('\n')
|
|
145
|
-
.filter((line) => {
|
|
146
|
-
return line.startsWith('/');
|
|
147
|
-
})
|
|
148
210
|
.forEach((line) => {
|
|
149
|
-
|
|
211
|
+
// mount output: "<fs> on <mountpoint> (<type>, <options>)"
|
|
212
|
+
const fs = line.split(' ')[0];
|
|
213
|
+
const type = line.match(/\(([^),]+)[^)]*\)$/);
|
|
214
|
+
if (fs && type) {
|
|
215
|
+
macOsFsTypes.set(fs, type[1].trim().toLowerCase());
|
|
216
|
+
}
|
|
217
|
+
if (line.startsWith('/')) {
|
|
218
|
+
osMounts[fs] = line.toLowerCase().indexOf('read-only') === -1;
|
|
219
|
+
}
|
|
150
220
|
});
|
|
151
221
|
} catch {
|
|
152
222
|
util.noop();
|
|
@@ -195,19 +265,23 @@ function fsSize(drive, callback) {
|
|
|
195
265
|
});
|
|
196
266
|
}
|
|
197
267
|
if ((!error || data.length) && stdout.toString().trim() !== '') {
|
|
198
|
-
|
|
199
|
-
callback
|
|
200
|
-
|
|
201
|
-
|
|
268
|
+
applyZfsUsage(data, (data) => {
|
|
269
|
+
if (callback) {
|
|
270
|
+
callback(data);
|
|
271
|
+
}
|
|
272
|
+
resolve(data);
|
|
273
|
+
});
|
|
202
274
|
} else {
|
|
203
275
|
exec('df -kPT 2>/dev/null', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
|
|
204
276
|
// fixed issue alpine fallback
|
|
205
277
|
const lines = filterLines(stdout);
|
|
206
278
|
data = parseDf(lines);
|
|
207
|
-
|
|
208
|
-
callback
|
|
209
|
-
|
|
210
|
-
|
|
279
|
+
applyZfsUsage(data, (data) => {
|
|
280
|
+
if (callback) {
|
|
281
|
+
callback(data);
|
|
282
|
+
}
|
|
283
|
+
resolve(data);
|
|
284
|
+
});
|
|
211
285
|
});
|
|
212
286
|
}
|
|
213
287
|
});
|
|
@@ -1359,7 +1433,7 @@ function diskLayout(callback) {
|
|
|
1359
1433
|
}
|
|
1360
1434
|
if (_darwin) {
|
|
1361
1435
|
let cmdFullSmart = '';
|
|
1362
|
-
exec(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType`, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
|
|
1436
|
+
exec(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPUSBHostDataType SPStorageDataType`, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
|
|
1363
1437
|
if (!error) {
|
|
1364
1438
|
// split by type:
|
|
1365
1439
|
const lines = stdout.toString().split('\n');
|
|
@@ -1498,7 +1572,7 @@ function diskLayout(callback) {
|
|
|
1498
1572
|
} catch {
|
|
1499
1573
|
util.noop();
|
|
1500
1574
|
}
|
|
1501
|
-
// USB Drives (
|
|
1575
|
+
// USB Drives (SPUSBDataType up to macOS 26, SPUSBHostDataType from macOS 27 on)
|
|
1502
1576
|
try {
|
|
1503
1577
|
const devices = linesUSB.join('\n').replace(/Media:\n /g, 'Model:').split('\n\n Product ID:');
|
|
1504
1578
|
devices.shift();
|
package/lib/network.js
CHANGED
package/lib/osinfo.js
CHANGED
|
@@ -1164,16 +1164,30 @@ function shell(callback) {
|
|
|
1164
1164
|
|
|
1165
1165
|
exports.shell = shell;
|
|
1166
1166
|
|
|
1167
|
+
// macOS 26+ and some hardened linux kernels mask MACs in getifaddrs()
|
|
1168
|
+
const MASKED_MACS = ['00:00:00:00:00:00', '02:00:00:00:00:00'];
|
|
1169
|
+
|
|
1167
1170
|
function getUniqueMacAdresses() {
|
|
1168
1171
|
let macs = [];
|
|
1169
1172
|
try {
|
|
1170
1173
|
const ifaces = os.networkInterfaces();
|
|
1174
|
+
let fallbackMacs = null;
|
|
1171
1175
|
for (let dev in ifaces) {
|
|
1172
1176
|
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
|
1173
1177
|
ifaces[dev].forEach((details) => {
|
|
1174
|
-
if (details && details.mac
|
|
1175
|
-
|
|
1176
|
-
if (
|
|
1178
|
+
if (details && details.mac) {
|
|
1179
|
+
let mac = details.mac.toLowerCase();
|
|
1180
|
+
if (MASKED_MACS.indexOf(mac) >= 0) {
|
|
1181
|
+
if (fallbackMacs === null) {
|
|
1182
|
+
try {
|
|
1183
|
+
fallbackMacs = require('./network').getMacAddresses();
|
|
1184
|
+
} catch {
|
|
1185
|
+
fallbackMacs = {};
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
mac = (fallbackMacs[dev] || '').toLowerCase();
|
|
1189
|
+
}
|
|
1190
|
+
if (mac && MASKED_MACS.indexOf(mac) === -1 && macs.indexOf(mac) === -1) {
|
|
1177
1191
|
macs.push(mac);
|
|
1178
1192
|
}
|
|
1179
1193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.33.
|
|
3
|
+
"version": "5.33.11",
|
|
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)",
|