mirror of
https://github.com/unraid/webgui.git
synced 2026-01-22 17:40:19 -06:00
Fixed parity duration + speed when paused/resumed
This commit is contained in:
@@ -198,14 +198,18 @@ function stopParity(form,text) {
|
||||
<?endif;?>
|
||||
}
|
||||
function pauseParity(form) {
|
||||
$(form).append('<input type="hidden" name="cmdNoCheck" value="Pause">');
|
||||
$('#pauseButton').val("_(Resume)_").prop('onclick',null).off('click').click(function(){resumeParity(form);});
|
||||
form.submit();
|
||||
$.post('/webGui/include/ParityControl.php',{action:'pause'},function(){
|
||||
$(form).append('<input type="hidden" name="cmdNoCheck" value="Pause">');
|
||||
$('#pauseButton').val("_(Resume)_").prop('onclick',null).off('click').click(function(){resumeParity(form);});
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
function resumeParity(form) {
|
||||
$(form).append('<input type="hidden" name="cmdCheck" value="Resume">');
|
||||
$('#pauseButton').val("_(Pause)_").prop('onclick',null).off('click').click(function(){pauseParity(form);});
|
||||
form.submit();
|
||||
$.post('/webGui/include/ParityControl.php',{action:'resume'},function(){
|
||||
$(form).append('<input type="hidden" name="cmdCheck" value="Resume">');
|
||||
$('#pauseButton').val("_(Pause)_").prop('onclick',null).off('click').click(function(){pauseParity(form);});
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
function shutdown_now(form,cmd) {
|
||||
$(form).append('<input type="hidden" name="cmd" value="'+cmd+'">');
|
||||
@@ -362,7 +366,7 @@ function formatWarning(val) {
|
||||
<? endif;
|
||||
else:
|
||||
$duration = $var['sbSynced2']-$var['sbSynced'];
|
||||
$speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';?>
|
||||
$speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":0;?>
|
||||
<td class="wrap"><?=sprintf(_('Last check completed on **%s**'),_(my_time($var['sbSynced2']).day_count($var['sbSynced2']),0))?><br><?=sprintf(_('Finding **%s** error'.($var['sbSyncErrs']==1?'':'s')),$var['sbSyncErrs']?:'0')?>
|
||||
<i class="fa fa-fw fa-clock-o"></i>_(Duration)_: <?=my_check($duration,$speed)?></td></tr>
|
||||
<? endif;
|
||||
|
||||
@@ -662,8 +662,9 @@ watchdog.on('message', function(d) {
|
||||
else if (ini['mdResyncAction']=="check") action = "<?=_('Read-Check')?>";
|
||||
else if (ini['mdResyncAction'].indexOf("check")>=0) action = "<?=_('Parity-Check')?>";
|
||||
action += " "+(ini['mdResyncPos']/(ini['mdResyncSize']/100+1)).toFixed(1)+" %";
|
||||
status += "•<span class='orange strong'>"+action.replace('.','<?=$display['number'][0]?>')+"</span>";
|
||||
if (ini['mdResync']==0) status += "(<?=_('Paused')?>)";
|
||||
status += "•<span class='orange strong'>"+action.replace('.','<?=$display['number'][0]?>');
|
||||
if (ini['mdResync']==0) status += " • <?=_('Paused')?>";
|
||||
status += "</span>";
|
||||
}
|
||||
if (progress) status += "•<span class='blue strong'>"+_(progress)+"</span>";
|
||||
$('#statusbar').html(status);
|
||||
|
||||
24
plugins/dynamix/include/ParityControl.php
Normal file
24
plugins/dynamix/include/ParityControl.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$stamps = '/var/tmp/stamps.ini';
|
||||
|
||||
switch ($_POST['action']) {
|
||||
case 'pause':
|
||||
if (!file_exists($stamps)) file_put_contents($stamps,parse_ini_file('/var/local/emhttp/var.ini')['sbSynced']);
|
||||
case 'resume':
|
||||
file_put_contents($stamps,','.time(),FILE_APPEND);
|
||||
break;
|
||||
}
|
||||
?>
|
||||
@@ -16,6 +16,7 @@ session_start();
|
||||
$docroot = '/usr/local/emhttp';
|
||||
$varroot = '/var/local/emhttp';
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
$stamps = '/var/tmp/stamps.ini';
|
||||
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/publish.php";
|
||||
@@ -75,10 +76,12 @@ while (true) {
|
||||
$locale_init = $display['locale'];
|
||||
update_translation($locale_init);
|
||||
}
|
||||
$synced = file_exists($stamps) ? explode(',',file_get_contents($stamps)) : [];
|
||||
$sbSynced = array_shift($synced);
|
||||
if ($var['mdResyncPos']) {
|
||||
$data = [];
|
||||
$data[] = my_scale($var['mdResyncSize']*1024,$unit,-1)." $unit";
|
||||
$data[] = _(my_clock(floor((time()-$var['sbSynced'])/60)),2).($var['mdResyncDt'] ? '' : ' ('._('paused').')');
|
||||
$data[] = _(my_clock(floor((time()-($sbSynced?:$var['sbSynced']))/60)),2).($var['mdResyncDt'] ? '' : ' ('._('paused').')');
|
||||
$data[] = my_scale($var['mdResyncPos']*1024,$unit)." $unit (".number_format(($var['mdResyncPos']/($var['mdResyncSize']/100+1)),1,$display['number'][0],'')." %)";
|
||||
$data[] = $var['mdResyncDt'] ? my_scale($var['mdResyncDb']*1024/$var['mdResyncDt'],$unit, 1)." $unit/sec" : '---';
|
||||
$data[] = $var['mdResyncDb'] ? _(my_clock(round(((($var['mdResyncDt']*(($var['mdResyncSize']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0)),2) : _('Unknown');
|
||||
@@ -88,12 +91,14 @@ while (true) {
|
||||
if ($var['sbSynced']>0 && $var['sbSynced2']>0) {
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$var['sbSynced2']));
|
||||
if (!in_parity_log($log,$timestamp)) {
|
||||
$duration = $var['sbSynced2'] - $var['sbSynced'];
|
||||
$idle = []; while (count($synced)>1) $idle[] = array_pop($synced) - array_pop($synced);
|
||||
$duration = $var['sbSynced2'] - ($sbSynced?:$var['sbSynced']);
|
||||
$status = $var['sbSyncExit'];
|
||||
$speed = ($status==0) ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : _('Unavailable');
|
||||
$speed = $status==0 ? my_scale($var['mdResyncSize']*1024/($duration+array_sum($idle)),$unit,1)." $unit/s" : 0;
|
||||
$error = $var['sbSyncErrs'];
|
||||
$year = date('Y',$var['sbSynced2']);
|
||||
if ($status==0||file_exists($log)) file_put_contents($log,"$year $timestamp|$duration|$speed|$status|$error\n",FILE_APPEND);
|
||||
if (file_exists($stamps)) unlink($stamps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ while (true) {
|
||||
} else {
|
||||
$status = 0;
|
||||
$duration = $var['sbSynced2']-$var['sbSynced'];
|
||||
$speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';
|
||||
$speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":0;
|
||||
$echo[4] = sprintf(_('Last check completed on **%s**'),_(my_time($var['sbSynced2']).day_count($var['sbSynced2']),0)).'<br>'.sprintf(_('Finding **%s** error'.($var['sbSyncErrs']==1?'':'s')),$var['sbSyncErrs']?:'0');
|
||||
$echo[4] .= " <i class='fa fa-fw fa-clock-o'></i> "._('Duration').': '.my_check($duration,$speed);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ $errors = [];
|
||||
$top = 120;
|
||||
|
||||
function read_write_parity_log($epoch,$duration,$speed,$status,$error) {
|
||||
global $stamps;
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$epoch));
|
||||
if (file_exists($log)) {
|
||||
@@ -54,6 +55,7 @@ function read_write_parity_log($epoch,$duration,$speed,$status,$error) {
|
||||
$year = date('Y',$epoch);
|
||||
$line = "$year $timestamp|$duration|$speed|$status|$error";
|
||||
if ($status==0||file_exists($log)) file_put_contents($log,"$line\n",FILE_APPEND);
|
||||
if (file_exists($stamps)) unlink($stamps);
|
||||
}
|
||||
return str_replace("\n","",$line);
|
||||
}
|
||||
@@ -256,6 +258,7 @@ if ($warn>0) {
|
||||
// process parity check, parity sync and data-rebuild notifications
|
||||
$name = 'parity';
|
||||
$last = $saved[$item][$name] ?? '';
|
||||
$stamps = '/var/tmp/stamps.ini';
|
||||
if ($var['mdResyncPos']) {
|
||||
if (!$last) {
|
||||
if (strstr($var['mdResyncAction'],"recon")) {
|
||||
@@ -273,9 +276,12 @@ if ($var['mdResyncPos']) {
|
||||
}
|
||||
} else {
|
||||
if ($last) {
|
||||
$duration = $var['sbSynced2'] - $var['sbSynced'];
|
||||
$status = $var['sbSyncExit'];
|
||||
$speed = $status==0 ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : "Unavailable";
|
||||
$synced = file_exists($stamps) ? array_filter(explode(',',file_get_contents($stamps))) : [];
|
||||
$sbSynced = array_shift($synced);
|
||||
$idle = []; while (count($synced)>1) $idle[] = array_pop($synced) - array_pop($synced);
|
||||
$duration = $var['sbSynced2'] - ($sbSynced?:$var['sbSynced']);
|
||||
$status = $var['sbSyncExit'];
|
||||
$speed = $status==0 ? my_scale($var['mdResyncSize']*1024/($duration+array_sum($idle)),$unit,1)." $unit/s" : 0;
|
||||
[$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";
|
||||
|
||||
Reference in New Issue
Block a user