mirror of
https://github.com/unraid/webgui.git
synced 2026-05-05 11:50:41 -05:00
Added Sync Errors to parity history
This commit is contained in:
@@ -194,27 +194,27 @@ toggle_diskio(true);
|
||||
if ($var['sbSyncExit']!=0):?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',490,430,false)"></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
|
||||
<td>Last check incomplete on <strong><?=my_time($var['sbSynced2']).day_count($var['sbSynced2'])?></strong><?if ($var['sbSynced2']):?>, finding <strong><?=$var['sbSyncErrs']?></strong> error<?=$var['sbSyncErrs']==1?'':'s'?>.<?endif;?>
|
||||
<br><i class="fa fa-dot-circle-o icon"></i><small>Error code: <?=my_error($var['sbSyncExit'])?></small></td>
|
||||
</tr>
|
||||
<? elseif ($var['sbSynced']==0):?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',490,430,false)"></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
|
||||
<td>Last checked on <strong><?=my_time(0).day_count(0)?></strong>
|
||||
<br><i class="fa fa-clock-o icon"></i><small>Duration: <?=my_check(0,0)?></small></td>
|
||||
</tr>
|
||||
<? elseif ($var['sbSynced2']==0):?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',490,430,false)"></td>
|
||||
<? list($entry,$duration,$speed,$status) = explode('|', read_parity_log($var['sbSynced']));
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
|
||||
<? list($entry,$duration,$speed,$status,$error) = explode('|', read_parity_log($var['sbSynced']));
|
||||
if ($status==0):?>
|
||||
<td>Last checked on <strong><?=my_time($var['sbSynced']).day_count($var['sbSynced'])?></strong>, finding <strong><?=$var['sbSyncErrs']?></strong> error<?=$var['sbSyncErrs']==1?'':'s'?>.
|
||||
<td>Last checked on <strong><?=my_time($var['sbSynced']).day_count($var['sbSynced'])?></strong>, finding <strong><?=$error?></strong> error<?=$error==1?'':'s'?>.
|
||||
<br><i class="fa fa-clock-o icon"></i><small>Duration: <?=my_check($duration,$speed)?></small>
|
||||
<? else:?>
|
||||
<td>Last check incomplete on <strong><?=my_time($var['sbSynced']).day_count($var['sbSynced'])?></strong>, finding <strong><?=$var['sbSyncErrs']?></strong> error<?=$var['sbSyncErrs']==1?'':'s'?>.
|
||||
<td>Last check incomplete on <strong><?=my_time($var['sbSynced']).day_count($var['sbSynced'])?></strong>, finding <strong><?=$error?></strong> error<?=$error==1?'':'s'?>.
|
||||
<br><i class="fa fa-dot-circle-o icon"></i><small>Error code: <?=$status?></small>
|
||||
<? endif;?>
|
||||
</td></tr>
|
||||
@@ -223,7 +223,7 @@ toggle_diskio(true);
|
||||
$speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',490,430,false)"></td>
|
||||
<td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
|
||||
<td>Last check completed on <strong><?=my_time($var['sbSynced2']).day_count($var['sbSynced2'])?></strong>, finding <strong><?=$var['sbSyncErrs']?></strong> error<?=$var['sbSyncErrs']==1?'':'s'?>.
|
||||
<br><i class="fa fa-clock-o icon"></i><small>Duration: <?=my_check($duration,$speed)?></small></td>
|
||||
</tr>
|
||||
|
||||
@@ -75,12 +75,12 @@ function parity_status() {
|
||||
}
|
||||
if ($var['sbSynced2']==0) {
|
||||
$idle = $var['mdResync']==0;
|
||||
list($entry,$duration,$speed,$status) = explode('|', read_parity_log($var['sbSynced'],!$idle));
|
||||
list($entry,$duration,$speed,$status,$error) = explode('|', read_parity_log($var['sbSynced'],!$idle));
|
||||
if ($status==0) {
|
||||
echo "<tr><td>".($idle ? "Last checked on " : "Activity started on ")."<strong>".my_time($var['sbSynced']).day_count($var['sbSynced'])."</strong>, finding <strong>{$var['sbSyncErrs']}</strong> error".($var['sbSyncErrs']==1?'.':'s.');
|
||||
echo "<tr><td>".($idle ? "Last checked on " : "Activity started on ")."<strong>".my_time($var['sbSynced']).day_count($var['sbSynced'])."</strong>, finding <strong>$error</strong> error".($error==1?'.':'s.');
|
||||
echo "<br><i class='fa fa-clock-o icon'></i><em>".($idle ? "Duration: " : "Last result: ").my_check($duration,$speed)."</em></td><td id='parity'></td></tr>";
|
||||
} else {
|
||||
echo "<tr><td>Last check incomplete on <strong>".my_time($var['sbSynced']).day_count($var['sbSynced'])."</strong>, finding <strong>{$var['sbSyncErrs']}</strong> error".($var['sbSyncErrs']==1?'.':'s.');
|
||||
echo "<tr><td>Last check incomplete on <strong>".my_time($var['sbSynced']).day_count($var['sbSynced'])."</strong>, finding <strong>$error</strong> error".($error==1?'.':'s.');
|
||||
echo "<br><i class='fa fa-dot-circle-o icon'></i><em>Error code: $status</em></td><td id='parity'></td></tr>";
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -380,8 +380,9 @@ case 'parity':
|
||||
$duration = $var['sbSynced2'] - $var['sbSynced'];
|
||||
$status = $var['sbSyncExit'];
|
||||
$speed = ($status==0) ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : "Unavailable";
|
||||
$error = $var['sbSyncErrs'];
|
||||
$year = date('Y',$var['sbSynced2']);
|
||||
if ($status==0||file_exists($log)) file_put_contents($log,"$year $timestamp|$duration|$speed|$status\n",FILE_APPEND);
|
||||
if ($status==0||file_exists($log)) file_put_contents($log,"$year $timestamp|$duration|$speed|$status|$error\n",FILE_APPEND);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ function read_parity_log($epoch,$busy=false) {
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
return $line ?: ($last ?: '0|0|0|0');
|
||||
return $line ?: $last ?: '0|0|0|0|0';
|
||||
}
|
||||
function urlencode_path($path) {
|
||||
return str_replace("%2F", "/", urlencode($path));
|
||||
|
||||
@@ -33,23 +33,23 @@ function my_duration($time) {
|
||||
<link type="text/css" rel="stylesheet" href="/webGui/styles/default-white.css">
|
||||
</head>
|
||||
<body>
|
||||
<table class='share_status' style='margin-top:0'><thead><tr><td>Date</td><td>Duration</td><td>Speed</td><td>Status</td></tr></thead><tbody>
|
||||
<table class='share_status' style='margin-top:0'><thead><tr><td>Date</td><td>Duration</td><td>Speed</td><td>Status</td><td>Errors</td></tr></thead><tbody>
|
||||
<?
|
||||
$log = '/boot/config/parity-checks.log'; $list = [];
|
||||
if (file_exists($log)) {
|
||||
$handle = fopen($log, 'r');
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
list($date,$duration,$speed,$status) = explode('|',$line);
|
||||
list($date,$duration,$speed,$status,$error) = explode('|',$line);
|
||||
if ($speed==0) $speed = 'Unavailable';
|
||||
$date = str_replace(' ',', ',strtr(str_replace(' ',' 0',$date),$month));
|
||||
if ($duration>0||$status<>0) $list[] = "<tr><td>$date</td><td>".my_duration($duration)."</td><td>$speed</td><td>".($status==0?'OK':($status==-4?'Canceled':$status))."</td></tr>";
|
||||
if ($duration>0||$status<>0) $list[] = "<tr><td>$date</td><td>".my_duration($duration)."</td><td>$speed</td><td>".($status==0?'OK':($status==-4?'Canceled':$status))."</td><td>$error</td></tr>";
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
if ($list)
|
||||
for ($i=count($list); $i>=0; --$i) echo $list[$i];
|
||||
else
|
||||
echo "<tr><td colspan='4' style='text-align:center;padding-top:12px'>No parity check history present!</td></tr>";
|
||||
echo "<tr><td colspan='5' style='text-align:center;padding-top:12px'>No parity check history present!</td></tr>";
|
||||
?>
|
||||
</tbody></table>
|
||||
<div style="text-align:center"><input type="button" value="Done" onclick="top.Shadowbox.close()"></div>
|
||||
|
||||
@@ -70,7 +70,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,$duration,$speed,$status) {
|
||||
function read_write_parity_log($epoch,$duration,$speed,$status,$error) {
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$epoch));
|
||||
if (file_exists($log)) {
|
||||
@@ -82,7 +82,7 @@ function read_write_parity_log($epoch,$duration,$speed,$status) {
|
||||
}
|
||||
if (empty($line)) {
|
||||
$year = date('Y',$epoch);
|
||||
$line = "$year $timestamp|$duration|$speed|$status";
|
||||
$line = "$year $timestamp|$duration|$speed|$status|$error";
|
||||
if ($status==0||file_exists($log)) file_put_contents($log,"$line\n",FILE_APPEND);
|
||||
}
|
||||
return $line;
|
||||
@@ -295,10 +295,10 @@ if ($var['mdResync']>0) {
|
||||
$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));
|
||||
list($entry,$duration,$speed,$status,$error) = explode('|', read_write_parity_log($var['sbSynced2'],$duration,$speed,$status,$var['sbSyncErrs']));
|
||||
$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\"");
|
||||
exec("$notify -e \"unRAID $last\" -s \"Notice [$server] - $last finished ($error errors)\" -d \"$info\" -i \"$level\"");
|
||||
unset($saved[$item][$name]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user