mirror of
https://github.com/unraid/webgui.git
synced 2026-01-25 02:58:58 -06:00
Merge pull request #1155 from SimonFair/SAS-Selftest-Fix
Fix SAS Selftest
This commit is contained in:
@@ -172,7 +172,8 @@ case "capabilities":
|
||||
case "identify":
|
||||
$passed = ['PASSED','OK'];
|
||||
$failed = ['FAILED','NOK'];
|
||||
exec("smartctl -i $type ".escapeshellarg("/dev/$port")."|awk 'NR>4'",$output);
|
||||
if ($disk["transport"] == "scsi") $standby = " -n standby " ; else $standby = "" ;
|
||||
exec("smartctl -i $type $standby ".escapeshellarg("/dev/$port")."|awk 'NR>4'",$output);
|
||||
exec("smartctl -n standby -H $type ".escapeshellarg("/dev/$port")."|grep -Pom1 '^SMART.*: [A-Z]+'|sed 's:self-assessment test result::'",$output);
|
||||
$empty = true;
|
||||
foreach ($output as $line) {
|
||||
@@ -185,7 +186,8 @@ case "identify":
|
||||
$empty = false;
|
||||
}
|
||||
if ($empty) {
|
||||
echo "<tr><td colspan='2' style='text-align:center;padding-top:12px'>"._('Can not read identification')."</td></tr>";
|
||||
$spundown = $disk['spundown'] ? "(device spundown, spinup to get information)" : "" ;
|
||||
echo "<tr><td colspan='2' style='text-align:center;padding-top:12px'>"._('Can not read identification'.$spundown)."</td></tr>";
|
||||
} else {
|
||||
$file = '/boot/config/disk.log';
|
||||
$extra = file_exists($file) ? parse_ini_file($file,true) : [];
|
||||
@@ -217,17 +219,31 @@ case "stop":
|
||||
exec("smartctl -X $type ".escapeshellarg("/dev/$port"));
|
||||
break;
|
||||
case "update":
|
||||
$progress = exec("smartctl -n standby -c $type ".escapeshellarg("/dev/$port")."|grep -Pom1 '\d+%'");
|
||||
if ($progress) {
|
||||
echo "<span class='big'><i class='fa fa-spinner fa-pulse'></i> "._('self-test in progress').", ".(100-substr($progress,0,-1))."% "._('complete')."</span>";
|
||||
break;
|
||||
if ($disk["transport"] == "scsi") {
|
||||
$progress = exec("smartctl -n standby -l selftest $type ".escapeshellarg("/dev/$port")."|grep -Pom1 '\d+%'");
|
||||
if ($progress) {
|
||||
echo "<span class='big'><i class='fa fa-spinner fa-pulse'></i> "._('self-test in progress').", ".(100-substr($progress,0,-1))."% "._('complete')."</span>";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$progress = exec("smartctl -n standby -c $type ".escapeshellarg("/dev/$port")."|grep -Pom1 '\d+%'");
|
||||
if ($progress) {
|
||||
echo "<span class='big'><i class='fa fa-spinner fa-pulse'></i> "._('self-test in progress').", ".(100-substr($progress,0,-1))."% "._('complete')."</span>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result = trim(exec("smartctl -n standby -l selftest $type ".escapeshellarg("/dev/$port")."|grep -m1 '^# 1'|cut -c26-55"));
|
||||
if ($disk["transport"] == "scsi") $result = trim(exec("smartctl -n standby -l selftest $type ".escapeshellarg("/dev/$port")."|grep -m1 '^# 1'|cut -c24-50"));
|
||||
else $result = trim(exec("smartctl -n standby -l selftest $type ".escapeshellarg("/dev/$port")."|grep -m1 '^# 1'|cut -c26-55"));
|
||||
if (!$result) {
|
||||
echo "<span class='big'>"._('No self-tests logged on this disk')."</span>";
|
||||
$spundown = $disk['spundown'] ? "Device spundown, spinup to get information" : "No self-tests logged on this disk" ;
|
||||
echo "<span class='big'>"._($spundown)."</span>";
|
||||
break;
|
||||
}
|
||||
if (strpos($result, "Completed without error")!==false) {
|
||||
if (strpos($result, "Completed, segment failed")!==false) {
|
||||
echo "<span class='big red-text'>"._($result)."</span>";
|
||||
break;
|
||||
}
|
||||
if (strpos($result, "Completed without error")!==false || strpos($result, "Completed")!==false ) {
|
||||
echo "<span class='big green-text'>"._($result)."</span>";
|
||||
break;
|
||||
}
|
||||
@@ -235,6 +251,10 @@ case "update":
|
||||
echo "<span class='big orange-text'>"._($result)."</span>";
|
||||
break;
|
||||
}
|
||||
if (strpos($result, "Failed")!==false) {
|
||||
echo "<span class='big red-text'>"._($result)."</span>";
|
||||
break;
|
||||
}
|
||||
echo "<span class='big red-text'>"._('Errors occurred - Check SMART report')."</span>";
|
||||
break;
|
||||
case "selftest":
|
||||
|
||||
Reference in New Issue
Block a user