mirror of
https://github.com/unraid/webgui.git
synced 2026-01-26 03:29:08 -06:00
@@ -77,9 +77,9 @@ function loadlist(id) {
|
||||
$(function() {
|
||||
loadlist();
|
||||
$('#plugin_tree').fileTree({root:'/boot/',filter:'plg'}, function(file) {$('#plugin_file').val(file);});
|
||||
$('.tabs').append("<span id='updateall' class='status vhshift' style='display:none;margin-left:12px'><input type='button' value='_(Update All Plugins)_' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=updateall\",\"Update All Plugins\",600,600,true,\"loadlist\",\":return\")'></span>");
|
||||
$('.tabs').append("<span id='updateall' class='status vhshift' style='display:none;margin-left:12px'><input type='button' value='_(Update All Plugins)_' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=updateall\",\"_(Update All Plugins)_\",600,600,true,\"loadlist\",\":return\")'></span>");
|
||||
<?if ($check):?>
|
||||
$('.tabs').append("<span id='checkall' class='status vhshift'><input type='button' value='_(Check For Updates)_' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkall\",\"Plugin Update Check\",600,600,true,\"loadlist\",\":return\")' disabled></span>");
|
||||
$('.tabs').append("<span id='checkall' class='status vhshift'><input type='button' value='_(Check For Updates)_' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkall\",\"_(Plugin Update Check)_\",600,600,true,\"loadlist\",\":return\")' disabled></span>");
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -38,7 +38,7 @@ function make_link($method, $arg, $extra='') {
|
||||
$cmd = "/plugins/dynamix.plugin.manager/scripts/plugin&arg1=$method&arg2=$arg".($extra?"&arg3=$extra":"");
|
||||
$exec = "loadlist";
|
||||
}
|
||||
return "$check<input type='button' id='$id' value='".ucfirst(_($method))."' onclick='openBox(\"$cmd\",\"".ucwords(_($method))." Plugin\",600,900,true,\"$exec\",\"$plg\");'$disabled>";
|
||||
return "$check<input type='button' id='$id' value='".ucfirst($method)."' onclick='openBox(\"$cmd\",\"".ucwords($method)." Plugin\",600,900,true,\"$exec\",\"$plg\");'$disabled>";
|
||||
}
|
||||
|
||||
// trying our best to find an icon
|
||||
|
||||
@@ -35,6 +35,6 @@ $tmp = $_GET['tmp'] ? '/var/tmp' : '/tmp/plugins/';
|
||||
|
||||
if (file_exists($file) && strpos(realpath($file),$tmp)===0 && substr($file,-4)=='.txt') echo Markdown(file_get_contents($file)); else echo Markdown("*"._('No release notes available')."!*");
|
||||
?>
|
||||
<br><div style="text-align:center"><input type="button" value="Done" onclick="top.Shadowbox.close()"></div>
|
||||
<br><div style="text-align:center"><input type="button" value="<?=_('Done')?>" onclick="top.Shadowbox.close()"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -138,7 +138,7 @@ foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) {
|
||||
if ($changes !== false) {
|
||||
$txtfile = "/tmp/plugins/".basename($plugin_file,'.plg').".txt";
|
||||
file_put_contents($txtfile,$changes);
|
||||
$version .= " <a href='#' title='View Release Notes' onclick=\"openBox('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=".urlencode($txtfile)."','Release Notes',600,900); return false\"><span class='fa fa-info-circle fa-fw big blue-text'></span></a>";
|
||||
$version .= " <a href='#' title='"._('View Release Notes')."' onclick=\"openBox('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=".urlencode($txtfile)."','"._('Release Notes')."',600,900); return false\"><span class='fa fa-info-circle fa-fw big blue-text'></span></a>";
|
||||
}
|
||||
//write plugin information
|
||||
$empty = false;
|
||||
@@ -164,6 +164,6 @@ foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) {
|
||||
//remove temporary symlink
|
||||
@unlink("/var/log/plugins/$tmp_plg");
|
||||
}
|
||||
if ($empty) echo "<tr><td colspan='6' style='text-align:center;padding-top:12px'><i class='fa fa-check-square-o icon'></i> No plugins installed</td><tr>";
|
||||
if ($empty) echo "<tr><td colspan='6' style='text-align:center;padding-top:12px'><i class='fa fa-check-square-o icon'></i> "._('No plugins installed')."</td><tr>";
|
||||
echo "\0".$updates;
|
||||
?>
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
*/
|
||||
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
//add translations
|
||||
$_SERVER['REQUEST_URI'] = "plugins";
|
||||
require_once "$docroot/plugins/dynamix/include/Translations.php";
|
||||
|
||||
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
|
||||
|
||||
function download_url($url, $path = "") {
|
||||
|
||||
@@ -24,9 +24,31 @@ $bgcolor = strstr('white,azure',$display['theme']) ? '#f2f2f2' : '#1c1c1c';
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.ui.css")?>">
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/plugins/dynamix.docker.manager/styles/style-{$display['theme']}.css")?>">
|
||||
<style>
|
||||
table.divider{margin-top:30px}
|
||||
table.divider{margin-top:20px}
|
||||
</style>
|
||||
<script>
|
||||
function validate(poolname) {
|
||||
var valid = /^[a-z_][a-z0-9_-]*[a-z_]$/;
|
||||
var reserved = ['disk','disks','diskp','diskq','diskr','flash','parity','parity2'];
|
||||
var shares = [<?=implode(',',array_map('escapeshellarg',array_filter(array_map('sharename',scandir('boot/config/shares')))))?>];
|
||||
var pools = [<?=implode(',',array_map('escapeshellarg',$pools))?>];
|
||||
if (!poolname.trim()) return false;
|
||||
if (reserved.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use reserved names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else if (shares.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use user share names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else if (pools.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Pool name already exists)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else if (!valid.test(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Use lowercase characters only and no ending digits)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function addPoolPopup() {
|
||||
var popup = $('#dialogAddPool');
|
||||
// Load popup with the template info
|
||||
@@ -41,17 +63,7 @@ function addPoolPopup() {
|
||||
hide : {effect:'fade', duration:250},
|
||||
buttons: {
|
||||
_(Add)_: function() {
|
||||
var poolname = $(this).find('input[name="poolName"]').val();
|
||||
var valid = /^[a-z_][a-z0-9_-]*[a-z_]$/;
|
||||
var reserved = ['disk','disks','diskp','diskq','diskr','flash','parity','parity2'];
|
||||
var shares = [<?=implode(',',array_map('escapeshellarg',array_filter(array_map('sharename',scandir('boot/config/shares')))))?>];
|
||||
if (reserved.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use reserved names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
} else if (shares.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use user share names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
} else if (!valid.test(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Use lowercase characters only and no ending digits)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
} else if (poolname) {
|
||||
if (validate($(this).find('input[name="poolName"]').val())) {
|
||||
$(this).find('form').submit();
|
||||
$(this).dialog('close');
|
||||
}
|
||||
@@ -103,7 +115,7 @@ pool_status();
|
||||
|
||||
<div id="dialogAddPool" style="display:none"></div>
|
||||
<div id="templatePopupPool" style="display:none">
|
||||
<form markdown="1" method="POST" action="/update.htm" target="progressFrame">
|
||||
<form markdown="1" method="POST" action="/update.htm" target="progressFrame" onsubmit="return validate(this.poolName.value)">
|
||||
<input type="hidden" name="changeSlots" value="apply">
|
||||
_(Name)_:
|
||||
: <input type="text" name="poolName" maxlength="40" value="<?=count($pools)==0?'cache':''?>">
|
||||
|
||||
@@ -221,6 +221,28 @@ function xfsCheck(path) {
|
||||
function updateMode(form,mode) {
|
||||
$(form).find('input[name="#arg[3]"]').val(mode);
|
||||
}
|
||||
function validate(poolname) {
|
||||
var valid = /^[a-z_][a-z0-9_-]*[a-z_]$/;
|
||||
var reserved = ['disk','disks','diskp','diskq','diskr','flash','parity','parity2'];
|
||||
var shares = [<?=implode(',',array_map('escapeshellarg',array_filter(array_map('sharename',scandir('boot/config/shares')))))?>];
|
||||
var pools = [<?=implode(',',array_map('escapeshellarg',$pools))?>];
|
||||
if (!poolname.trim()) return false;
|
||||
if (reserved.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use reserved names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else if (shares.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use user share names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else if (pools.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Pool name already exists)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else if (!valid.test(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Use lowercase characters only and no ending digits)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function renamePoolPopup() {
|
||||
var popup = $('#dialogRenamePool');
|
||||
// Load popup with the template info
|
||||
@@ -235,17 +257,7 @@ function renamePoolPopup() {
|
||||
hide : {effect:'fade', duration:250},
|
||||
buttons: {
|
||||
_(Rename)_: function() {
|
||||
var poolname = $(this).find('input[name="poolName"]').val();
|
||||
var valid = /^[a-z_][a-z0-9_-]*[a-z_]$/;
|
||||
var reserved = ['disk','disks','diskp','diskq','diskr','flash','parity','parity2'];
|
||||
var shares = [<?=implode(',',array_map('escapeshellarg',array_filter(array_map('sharename',scandir('boot/config/shares')))))?>];
|
||||
if (reserved.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use reserved names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
} else if (shares.includes(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Do not use user share names)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
} else if (!valid.test(poolname)) {
|
||||
swal({title:'_(Invalid pool name)_',text:'_(Use lowercase characters only and no ending digits)_',type:'error',confirmButtonText:'_(Ok)_'});
|
||||
} else if (poolname) {
|
||||
if (validate($(this).find('input[name="poolName"]').val())) {
|
||||
$(this).find('form').submit();
|
||||
$(this).dialog('close');
|
||||
}
|
||||
@@ -808,7 +820,7 @@ _(SMART attribute notifications)_:
|
||||
|
||||
<div id="dialogRenamePool" style="display:none"></div>
|
||||
<div id="templatePopupPool" style="display:none">
|
||||
<form markdown="1" method="POST" action="/update.htm" target="progressFrame">
|
||||
<form markdown="1" method="POST" action="/update.htm" target="progressFrame" onsubmit="return validate(this.poolName.value)">
|
||||
<input type="hidden" name="poolNameOrig" value="<?=$name?>">
|
||||
<input type="hidden" name="changeSlots" value="apply">
|
||||
_(Name)_:
|
||||
|
||||
@@ -50,8 +50,7 @@ function globalInclude($name) {
|
||||
}
|
||||
|
||||
// global shares include/exclude
|
||||
$disks = array_filter($disks,'my_disks');
|
||||
$myDisks = array_filter(array_diff(array_keys($disks), explode(',',$var['shareUserExclude'])), 'globalInclude');
|
||||
$myDisks = array_filter(array_diff(array_keys(array_filter($disks,'my_disks')), explode(',',$var['shareUserExclude'])), 'globalInclude');
|
||||
?>
|
||||
:help3
|
||||
> A *Share*, also called a *User Share*, is simply the name of a top-level directory that exists on one or more of your
|
||||
|
||||
@@ -60,4 +60,4 @@ To see natural IOMMU groups for your hardware, go to the <b><a href="/Settings/V
|
||||
> Note that linux groups ATA, SATA and SAS devices with true SCSI devices.
|
||||
|
||||
<pre><table id='t4' class='pre'><tr><td><div class="spinner"></div></td></tr></table></pre>
|
||||
<input type="button" value="Done" onclick="done()">
|
||||
<input type="button" value="_(Done)_" onclick="done()">
|
||||
|
||||
@@ -14,13 +14,11 @@ Tag="user"
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
|
||||
<?if (!array_key_exists($name, $users)):?>
|
||||
<p class="notice">User <?=htmlspecialchars($name)?> has been deleted.</p><br>
|
||||
<input type="button" value="Done" onClick="done()">
|
||||
<p class="notice"><?=sprintf(_('User %s has been deleted'),htmlspecialchars($name))?>.</p><br>
|
||||
<input type="button" value="_(Done)_" onClick="done()">
|
||||
<?return;?>
|
||||
<?endif;?>
|
||||
|
||||
<?
|
||||
$user = "/boot/config/plugins/dynamix/users/$name.png";
|
||||
$void = "<img src='/webGui/images/user.png' width='48' height='48' id='image' onclick='$("#drop").click()' style='cursor:pointer' title='Click to select PNG file'>";
|
||||
@@ -122,7 +120,7 @@ $(function(){
|
||||
data:{"csrf_token":"<?=$var['csrf_token']?>"},
|
||||
beforeEach:function(file) {
|
||||
if (!file.type.match(/^image\/png/)) {
|
||||
swal({title:"Warning",text:"Only PNG images are allowed!",type:"warning",confirmButtonText:'_(Ok)_'});
|
||||
swal({title:"Warning",text:"_(Only PNG images are allowed)_!",type:"warning",confirmButtonText:'_(Ok)_'});
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -636,9 +636,8 @@ $(function() {
|
||||
$('input[value="<?=_('Apply')?>"],input[value="Apply"],input[name="cmdEditShare"],input[name="cmdUserEdit"]').prop('disabled',true);
|
||||
$('form').find('select,input[type=text],input[type=number],input[type=password],input[type=checkbox],input[type=radio],input[type=file],textarea').each(function(){$(this).on('input change',function() {
|
||||
var form = $(this).parentsUntil('form').parent();
|
||||
form.find('input[value="<?=_('Apply')?>"],input[value="Apply"],input[name="cmdEditShare"],input[name="cmdUserEdit"]').not('input.lock').prop('disabled',false);
|
||||
form.find('input[value="<?=_('Done')?>"]').not('input.lock').val('<?=_('Reset')?>').prop('onclick',null).off('click').click(function(){refresh(form.offset().top)});
|
||||
form.find('input[value="Done"]').not('input.lock').val('Reset').prop('onclick',null).off('click').click(function(){refresh(form.offset().top)});
|
||||
form.find('input[value="<?=_("Apply")?>"],input[value="Apply"],input[name="cmdEditShare"],input[name="cmdUserEdit"]').not('input.lock').prop('disabled',false);
|
||||
form.find('input[value="<?=_("Done")?>"],input[value="Done"]').not('input.lock').val('<?=_("Reset")?>').prop('onclick',null).off('click').click(function(){refresh(form.offset().top)});
|
||||
});});
|
||||
|
||||
var top = ($.cookie('top')||0) - $('.tabs').offset().top - 75;
|
||||
|
||||
@@ -46,7 +46,7 @@ function in_parity_log($log,$timestamp) {
|
||||
return !empty($line);
|
||||
}
|
||||
function device_info(&$disk,$online) {
|
||||
global $path, $var, $crypto;
|
||||
global $pools, $path, $var, $crypto;
|
||||
$name = $disk['name'];
|
||||
$fancyname = $disk['type']=='New' ? $name : my_lang(my_disk($name),3);
|
||||
$type = $disk['type']=='Flash' || $disk['type']=='New' ? $disk['type'] : 'Device';
|
||||
@@ -71,7 +71,7 @@ function device_info(&$disk,$online) {
|
||||
$link = ($disk['type']=='Parity' && strpos($disk['status'],'_NP')===false) ||
|
||||
($disk['type']=='Data' && $disk['status']!='DISK_NP') ||
|
||||
($disk['type']=='Cache' && $disk['status']!='DISK_NP') ||
|
||||
($disk['name']=='cache') || ($disk['name']=='flash') ||
|
||||
($disk['name']=='flash') || in_array($disk['name'],$pools) ||
|
||||
$disk['type']=='New' ? "<a href=\"".htmlspecialchars("$path/$type?name=$name")."\">".$fancyname."</a>" : $fancyname;
|
||||
if ($crypto) switch ($disk['luksState']) {
|
||||
case 0:
|
||||
@@ -212,7 +212,7 @@ function array_offline(&$disk) {
|
||||
echo "</tr>";
|
||||
}
|
||||
function array_online(&$disk) {
|
||||
global $sum, $diskio;
|
||||
global $pools, $sum, $diskio;
|
||||
if ($disk['device']!='') {
|
||||
$dev = $disk['device'];
|
||||
$data = explode(' ',$diskio[$dev] ?? '0 0');
|
||||
@@ -235,9 +235,9 @@ function array_online(&$disk) {
|
||||
echo "<tr>";
|
||||
switch ($disk['status']) {
|
||||
case 'DISK_NP':
|
||||
if ($disk['name']=="cache") {
|
||||
if (in_array($disk['name'],$pools)) {
|
||||
echo "<td>".device_info($disk,true)."</td>";
|
||||
echo "<td><em>"._('Not installed')."</em></td>";
|
||||
echo "<td><a class='none nohand'><i class=\"icon-disk icon\"></i><span></span></a><em>"._('Not installed')."</em></td>";
|
||||
echo "<td colspan='4'></td>";
|
||||
fs_info($disk);
|
||||
}
|
||||
@@ -344,6 +344,8 @@ function cache_slots($off,$pool,$min,$slots) {
|
||||
return $out;
|
||||
}
|
||||
$crypto = false;
|
||||
$cache = cache_filter($disks);
|
||||
$pools = pools_filter($cache);
|
||||
switch ($_POST['device']) {
|
||||
case 'array':
|
||||
$parity = parity_filter($disks);
|
||||
@@ -378,8 +380,7 @@ case 'flash':
|
||||
echo "</tr>";
|
||||
break;
|
||||
case 'cache':
|
||||
$cache = cache_filter($disks);
|
||||
foreach (pools_filter($cache) as $pool) {
|
||||
foreach ($pools as $pool) {
|
||||
$tmp = "/var/tmp/$pool.log.tmp";
|
||||
foreach ($cache as $disk) if (prefix($disk['name'])==$pool) $crypto |= $disk['luksState']!=0 || vfs_luks($disk['fsType']);
|
||||
if ($var['fsState']=='Stopped') {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2018, Lime Technology
|
||||
* Copyright 2012-2018, Bergware International.
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, 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,
|
||||
@@ -17,62 +17,24 @@ $devs = parse_ini_file("/var/local/emhttp/devs.ini",true);
|
||||
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);
|
||||
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/webGui/include/Preselect.php";
|
||||
require_once "$docroot/webGui/include/CustomMerge.php";
|
||||
|
||||
extract(parse_plugin_cfg("dynamix",true));
|
||||
|
||||
$notify = "$docroot/webGui/scripts/notify";
|
||||
$ram = "/var/local/emhttp/monitor.ini";
|
||||
$rom = "/boot/config/plugins/dynamix/monitor.ini";
|
||||
$saved = @parse_ini_file($ram,true);
|
||||
$unraid = parse_plugin_cfg("dynamix",true);
|
||||
$high1 = $unraid['display']['critical'];
|
||||
$high2 = $unraid['display']['warning'];
|
||||
$high1 = $display['critical'];
|
||||
$high2 = $display['warning'];
|
||||
$server = strtoupper($var['NAME']);
|
||||
$pools = pools_filter($disks);
|
||||
$errors = [];
|
||||
$top = 120;
|
||||
|
||||
function plus($val,$word,$last) {
|
||||
return $val>0 ? (($val||$last) ? ($val.' '.$word.($val!=1?'s':'').($last ?'':', ')) : '') : '';
|
||||
}
|
||||
function my_temp($value) {
|
||||
global $unraid;
|
||||
$unit = $unraid['display']['unit'];
|
||||
return ($unit=='F' ? round(9/5*$value+32) : $value)." $unit";
|
||||
}
|
||||
function my_disk($name) {
|
||||
return ucfirst(preg_replace('/^(disk|cache|parity)(\d+)/','$1 $2',$name));
|
||||
}
|
||||
function my_scale($value, &$unit, $decimals=NULL, $scale=NULL) {
|
||||
global $unraid;
|
||||
$scale = $scale ?? $unraid['display']['scale'];
|
||||
$number = $unraid['display']['number'];
|
||||
$units = ['B','KB','MB','GB','TB','PB','EB','ZB','YB'];
|
||||
$size = count($units);
|
||||
if ($scale==0 && ($decimals===NULL || $decimals<0)) {
|
||||
$decimals = 0;
|
||||
$unit = '';
|
||||
} else {
|
||||
$base = $value ? floor(log($value, 1000)) : 0;
|
||||
if ($scale>0 && $base>$scale) $base = $scale;
|
||||
if ($base>$size) $base = $size-1;
|
||||
$value /= pow(1000, $base);
|
||||
if ($decimals===NULL) $decimals = $value>=100 ? 0 : ($value>=10 ? 1 : (round($value*100)%100===0 ? 0 : 2));
|
||||
elseif ($decimals<0) $decimals = $value>=100||round($value*10)%10===0 ? 0 : abs($decimals);
|
||||
if ($scale<0 && round($value,-1)==1000) {$value = 1; $base++;}
|
||||
$unit = $units[$base];
|
||||
}
|
||||
return number_format($value, $decimals, $number[0], $value>=10000 ? $number[1] : '');
|
||||
}
|
||||
function my_check($time,$speed) {
|
||||
if (!$time) return 'unavailable (no parity-check entries logged)';
|
||||
$days = floor($time/86400);
|
||||
$hmss = $time-$days*86400;
|
||||
$hour = floor($hmss/3600);
|
||||
$mins = $hmss/60%60;
|
||||
$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,$error) {
|
||||
$log = '/boot/config/parity-checks.log';
|
||||
$timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$epoch));
|
||||
@@ -91,10 +53,10 @@ function read_write_parity_log($epoch,$duration,$speed,$status,$error) {
|
||||
return str_replace("\n","",$line);
|
||||
}
|
||||
function check_temp($name,$temp,$text,$info) {
|
||||
global $notify,$disks,$saved,$unraid,$server,$top;
|
||||
global $notify,$disks,$saved,$display,$server,$top;
|
||||
$disk = &$disks[$name];
|
||||
$hot = $disk['hotTemp'] ?? $unraid['display']['hot'];
|
||||
$max = $disk['maxTemp'] ?? $unraid['display']['max'];
|
||||
$hot = $disk['hotTemp'] ?? $display['hot'];
|
||||
$max = $disk['maxTemp'] ?? $display['max'];
|
||||
$warn = exceed($temp,$max,$top) ? 'alert' : (exceed($temp,$hot,$top) ? 'warning' : '');
|
||||
$item = 'temp';
|
||||
$last = $saved[$item][$name] ?? 0;
|
||||
@@ -169,11 +131,11 @@ function check_smart($name,$port,$text,$info) {
|
||||
if (!file_exists($file) || (time()-filemtime($file)>$var['poll_attributes'])) exec("smartctl -n standby -H $type ".escapeshellarg("/dev/$port")."|grep -Pom1 '^SMART.*: \K[A-Z]+'|tr -d '\n' >".escapeshellarg($file));
|
||||
}
|
||||
function check_usage($name,$used,$text,$info) {
|
||||
global $notify,$disks,$saved,$unraid,$server;
|
||||
global $notify,$disks,$saved,$display,$server;
|
||||
if ($used == -1) return;
|
||||
$disk = &$disks[$name];
|
||||
$warning = $disk['warning'] ?? $unraid['display']['warning'];
|
||||
$critical = $disk['critical'] ?? $unraid['display']['critical'];
|
||||
$warning = $disk['warning'] ?? $display['warning'];
|
||||
$critical = $disk['critical'] ?? $display['critical'];
|
||||
$warn = exceed($used,$critical) ? 'alert' : (exceed($used,$warning) ? 'warning' : '');
|
||||
$item = 'used';
|
||||
$last = $saved[$item][$name] ?? 0;
|
||||
@@ -194,7 +156,7 @@ function check_usage($name,$used,$text,$info) {
|
||||
foreach ($disks as $disk) {
|
||||
$name = $disk['name'];
|
||||
if ($name=='flash' || substr($disk['status'],-3)=='_NP') continue;
|
||||
$text = my_disk($name).($name=='cache'||$name=='parity'?' disk':'');
|
||||
$text = my_disk($name).(in_array($name,$pools)||$name=='parity'?' disk':'');
|
||||
$info = !empty($disk['id']) ? "{$disk['id']} ({$disk['device']})" : "No device identification ({$disk['device']})";
|
||||
// process disk temperature notifications
|
||||
check_temp($name,$disk['temp'],$text,$info);
|
||||
@@ -209,21 +171,27 @@ foreach ($disks as $disk) {
|
||||
switch ($warn) {
|
||||
case 'red':
|
||||
if ($warn!=$last) {
|
||||
$status = strtolower(str_replace(['NP_','_'],['',' '],$disk['status']));
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text error")." -s ".escapeshellarg("Alert [$server] - $text in error state ($status)")." -d ".escapeshellarg("$info")." -i \"alert\"");
|
||||
if ($var['fsState']!='Stopped') {
|
||||
$status = strtolower(str_replace(['NP_','_'],['',' '],$disk['status']));
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text error")." -s ".escapeshellarg("Alert [$server] - $text in error state ($status)")." -d ".escapeshellarg("$info")." -i \"alert\"");
|
||||
}
|
||||
$saved[$item][$name] = $warn;
|
||||
}
|
||||
break;
|
||||
case 'yellow':
|
||||
if ($warn!=$last) {
|
||||
$status = $name=='parity' ? "parity-sync in progress" : "drive not ready, content being reconstructed";
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text error")." -s ".escapeshellarg("Warning [$server] - $text, $status")." -d ".escapeshellarg("$info")." -i \"warning\"");
|
||||
if ($var['fsState']!='Stopped') {
|
||||
$status = $name=='parity' ? "parity-sync in progress" : "drive not ready, content being reconstructed";
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text error")." -s ".escapeshellarg("Warning [$server] - $text, $status")." -d ".escapeshellarg("$info")." -i \"warning\"");
|
||||
}
|
||||
$saved[$item][$name] = $warn;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($last) {
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text message")." -s ".escapeshellarg("Notice [$server] - $text returned to normal operation")." -d ".escapeshellarg("$info"));
|
||||
if ($var['fsState']!='Stopped') {
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text message")." -s ".escapeshellarg("Notice [$server] - $text returned to normal operation")." -d ".escapeshellarg("$info"));
|
||||
}
|
||||
unset($saved[$item][$name]);
|
||||
}
|
||||
break;}
|
||||
@@ -231,7 +199,7 @@ foreach ($disks as $disk) {
|
||||
if ($disk['numErrors']>0) $errors[] = "$text - $info (errors {$disk['numErrors']})";
|
||||
// check file system of cache pool
|
||||
$item = 'pool';
|
||||
if ($name=='cache' && strpos($disk['fsType'],'btrfs')!==false) {
|
||||
if (in_array($name,$pools) && strpos($disk['fsType'],'btrfs')!==false) {
|
||||
$attr = 'missing';
|
||||
if (exec("/sbin/btrfs filesystem show {$disk['uuid']} 2>/dev/null|grep -c 'missing'")>0) {
|
||||
if (empty($saved[$item][$attr])) {
|
||||
@@ -239,10 +207,10 @@ foreach ($disks as $disk) {
|
||||
$saved[$item][$attr] = 1;
|
||||
}
|
||||
} elseif (isset($saved[$item][$attr])) unset($saved[$item][$attr]);
|
||||
$attr = 'profile';
|
||||
if (exec("/sbin/btrfs filesystem df /mnt/cache 2>/dev/null|grep -c '^Data'")>1) {
|
||||
$attr = "profile-$name";
|
||||
if (exec("/sbin/btrfs filesystem df /mnt/$name 2>/dev/null|grep -c '^Data'")>1) {
|
||||
if (empty($saved[$item][$attr])) {
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text message")." -s ".escapeshellarg("Warning [$server] - Cache pool BTRFS too many profiles (You can ignore this warning when a cache pool balance operation is in progress)")." -d ".escapeshellarg("$info")." -i \"warning\"");
|
||||
exec("$notify -e ".escapeshellarg("Unraid $text message")." -s ".escapeshellarg("Warning [$server] - $pool pool BTRFS too many profiles (You can ignore this warning when a pool balance operation is in progress)")." -d ".escapeshellarg("$info")." -i \"warning\"");
|
||||
$saved[$item][$attr] = 1;
|
||||
}
|
||||
} elseif (isset($saved[$item][$attr])) unset($saved[$item][$attr]);
|
||||
|
||||
Reference in New Issue
Block a user