mirror of
https://github.com/unraid/webgui.git
synced 2026-05-12 07:10:52 -05:00
webGui: new watchdog service with websockets instead of ajax polling
This commit is contained in:
@@ -245,21 +245,6 @@ function closeNotifier(filter) {
|
||||
function viewHistory(filter) {
|
||||
location.replace('/Tools/NotificationsArchive?filter='+filter);
|
||||
}
|
||||
function watchdog() {
|
||||
$.post('/webGui/include/Watchdog.php',{mode:<?=$display['refresh']?>,dot:'<?=$display['number'][0]?>'},function(data) {
|
||||
if (data) {
|
||||
$.each(data.split('#'),function(k,v) {
|
||||
<?if ($update):?>
|
||||
if (v!='stop') $('#statusbar').html(v); else setTimeout(refresh,0);
|
||||
});
|
||||
timers.watchdog = setTimeout(watchdog,<?=abs($display['refresh'])?>);
|
||||
<?else:?>
|
||||
if (v!='stop') $('#statusbar').html(v);
|
||||
});
|
||||
<?endif;?>
|
||||
}
|
||||
});
|
||||
}
|
||||
function countDown() {
|
||||
counting--;
|
||||
if (counting==0) counting = update;
|
||||
@@ -419,7 +404,6 @@ $(function() {
|
||||
form.find('input[value="Apply"],input[name="cmdEditShare"],input[name="cmdUserEdit"]').removeAttr('disabled');
|
||||
form.find('input[value="Done"]').val('Reset').prop('onclick',null).click(function(){refresh(form.offset().top)});
|
||||
});});
|
||||
timers.watchdog = setTimeout(watchdog,50);
|
||||
var top = ($.cookie('top')||0) - $('.tabs').offset().top - 75;
|
||||
if (top>0) {$('html,body').scrollTop(top);}
|
||||
$.removeCookie('top',{path:'/'});
|
||||
@@ -486,7 +470,10 @@ $(function() {
|
||||
}
|
||||
|
||||
$('form').append($('<input>').attr({type:'hidden', name:'csrf_token', value:'<?=$var['csrf_token']?>'}));
|
||||
var watchdog = new NchanSubscriber('/sub/watchdog');
|
||||
watchdog.on('message', function(data){$('#statusbar').html(data);});
|
||||
watchdog.start();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
PREV=
|
||||
while :; do
|
||||
. /var/local/emhttp/var.ini
|
||||
case $fsState in
|
||||
Stopped)
|
||||
DATA="<span class='red strong'>Array Stopped</span>"
|
||||
;;
|
||||
Starting)
|
||||
DATA="<span class='orange strong'>Array Starting</span>"
|
||||
;;
|
||||
*)
|
||||
DATA="<span class='green strong'>Array Started</span>"
|
||||
;;
|
||||
esac
|
||||
if [[ $mdResync -gt 0 ]]; then
|
||||
MODE=
|
||||
if [[ $mdResyncAction =~ recon ]]; then
|
||||
MODE='Parity-Sync / Data-Rebuild'
|
||||
elif [[ $mdResyncAction =~ clear ]]; then
|
||||
MODE='Clearing'
|
||||
elif [[ $mdResyncAction == check ]]; then
|
||||
MODE='Read-Check'
|
||||
elif [[ $mdResyncAction =~ check ]]; then
|
||||
MODE='Parity-Check'
|
||||
fi
|
||||
p=$((mdResyncPos*1000/mdResync)); w=${p:0:-1}
|
||||
DATA="$DATA•<span class='orange strong'>$MODE ${w:-0}.${p: -1} %</span>"
|
||||
fi
|
||||
if [[ $DATA != $PREV ]]; then
|
||||
curl -s -X POST -d "$DATA" http://127.0.0.1/pub/watchdog?buffer_length=1 &>/dev/null
|
||||
PREV=$DATA
|
||||
fi
|
||||
sleep 3
|
||||
done &
|
||||
Reference in New Issue
Block a user