diskLayout() fixed linux

This commit is contained in:
Sebastian Hildebrandt 2020-03-08 17:07:24 +01:00
parent 204fc3498a
commit 34da27443e
4 changed files with 18 additions and 12 deletions

View File

@ -30,7 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.22.6 | 2020-03-08 | `network()` fixed DHCP linux, `diskLayout()` fixed linux | | 4.22.7 | 2020-03-08 | `diskLayout()` fixed linux |
| 4.22.6 | 2020-03-08 | `network()` fixed DHCP linux|
| 4.22.5 | 2020-03-04 | `graphics()` fixed vram macOS | | 4.22.5 | 2020-03-04 | `graphics()` fixed vram macOS |
| 4.22.4 | 2020-03-01 | `versions()` added dotnet, typings fix | | 4.22.4 | 2020-03-01 | `versions()` added dotnet, typings fix |
| 4.22.3 | 2020-02-20 | `memLayout()` code cleanup | | 4.22.3 | 2020-02-20 | `memLayout()` code cleanup |

View File

@ -83,6 +83,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.22.7</th>
<td>2020-03-08</td>
<td><span class="code">diskLayout()</span> fixed detection (linux)</td>
</tr>
<tr> <tr>
<th scope="row">4.22.6</th> <th scope="row">4.22.6</th>
<td>2020-03-08</td> <td>2020-03-08</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png"> <img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div> <div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div> <div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.22.6</span></div> <div class="version">Current Version: <span id="version">4.22.7</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button> <button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div> </div>
<div class="down"> <div class="down">

20
lib/filesystem.js Normal file → Executable file
View File

@ -722,11 +722,13 @@ function diskLayout(callback) {
]; ];
let result = ''; let result = '';
model = model.toUpperCase(); if (model) {
diskManufacturers.forEach((manufacturer) => { model = model.toUpperCase();
const re = RegExp(manufacturer.pattern); diskManufacturers.forEach((manufacturer) => {
if (re.test(model)) { result = manufacturer.manufacturer; } const re = RegExp(manufacturer.pattern);
}); if (re.test(model)) { result = manufacturer.manufacturer; }
});
}
return result; return result;
} }
@ -745,21 +747,21 @@ function diskLayout(callback) {
try { try {
const outJSON = JSON.parse(out); const outJSON = JSON.parse(out);
if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) { if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) {
devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null)); }); devices = outJSON.blockdevices.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null)); });
} }
} catch (e) { } catch (e) {
// fallback to older version of lsblk // fallback to older version of lsblk
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString(); const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString();
let lines = blkStdoutToObject(out2).split('\n'); let lines = blkStdoutToObject(out2).split('\n');
const data = parseBlk(lines); const data = parseBlk(lines);
devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fstype === '')); }); devices = data.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fstype === '')); });
} }
devices.forEach((device) => { devices.forEach((device) => {
let mediumType = ''; let mediumType = '';
const BSDName = '/dev/' + device.name; const BSDName = '/dev/' + device.name;
const logical = device.name; const logical = device.name;
try { try {
mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0]; mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational 2>/dev/null').toString().split('\n')[0];
} catch (e) { } catch (e) {
util.noop(); util.noop();
} }
@ -793,8 +795,6 @@ function diskLayout(callback) {
util.noop(); util.noop();
} }
} }
// lshw sometimes returns empty results, try lsblk
// check S.M.A.R.T. status // check S.M.A.R.T. status
if (cmd) { if (cmd) {
cmd = cmd + 'printf "\n"'; cmd = cmd + 'printf "\n"';