diskLayout() added USB drives (mac OS)
This commit is contained in:
parent
b39f30489b
commit
b120ad2c45
@ -72,6 +72,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 5.2.3 | 2020-02-11 | `diskLayout()` added USB drives (mac OS) |
|
||||||
| 5.2.2 | 2020-02-11 | code cleanup, updated docs |
|
| 5.2.2 | 2020-02-11 | code cleanup, updated docs |
|
||||||
| 5.2.1 | 2020-02-10 | `system()` fixed issue virtual detect (linux) |
|
| 5.2.1 | 2020-02-10 | `system()` fixed issue virtual detect (linux) |
|
||||||
| 5.2.0 | 2020-02-10 | `wifiInterfces()` and `wifiConnections()` added |
|
| 5.2.0 | 2020-02-10 | `wifiInterfces()` and `wifiConnections()` added |
|
||||||
|
|||||||
@ -56,6 +56,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.2.3</th>
|
||||||
|
<td>2020-02-11</td>
|
||||||
|
<td><span class="code">diskLayout()</span> added USB drives (mac OS)</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.2.2</th>
|
<th scope="row">5.2.2</th>
|
||||||
<td>2020-02-11</td>
|
<td>2020-02-11</td>
|
||||||
|
|||||||
@ -170,7 +170,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">New Version: <span id="version">5.2.2</span></div>
|
<div class="version">New Version: <span id="version">5.2.3</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">
|
||||||
@ -201,7 +201,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row number-section">
|
<div class="row number-section">
|
||||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||||
<div class="numbers">13,682</div>
|
<div class="numbers">13,752</div>
|
||||||
<div class="title">Lines of code</div>
|
<div class="title">Lines of code</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||||
|
|||||||
@ -929,157 +929,178 @@ function diskLayout(callback) {
|
|||||||
else if (dataType === 'NVMe') { linesNVMe.push(line); }
|
else if (dataType === 'NVMe') { linesNVMe.push(line); }
|
||||||
else if (dataType === 'USB') { linesUSB.push(line); }
|
else if (dataType === 'USB') { linesUSB.push(line); }
|
||||||
});
|
});
|
||||||
// Serial ATA Drives
|
try {
|
||||||
let devices = linesSATA.join('\n').split(' Physical Interconnect: ');
|
// Serial ATA Drives
|
||||||
devices.shift();
|
let devices = linesSATA.join('\n').split(' Physical Interconnect: ');
|
||||||
devices.forEach(function (device) {
|
devices.shift();
|
||||||
device = 'InterfaceType: ' + device;
|
devices.forEach(function (device) {
|
||||||
let lines = device.split('\n');
|
device = 'InterfaceType: ' + device;
|
||||||
const mediumType = util.getValue(lines, 'Medium Type', ':', true).trim();
|
let lines = device.split('\n');
|
||||||
const sizeStr = util.getValue(lines, 'capacity', ':', true).trim();
|
const mediumType = util.getValue(lines, 'Medium Type', ':', true).trim();
|
||||||
const BSDName = util.getValue(lines, 'BSD Name', ':', true).trim();
|
const sizeStr = util.getValue(lines, 'capacity', ':', true).trim();
|
||||||
if (sizeStr) {
|
const BSDName = util.getValue(lines, 'BSD Name', ':', true).trim();
|
||||||
let sizeValue = 0;
|
if (sizeStr) {
|
||||||
if (sizeStr.indexOf('(') >= 0) {
|
let sizeValue = 0;
|
||||||
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
if (sizeStr.indexOf('(') >= 0) {
|
||||||
|
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
||||||
|
}
|
||||||
|
if (!sizeValue) {
|
||||||
|
sizeValue = parseInt(sizeStr);
|
||||||
|
}
|
||||||
|
if (sizeValue) {
|
||||||
|
const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
|
||||||
|
result.push({
|
||||||
|
device: BSDName,
|
||||||
|
type: mediumType.startsWith('Solid') ? 'SSD' : 'HD',
|
||||||
|
name: util.getValue(lines, 'Model', ':', true).trim(),
|
||||||
|
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()) || util.getValue(lines, 'Manufacturer', ':', true),
|
||||||
|
size: sizeValue,
|
||||||
|
bytesPerSector: null,
|
||||||
|
totalCylinders: null,
|
||||||
|
totalHeads: null,
|
||||||
|
totalSectors: null,
|
||||||
|
totalTracks: null,
|
||||||
|
tracksPerCylinder: null,
|
||||||
|
sectorsPerTrack: null,
|
||||||
|
firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
|
||||||
|
serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
|
||||||
|
interfaceType: util.getValue(lines, 'InterfaceType', ':', true).trim(),
|
||||||
|
smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
|
||||||
|
temperature: null,
|
||||||
|
BSDName: BSDName
|
||||||
|
});
|
||||||
|
cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!sizeValue) {
|
});
|
||||||
sizeValue = parseInt(sizeStr);
|
} catch (e) {
|
||||||
}
|
util.noop();
|
||||||
if (sizeValue) {
|
}
|
||||||
const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
|
|
||||||
result.push({
|
|
||||||
device: BSDName,
|
|
||||||
type: mediumType.startsWith('Solid') ? 'SSD' : 'HD',
|
|
||||||
name: util.getValue(lines, 'Model', ':', true).trim(),
|
|
||||||
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()) || util.getValue(lines, 'Manufacturer', ':', true),
|
|
||||||
size: sizeValue,
|
|
||||||
bytesPerSector: null,
|
|
||||||
totalCylinders: null,
|
|
||||||
totalHeads: null,
|
|
||||||
totalSectors: null,
|
|
||||||
totalTracks: null,
|
|
||||||
tracksPerCylinder: null,
|
|
||||||
sectorsPerTrack: null,
|
|
||||||
firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
|
|
||||||
serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
|
|
||||||
interfaceType: util.getValue(lines, 'InterfaceType', ':', true).trim(),
|
|
||||||
smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
|
|
||||||
temperature: null,
|
|
||||||
BSDName: BSDName
|
|
||||||
});
|
|
||||||
cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// NVME Drives
|
// NVME Drives
|
||||||
devices = linesNVMe.join('\n').split('\n\n Capacity:');
|
try {
|
||||||
devices.shift();
|
let devices = linesNVMe.join('\n').split('\n\n Capacity:');
|
||||||
devices.forEach(function (device) {
|
devices.shift();
|
||||||
device = '!Capacity: ' + device;
|
devices.forEach(function (device) {
|
||||||
let lines = device.split('\n');
|
device = '!Capacity: ' + device;
|
||||||
const linkWidth = util.getValue(lines, 'link width', ':', true).trim();
|
let lines = device.split('\n');
|
||||||
const sizeStr = util.getValue(lines, '!capacity', ':', true).trim();
|
const linkWidth = util.getValue(lines, 'link width', ':', true).trim();
|
||||||
const BSDName = util.getValue(lines, 'BSD Name', ':', true).trim();
|
const sizeStr = util.getValue(lines, '!capacity', ':', true).trim();
|
||||||
if (sizeStr) {
|
const BSDName = util.getValue(lines, 'BSD Name', ':', true).trim();
|
||||||
let sizeValue = 0;
|
if (sizeStr) {
|
||||||
if (sizeStr.indexOf('(') >= 0) {
|
let sizeValue = 0;
|
||||||
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
if (sizeStr.indexOf('(') >= 0) {
|
||||||
|
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
||||||
|
}
|
||||||
|
if (!sizeValue) {
|
||||||
|
sizeValue = parseInt(sizeStr);
|
||||||
|
}
|
||||||
|
if (sizeValue) {
|
||||||
|
const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
|
||||||
|
result.push({
|
||||||
|
device: BSDName,
|
||||||
|
type: 'NVMe',
|
||||||
|
name: util.getValue(lines, 'Model', ':', true).trim(),
|
||||||
|
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
|
||||||
|
size: sizeValue,
|
||||||
|
bytesPerSector: null,
|
||||||
|
totalCylinders: null,
|
||||||
|
totalHeads: null,
|
||||||
|
totalSectors: null,
|
||||||
|
totalTracks: null,
|
||||||
|
tracksPerCylinder: null,
|
||||||
|
sectorsPerTrack: null,
|
||||||
|
firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
|
||||||
|
serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
|
||||||
|
interfaceType: ('PCIe ' + linkWidth).trim(),
|
||||||
|
smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
|
||||||
|
temperature: null,
|
||||||
|
BSDName: BSDName
|
||||||
|
});
|
||||||
|
cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!sizeValue) {
|
});
|
||||||
sizeValue = parseInt(sizeStr);
|
} catch (e) {
|
||||||
}
|
util.noop();
|
||||||
if (sizeValue) {
|
}
|
||||||
const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
|
|
||||||
result.push({
|
|
||||||
device: BSDName,
|
|
||||||
type: 'NVMe',
|
|
||||||
name: util.getValue(lines, 'Model', ':', true).trim(),
|
|
||||||
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
|
|
||||||
size: sizeValue,
|
|
||||||
bytesPerSector: null,
|
|
||||||
totalCylinders: null,
|
|
||||||
totalHeads: null,
|
|
||||||
totalSectors: null,
|
|
||||||
totalTracks: null,
|
|
||||||
tracksPerCylinder: null,
|
|
||||||
sectorsPerTrack: null,
|
|
||||||
firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
|
|
||||||
serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
|
|
||||||
interfaceType: ('PCIe ' + linkWidth).trim(),
|
|
||||||
smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
|
|
||||||
temperature: null,
|
|
||||||
BSDName: BSDName
|
|
||||||
});
|
|
||||||
cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// USB Drives
|
// USB Drives
|
||||||
devices = linesUSB.join('\n').replaceAll('Media:\n ', 'Model:').split('\n\n Product ID:');
|
try {
|
||||||
devices.shift();
|
let devices = linesUSB.join('\n').replaceAll('Media:\n ', 'Model:').split('\n\n Product ID:');
|
||||||
devices.forEach(function (device) {
|
devices.shift();
|
||||||
let lines = device.split('\n');
|
devices.forEach(function (device) {
|
||||||
const sizeStr = util.getValue(lines, 'Capacity', ':', true).trim();
|
let lines = device.split('\n');
|
||||||
const BSDName = util.getValue(lines, 'BSD Name', ':', true).trim();
|
const sizeStr = util.getValue(lines, 'Capacity', ':', true).trim();
|
||||||
if (sizeStr) {
|
const BSDName = util.getValue(lines, 'BSD Name', ':', true).trim();
|
||||||
let sizeValue = 0;
|
if (sizeStr) {
|
||||||
if (sizeStr.indexOf('(') >= 0) {
|
let sizeValue = 0;
|
||||||
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
if (sizeStr.indexOf('(') >= 0) {
|
||||||
|
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
||||||
|
}
|
||||||
|
if (!sizeValue) {
|
||||||
|
sizeValue = parseInt(sizeStr);
|
||||||
|
}
|
||||||
|
if (sizeValue) {
|
||||||
|
const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
|
||||||
|
result.push({
|
||||||
|
device: BSDName,
|
||||||
|
type: 'USB',
|
||||||
|
name: util.getValue(lines, 'Model', ':', true).trim().replaceAll(':', ''),
|
||||||
|
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
|
||||||
|
size: sizeValue,
|
||||||
|
bytesPerSector: null,
|
||||||
|
totalCylinders: null,
|
||||||
|
totalHeads: null,
|
||||||
|
totalSectors: null,
|
||||||
|
totalTracks: null,
|
||||||
|
tracksPerCylinder: null,
|
||||||
|
sectorsPerTrack: null,
|
||||||
|
firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
|
||||||
|
serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
|
||||||
|
interfaceType: 'USB',
|
||||||
|
smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
|
||||||
|
temperature: null,
|
||||||
|
BSDName: BSDName
|
||||||
|
});
|
||||||
|
cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!sizeValue) {
|
});
|
||||||
sizeValue = parseInt(sizeStr);
|
} catch (e) {
|
||||||
}
|
util.noop();
|
||||||
if (sizeValue) {
|
}
|
||||||
const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
|
if (cmd) {
|
||||||
result.push({
|
cmd = cmd + 'printf "\n"';
|
||||||
device: BSDName,
|
exec(cmd, function (error, stdout) {
|
||||||
type: 'USB',
|
let lines = stdout.toString().split('\n');
|
||||||
name: util.getValue(lines, 'Model', ':', true).trim().replaceAll(':', ''),
|
lines.forEach(line => {
|
||||||
vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
|
if (line) {
|
||||||
size: sizeValue,
|
let parts = line.split('|');
|
||||||
bytesPerSector: null,
|
if (parts.length === 2) {
|
||||||
totalCylinders: null,
|
let BSDName = parts[0];
|
||||||
totalHeads: null,
|
parts[1] = parts[1].trim();
|
||||||
totalSectors: null,
|
let parts2 = parts[1].split(':');
|
||||||
totalTracks: null,
|
if (parts2.length === 2) {
|
||||||
tracksPerCylinder: null,
|
parts2[1] = parts2[1].trim();
|
||||||
sectorsPerTrack: null,
|
let status = parts2[1].toLowerCase();
|
||||||
firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
|
for (let i = 0; i < result.length; i++) {
|
||||||
serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
|
if (result[i].BSDName === BSDName) {
|
||||||
interfaceType: 'USB',
|
result[i].smartStatus = (status === 'not supported' ? 'not supported' : (status === 'verified' ? 'Ok' : (status === 'failing' ? 'Predicted Failure' : 'unknown')));
|
||||||
smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
|
}
|
||||||
temperature: null,
|
|
||||||
BSDName: BSDName
|
|
||||||
});
|
|
||||||
cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (cmd) {
|
|
||||||
cmd = cmd + 'printf "\n"';
|
|
||||||
exec(cmd, function (error, stdout) {
|
|
||||||
let lines = stdout.toString().split('\n');
|
|
||||||
lines.forEach(line => {
|
|
||||||
if (line) {
|
|
||||||
let parts = line.split('|');
|
|
||||||
if (parts.length === 2) {
|
|
||||||
let BSDName = parts[0];
|
|
||||||
parts[1] = parts[1].trim();
|
|
||||||
let parts2 = parts[1].split(':');
|
|
||||||
if (parts2.length === 2) {
|
|
||||||
parts2[1] = parts2[1].trim();
|
|
||||||
let status = parts2[1].toLowerCase();
|
|
||||||
for (let i = 0; i < result.length; i++) {
|
|
||||||
if (result[i].BSDName === BSDName) {
|
|
||||||
result[i].smartStatus = (status === 'not supported' ? 'not supported' : (status === 'verified' ? 'Ok' : (status === 'failing' ? 'Predicted Failure' : 'unknown')));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
for (let i = 0; i < result.length; i++) {
|
||||||
|
delete result[i].BSDName;
|
||||||
}
|
}
|
||||||
|
if (callback) {
|
||||||
|
callback(result);
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
for (let i = 0; i < result.length; i++) {
|
for (let i = 0; i < result.length; i++) {
|
||||||
delete result[i].BSDName;
|
delete result[i].BSDName;
|
||||||
}
|
}
|
||||||
@ -1087,15 +1108,7 @@ function diskLayout(callback) {
|
|||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < result.length; i++) {
|
|
||||||
delete result[i].BSDName;
|
|
||||||
}
|
}
|
||||||
if (callback) {
|
|
||||||
callback(result);
|
|
||||||
}
|
|
||||||
resolve(result);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user