mirror of
https://github.com/unraid/webgui.git
synced 2026-04-22 10:08:25 -05:00
Fix parity history code to work with new dual parity vars
This commit is contained in:
@@ -326,20 +326,13 @@ case 'parity':
|
||||
$data[] = $var['sbSyncErrs'];
|
||||
echo implode(';',$data);
|
||||
} else {
|
||||
if ($var['sbSynced']==0) break;
|
||||
if ($var['sbSynced']==0 || $var['sbSynced2']==0) break;
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$var['sbSynced']));
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$var['sbSynced2']));
|
||||
if (in_parity_log($log,$timestamp)) break;
|
||||
exec("grep -Po '^$timestamp .*(sync done. \Ktime=\d+|sync completion \Kstatus: -?\d+)' /var/log/syslog", $rows);
|
||||
$duration = 0; $speed = 0; $status = 0;
|
||||
foreach ($rows as $row) {
|
||||
if (strpos($row,'time=')!==false) {
|
||||
$duration = substr($row,5);
|
||||
} elseif (strpos($row,'status:')!==false) {
|
||||
$status = substr($row,8);
|
||||
}
|
||||
}
|
||||
if ($duration>0) $speed = isset($disks['parity']['sizeSb']) ? my_scale($disks['parity']['sizeSb']*1024/$duration,$unit,1)." $unit/s" : "Unknown";
|
||||
$duration = $var['sbSynced2'] - $var['sbSynced'];
|
||||
$status = $var['sbSyncExit'];
|
||||
$speed = ($status==0) ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : "Unavailable";
|
||||
file_put_contents($log,"$timestamp|$duration|$speed|$status\n",FILE_APPEND);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -69,8 +69,7 @@ function my_check($time,$speed) {
|
||||
$secs = $hmss%60;
|
||||
return plus($days,'day',($hour|$mins|$secs)==0).plus($hour,'hour',($mins|$secs)==0).plus($mins,'minute',$secs==0).plus($secs,'second',true).". Average speed: $speed";
|
||||
}
|
||||
function read_write_parity_log($epoch) {
|
||||
global $disks;
|
||||
function read_write_parity_log($epoch,$duration,$speed,$status) {
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$epoch));
|
||||
if (file_exists($log)) {
|
||||
@@ -81,16 +80,6 @@ function read_write_parity_log($epoch) {
|
||||
fclose($handle);
|
||||
}
|
||||
if (empty($line)) {
|
||||
exec("grep -Po '^$timestamp .*(sync done. \Ktime=\d+|sync completion \Kstatus: -?\d+)' /var/log/syslog", $rows);
|
||||
$duration = 0; $speed = 0; $status = 0;
|
||||
foreach ($rows as $row) {
|
||||
if (strpos($row,'time=')!==false) {
|
||||
$duration = substr($row,5);
|
||||
} elseif (strpos($row,'status:')!==false) {
|
||||
$status = substr($row,8);
|
||||
}
|
||||
}
|
||||
if ($duration>0) $speed = isset($disks['parity']['sizeSb']) ? my_scale($disks['parity']['sizeSb']*1024/$duration,$unit,1)." $unit/s" : "Unknown";
|
||||
$line = "$timestamp|$duration|$speed|$status";
|
||||
file_put_contents($log,"$line\n",FILE_APPEND);
|
||||
}
|
||||
@@ -291,15 +280,26 @@ $name = 'parity';
|
||||
$last = isset($saved[$item][$name]) ? $saved[$item][$name] : '';
|
||||
if ($var['mdResync']>0) {
|
||||
if (!$last) {
|
||||
$last = $var['mdNumInvalid']==0 ? 'Parity check' : ($var['mdInvalidDisk']==0 ? 'Parity sync:' : 'Data rebuild:');
|
||||
$info = isset($disks['parity']['sizeSb']) ? "Parity size: ".my_scale($disks['parity']['sizeSb']*1024, $unit)." $unit" : "No parity disk present";
|
||||
if (strstr($var['mdResyncAction'],"recon")) {
|
||||
$last = 'Parity sync / Data rebuild';
|
||||
} elseif (strstr($var['mdResyncAction'],"clear")) {
|
||||
$last = 'Disk clear';
|
||||
} elseif ($var['mdResyncAction']=="check") {
|
||||
$last = 'Read check';
|
||||
} elseif (strstr($var['mdResyncAction'],"check")) {
|
||||
$last = 'Parity check';
|
||||
}
|
||||
$info = "Size: ".my_scale($var['mdResyncSize']*1024, $unit)." $unit";
|
||||
exec("$notify -e \"unRAID $last\" -s \"Notice [$server] - $last started\" -d \"$info\" -i \"warning\"");
|
||||
$saved[$item][$name] = $last;
|
||||
}
|
||||
} else {
|
||||
if ($last) {
|
||||
list($entry,$duration,$speed,$status) = explode('|', read_write_parity_log($var['sbSynced']));
|
||||
$info = $status==0 ? "Duration: ".my_check($duration, $speed) : "Error code: $status";
|
||||
$duration = $var['sbSynced2'] - $var['sbSynced'];
|
||||
$status = $var['sbSyncExit'];
|
||||
$speed = $status==0 ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : "Unavailable";
|
||||
list($entry,$duration,$speed,$status) = explode('|', read_write_parity_log($var['sbSynced2'],$duration,$speed,$status));
|
||||
$info = $status==0 ? "Duration: ".my_check($duration, $speed) : $status==-4 ? "Canceled" : "Error code: $status";
|
||||
$level = ($status==0 && $var['sbSyncErrs']==0) ? "normal" : "warning";
|
||||
exec("$notify -e \"unRAID $last\" -s \"Notice [$server] - $last finished ({$var['sbSyncErrs']} errors)\" -d \"$info\" -i \"$level\"");
|
||||
unset($saved[$item][$name]);
|
||||
|
||||
@@ -93,18 +93,6 @@ function my_clock($time) {
|
||||
$mins = $time%60;
|
||||
return plus($days,'day',($hour|$mins)==0).plus($hour,'hour',$mins==0).plus($mins,'minute',true);
|
||||
}
|
||||
function read_parity_log($epoch) {
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
if (file_exists($log)) {
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$epoch));
|
||||
$handle = fopen($log, 'r');
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if (strpos($line,$timestamp)!==false) break;
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
return $line ? $line : '0|0|0|0';
|
||||
}
|
||||
|
||||
// generate report of array devices
|
||||
foreach ($disks as $disk) {
|
||||
@@ -128,7 +116,7 @@ foreach ($disks as $disk) {
|
||||
if ($fail) $fail .= ')';
|
||||
$status = $fail ? ' [NOK]' : ' [OK]';
|
||||
$color = strtok($disk['color'],'-');
|
||||
if ($name=='parity') $parity = true;
|
||||
if ($disk['type']=='Parity') $parity = true;
|
||||
if ($name=='cache') $cache = true;
|
||||
if ($color=='red'||$color=='yellow') { $error3++; $status = ' ['.str_replace(array('NP_','_'),array('',' '),$disk['status']).']'; }
|
||||
$info = "{$disk['id']} ({$disk['device']})";
|
||||
@@ -144,7 +132,17 @@ if ($mdResync>0) {
|
||||
$mdResyncPos = $var['mdResyncPos'];
|
||||
$mdResyncDb = $var['mdResyncDb'];
|
||||
$mdResyncDt = $var['mdResyncDt'];
|
||||
$data[] = ($var['mdNumInvalid']==0 ? 'Parity check' : ($var['mdInvalidDisk']==0 ? 'Parity sync' : 'Data rebuild'))." in progress.";
|
||||
$mode = '';
|
||||
if (strstr($var['mdResyncAction'],"recon")) {
|
||||
$mode = 'Parity sync / Data rebuild';
|
||||
} elseif (strstr($var['mdResyncAction'],"clear")) {
|
||||
$mode = 'Disk clear';
|
||||
} elseif ($var['mdResyncAction']=="check") {
|
||||
$mode = 'Read check';
|
||||
} elseif (strstr($var['mdResyncAction'],"check")) {
|
||||
$mode = 'Parity check';
|
||||
}
|
||||
$data[] = $mode." in progress.";
|
||||
$data[] = "Total size: ".my_scale($mdResync*1024, $unit)." $unit";
|
||||
$data[] = "Elapsed time: ".my_clock(floor((time()-$var['sbUpdated'])/60));
|
||||
$data[] = "Current position: ".my_scale($mdResyncPos*1024, $unit)." $unit (".number_format(($mdResyncPos/($mdResync/100+1)),1,$unraid['display']['number'][0],'')." %)";
|
||||
@@ -153,19 +151,23 @@ if ($mdResync>0) {
|
||||
$data[] = "Sync errors ".($var['mdResyncCorr']==0 ? 'detected: ' : 'corrected: ').$var['sbSyncErrs'];
|
||||
} else {
|
||||
$sbSynced = $var['sbSynced'];
|
||||
if ($sbSynced==0) {
|
||||
$sbSynced2 = $var['sbSynced2'];
|
||||
$sbSyncErrs = $var['sbSyncErrs'];
|
||||
if ($var['sbSyncExit']!=0) {
|
||||
$data[] = "Last check incomplete on ".my_time($sbSynced2).", finding $sbSyncErrs error".($sbSyncErrs==1?'.':'s.');
|
||||
$data[] = "Error code: ".$var['sbSyncExit'];
|
||||
} else if ($sbSynced==0) {
|
||||
$data[] = "Parity has not been checked yet";
|
||||
} else {
|
||||
$data[] = $var['mdNumInvalid']==0 ? 'Parity is valid' : ($var['mdInvalidDisk']==0 ? 'Parity is invalid' : 'Data is invalid');
|
||||
$sbSyncErrs = $var['sbSyncErrs'];
|
||||
list($entry,$duration,$speed,$status) = explode('|', read_parity_log($sbSynced));
|
||||
if ($status==0) {
|
||||
$data[] = "Last checked on ".my_time($sbSynced).", finding $sbSyncErrs error".($sbSyncErrs==1?'.':'s.');
|
||||
$data[] = "Duration: ".my_check($duration,$speed);
|
||||
} else if ($sbSynced2>0) {
|
||||
if (strstr($var['mdResyncAction'],"recon")) {
|
||||
$data[] = 'Parity or Data is invalid';
|
||||
} else {
|
||||
$data[] = "Last check incomplete on ".my_time($sbSynced).", finding $sbSyncErrs error".($sbSyncErrs==1?'.':'s.');
|
||||
$data[] = "Error code: $status";
|
||||
$data[] = 'Parity is valid';
|
||||
}
|
||||
$duration = $sbSynced2 - $sbSynced;
|
||||
$speed = my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s";
|
||||
$data[] = "Last checked on ".my_time($sbSynced2).", finding $sbSyncErrs error".($sbSyncErrs==1?'.':'s.');
|
||||
$data[] = "Duration: ".my_check($duration,$speed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user