disklayout() added device (/dev/sda...) linux, mac

This commit is contained in:
Sebastian Hildebrandt 2019-03-01 15:30:22 +01:00
parent d79a97a027
commit c81292c760
6 changed files with 36 additions and 10 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.0.13 | 2019-03-01 | `diskLayout()` added device (/dev/sda...) linux, mac |
| 4.0.12 | 2019-03-01 | `diskLayout()` linux rewritten - better detection |
| 4.0.11 | 2019-02-23 | `users()` fix windows (time), added @ts-check |
| 4.0.10 | 2019-02-10 | `networkInterfaceDefault()` fix windows |

View File

@ -343,7 +343,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
| si.diskLayout(cb) | [{...}] | X | | X | X | | physical disk layout (array) |
| | [0].type | X | | X | X | | HD, SSD |
| | [0].type | X | | X | | | e.g. /dev/sda |
| | [0].type | X | | X | X | | HD, SSD, NVMe |
| | [0].name | X | | X | X | | disk name |
| | [0].vendor | X | | | X | | vendor/producer |
| | [0].size | X | | X | X | | size in bytes |
@ -356,7 +357,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].sectorsPerTrack | | | | X | | sectors per track |
| | [0].firmwareRevision | X | | X | X | | firmware revision |
| | [0].serialNum | X | | X | X | | serial number |
| | [0].interfaceType | X | | | X | | |
| | [0].interfaceType | X | | | X | | SATA, PCIe, ... |
| | [0].smartStatus | X | | X | X | | S.M.A.R.T Status (see Known Issues) |
| si.blockDevices(cb) | [{...}] | X | | X | X | | returns array of disks, partitions,<br>raids and roms |
| | [0].name | X | | X | X | | name |

View File

@ -75,6 +75,16 @@
<td></td>
<td>physical disk layout (array)</td>
</tr>
<tr>
<td></td>
<td>[0].device</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>e.g. /dev/sda</td>
</tr>
<tr>
<td></td>
<td>[0].type</td>
@ -83,7 +93,7 @@
<td>X</td>
<td>X</td>
<td></td>
<td>HD, SSD</td>
<td>HD, SSD, NVMe</td>
</tr>
<tr>
<td></td>
@ -213,7 +223,7 @@
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>SATA, PCIe, ...</td>
</tr>
<tr>
<td></td>

View File

@ -80,6 +80,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.0.13</th>
<td>2019-03-01</td>
<td><span class="code">diskLayout()</span> added device (/dev/sda...) linux, mac</td>
</tr>
<tr>
<th scope="row">4.0.12</th>
<td>2019-03-01</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.0.12</span></div>
<div class="version">Current Version: <span id="version">4.0.13</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>
</div>
<div class="down">
@ -193,7 +193,7 @@
</div>
<div class="row number-section">
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">8,158</div>
<div class="numbers">8,167</div>
<div class="title">Lines of code</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">

View File

@ -666,8 +666,14 @@ function diskLayout(callback) {
} catch (e) {
util.noop();
}
let interfaceType = device.tran ? device.tran.toUpperCase().trim() : '';
if (interfaceType === 'NVME') {
mediumType = '2';
interfaceType = 'PCIe'
}
result.push({
type: (mediumType === '0' ? 'SSD' : (mediumType === '1' ? 'HD' : (device.model && device.model.indexOf('SSD') > -1 ? 'SSD' : 'HD'))),
device: BSDName,
type: (mediumType === '0' ? 'SSD' : (mediumType === '1' ? 'HD' : (mediumType === '2' ? 'NVMe' : (device.model && device.model.indexOf('SSD') > -1 ? 'SSD' : (device.model && device.model.indexOf('NVM') > -1 ? 'NVMe' : 'HD'))))),
name: device.model || '',
vendor: getVendorFromModel(device.model) || (device.vendor ? device.vendor.trim() : ''),
size: device.size || 0,
@ -680,7 +686,7 @@ function diskLayout(callback) {
sectorsPerTrack: -1,
firmwareRevision: device.rev ? device.rev.trim() : '',
serialNum: device.serial ? device.serial.trim() : '',
interfaceType: device.tran ? device.tran.trim() : '',
interfaceType: interfaceType,
smartStatus: 'unknown',
BSDName: BSDName
});
@ -768,9 +774,10 @@ function diskLayout(callback) {
}
if (sizeValue) {
result.push({
device: BSDName,
type: mediumType.startsWith('Solid') ? 'SSD' : 'HD',
name: util.getValue(lines, 'Model', ':', true).trim(),
vendor: '',
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
size: sizeValue,
bytesPerSector: -1,
totalCylinders: -1,
@ -808,9 +815,10 @@ function diskLayout(callback) {
}
if (sizeValue) {
result.push({
device: BSDName,
type: 'NVMe',
name: util.getValue(lines, 'Model', ':', true).trim(),
vendor: '',
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
size: sizeValue,
bytesPerSector: -1,
totalCylinders: -1,
@ -884,6 +892,7 @@ function diskLayout(callback) {
const status = util.getValue(lines, 'Status', '=').trim().toLowerCase();
if (size) {
result.push({
device: '',
type: device.indexOf('SSD') > -1 ? 'SSD' : 'HD', // just a starting point ... better: MSFT_PhysicalDisk - Media Type ... see below
name: util.getValue(lines, 'Caption', '='),
vendor: util.getValue(lines, 'Manufacturer', '='),