Merge pull request #1144 from SimonFair/Add-NVME-capabilities

Add nvme capabilities
This commit is contained in:
tom mortensen
2022-07-31 10:06:00 -07:00
committed by GitHub
2 changed files with 59 additions and 7 deletions
+4 -5
View File
@@ -18,14 +18,13 @@ Cond="strpos($disks[$name]['status'],'_NP')===false"
<script>
$(function() {
$.post("/webGui/include/SmartInfo.php",{cmd:'capabilities',port:'<?=addslashes(htmlspecialchars($dev))?>',name:'<?=addslashes(htmlspecialchars($name))?>'}, function(data) {
$('#disk_capabilities').html(data);
$('#disk_capabilities_div').html(data);
});
});
</script>
<table class='share_status small'>
<thead><td style="width:33%">_(Feature)_</td><td>_(Value)_</td><td>_(Information)_</td></thead>
<tbody id="disk_capabilities"><tr><td colspan='3'><div class="spinner"></div></td></tr></tbody>
</table>
<div id="disk_capabilities_div" class='share_status small'>
</div>
<input type="button" value="_(Done)_" onclick="done()">
:smart_capabilities_help:
+55 -2
View File
@@ -98,23 +98,76 @@ case "attributes":
if ($empty) echo "<tr><td colspan='10' style='text-align:center;padding-top:12px'>"._('Can not read attributes')."</td></tr>";
break;
case "capabilities":
echo '<table id="disk_capabilities_table" class="share_status small"><thead><td style="width:33%">'._('Feature').'</td><td>'._('Value').'</td><td>'._('Information').'</td></thead><tbody>' ;
exec("smartctl -n standby -c $type ".escapeshellarg("/dev/$port")."|awk 'NR>5'",$output);
$row = ['','',''];
$empty = true;
if (substr($port,0,4)=="nvme") $nvme=true ;
$nvme_section="info" ;
foreach ($output as $line) {
if (!$line) continue;
if (!$line) {echo "<tr></tr>" ;continue;}
$line = preg_replace('/^_/','__',preg_replace(['/__+/','/_ +_/'],'_',str_replace([chr(9),')','('],'_',$line)));
$info = array_map('trim', explode('_', preg_replace('/_( +)_ /','__',$line), 3));
if ($nvme && $info[0]=="Supported Power States" ) { $nvme_section="psheading" ;echo "</body></table><div id='title'><span>${line}</span></div>"; $row = ['','',''] ; continue ;}
if ($nvme && $info[0]=="Supported LBA Sizes" ) {
echo "</body></table><div id='title'>${info[0]} ${info[1]} ${info[2]}</span></div>";
$row = ['','',''];
$nvme_section="lbaheading" ;
continue ;
}
append($row[0],$info[0]);
append($row[1],$info[1]);
append($row[2],$info[2]);
if (substr($row[2],-1)=='.') {
if (substr($row[2],-1)=='.' || ($nvme && $nvme_section=="info")) {
echo "<tr><td>${row[0]}</td><td>${row[1]}</td><td>${row[2]}</td></tr>";
$row = ['','',''];
$empty = false;
}
if ($nvme && $nvme_section == "psheading") {
echo '<table id="disk_capabilities_table2" class="share_status small"><thead>' ;
$nvme_section = "psdetail";
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S+)\s+(?P<data3>\S+)\s+(?P<data4>\S+)\s+(?P<data5>\S+)\s+(?P<data6>\S+)\s+(?P<data7>\S+)\s+(?P<data8>\S+)\s+(?P<data9>\S+)\s+(?P<data10>\S+)\s+(?P<data11>\S+)$/',$line, $psheadings);
for ($i = 1; $i <= 11; $i++) {
echo "<td>".$psheadings['data'.$i]."</td>" ;
}
$row = ['','',''];
echo '</tr></thead><tbody>' ;
}
if ($nvme && $nvme_section == "psdetail") {
$nvme_section = "psdetail";
echo '<tr>' ;
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S\s+)\s+(?P<data3>\S+)\s+(?P<data4>\S\s+)\s+(?P<data5>\S+)\s+(?P<data6>\S+)\s+(?P<data7>\S+)\s+(?P<data8>\S+)\s+(?P<data9>\S+)\s+(?P<data10>\S+)\s+(?P<data11>\S+)$/',$line, $psdetails);
for ($i = 1; $i <= 11; $i++) {
echo "<td>".$psdetails['data'.$i]."</td>" ;
}
$row = ['','',''];
echo '</tr>' ;
}
if ($nvme && $nvme_section == "lbaheading") {
echo '<table id="disk_capabilities_table3" class="share_status small"><thead>' ;
$nvme_section = "lbadetail";
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S+)\s+(?P<data3>\S+)\s+(?P<data4>\S+)\s+(?P<data5>\S+)$/',$line, $lbaheadings);
for ($i = 1; $i <= 5; $i++) {
echo "<td>".$lbaheadings['data'.$i]."</td>" ;
}
$row = ['','',''];
echo '</thead><tbody>' ;
}
if ($nvme && $nvme_section == "lbadetail") {
$nvme_section = "lbadetail";
preg_match('/^(?P<data1>.\S+)\s+(?P<data2>\S\s+)\s+(?P<data3>\S+)\s+(?P<data4>\S\s+)\s+(?P<data5>\S+)$/',$line, $lbadetails);
echo '<tr>' ;
for ($i = 1; $i <= 5; $i++) {
echo "<td>".$lbadetails['data'.$i]."</td>" ;
}
$row = ['','',''];
echo '</tr>' ;
}
}
if ($empty) echo "<tr><td colspan='3' style='text-align:center;padding-top:12px'>"._('Can not read capabilities')."</td></tr>";
echo "</tbody></table>" ;
break;
case "identify":
$passed = ['PASSED','OK'];