mirror of
https://github.com/unraid/webgui.git
synced 2026-03-10 04:49:14 -05:00
Multi cache pools
This commit is contained in:
@@ -26,7 +26,9 @@ $pools = array_unique(array_map('prefix',array_keys($cache)));
|
||||
$i = 0;
|
||||
?>
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.ui.css")?>">
|
||||
|
||||
<style>
|
||||
table.divider{margin-top:2px}
|
||||
</style>
|
||||
<script>
|
||||
function addPoolPopup() {
|
||||
var popup = $('#dialogAddPool');
|
||||
@@ -86,7 +88,7 @@ pool_status();
|
||||
|
||||
<?foreach ($pools as $pool):?>
|
||||
<?if ($cache[$pool]['devicesSb'] || $var['fsState']=='Stopped'):?>
|
||||
<table class="disk_status wide"<?=$i?' style="margin-top:0"':''?>>
|
||||
<table class="disk_status wide<?=$i?' divider':''?>">
|
||||
<thead><tr><td>_(Device)_</td><td>_(Identification)_</td><td>_(Temp)_.</td><td>_(Reads)_</td><td>_(Writes)_</td><td>_(Errors)_</td><td>_(FS)_</td><td>_(Size)_</td><td>_(Used)_</td><td>_(Free)_</td><td>_(View)_</td></tr></thead>
|
||||
<tbody id="pool_device<?=$i++?>">
|
||||
<?foreach ($cache as $disk) if (prefix($disk['name']==$pool)) echo "<tr><td colspan='11'> </td></tr>";?>
|
||||
@@ -96,14 +98,13 @@ pool_status();
|
||||
<?endforeach;?>
|
||||
<?if ($var['fsState']=='Stopped'):?>
|
||||
<input type="button" value="Add Pool" style="margin:0" onclick="addPoolPopup()">
|
||||
<?endif;?>
|
||||
|
||||
<div id="dialogAddPool" style="display:none"></div>
|
||||
<div id="templatePopupPool" style="display:none">
|
||||
<form markdown="1" method="POST" action="/update.htm" target="progressFrame">
|
||||
<input type="hidden" name="changeSlots" value="apply">
|
||||
_(Name)_:
|
||||
: <input type="text" name="poolName" maxlength="40">
|
||||
: <input type="text" name="poolName" maxlength="40" value="">
|
||||
|
||||
_(Slots)_:
|
||||
: <select name="poolSlots">
|
||||
@@ -113,6 +114,7 @@ _(Slots)_:
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<?endif;?>
|
||||
|
||||
:help3
|
||||
> **Colored Status Indicator** the significance of the color indicator at the beginning of each line in *Pool Devices* is as follows:
|
||||
|
||||
@@ -40,6 +40,9 @@ function data_devices($disk) {
|
||||
function cache_devices($disk) {
|
||||
return $disk['type']=='Cache';
|
||||
}
|
||||
function prefix($key) {
|
||||
return preg_replace('/[0-9]+$/','',$key);
|
||||
}
|
||||
function vpn_peers($file) {
|
||||
$peers = [];
|
||||
$entries = array_filter(array_map('trim',preg_split('/\[(Interface|Peer)\]/',file_get_contents($file))));
|
||||
@@ -59,15 +62,19 @@ $apcupsd = file_exists('/var/run/apcupsd.pid');
|
||||
$wireguard = is_executable('/usr/bin/wg') && file_exists('/var/log/plugins/dynamix.wireguard.plg');
|
||||
$started = $var['fsState']=='Started';
|
||||
$sleep = isset($display['sleep']);
|
||||
$cache_pool = $var['cacheSbNumDisks'];
|
||||
$array_size = $array_used = 0;
|
||||
$cache_size = $cache_used = 0;
|
||||
$extra_size = $extra_used = 0;
|
||||
$cache_type = 'disk';
|
||||
$cache_size = $cache_used = [];
|
||||
$cache_type = $cache_pool = [];
|
||||
$cache_percent = [];
|
||||
|
||||
$parity = $var['mdResync'];
|
||||
$mover = file_exists('/var/run/mover.pid');
|
||||
$btrfs = exec('pgrep -cf /sbin/btrfs');
|
||||
$dot = $display['number'][0];
|
||||
|
||||
$cache = array_filter($disks,'cache_devices');
|
||||
$pools = array_unique(array_map('prefix',array_keys($cache)));
|
||||
|
||||
foreach ($disks as $disk) {
|
||||
switch ($disk['type']) {
|
||||
@@ -78,10 +85,13 @@ foreach ($disks as $disk) {
|
||||
}
|
||||
break;
|
||||
case 'Cache':
|
||||
if ($disk['name']=='cache') {
|
||||
$cache_size = $disk['fsSize'];
|
||||
$cache_used = $disk['fsSize']-$disk['fsFree'];
|
||||
$cache_type = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme';
|
||||
$name = $disk['name'];
|
||||
if (in_array($name,$pools)) {
|
||||
$cache_size[$name] = $disk['fsSize'];
|
||||
$cache_used[$name] = $disk['fsSize']-$disk['fsFree'];
|
||||
$cache_type[$name] = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme';
|
||||
$cache_pool[$name] = $disk['devicesSb'];
|
||||
$cache_percent[$name] = number_format(100*$cache_used[$name]/($cache_size[$name] ?: 1),1,$dot,'');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -89,9 +99,7 @@ foreach ($disks as $disk) {
|
||||
foreach ($devs as $disk) {
|
||||
$extra_size += $disk['sectors']*$disk['sector_size'];
|
||||
}
|
||||
$dot = $display['number'][0];
|
||||
$array_percent = number_format(100*$array_used/($array_size ?: 1),1,$dot,'');
|
||||
$cache_percent = number_format(100*$cache_used/($cache_size ?: 1),1,$dot,'');
|
||||
|
||||
exec('cat /sys/devices/system/cpu/*/topology/thread_siblings_list|sort -nu', $cpus);
|
||||
$conf = $wireguard ? glob('/etc/wireguard/wg*.conf') : [];
|
||||
@@ -184,9 +192,13 @@ a.cpu_close,span.hand{cursor:pointer}
|
||||
tr.hidden{display:none;height:0;lineheight:0}
|
||||
td.none{text-align:center;padding-top:12px}
|
||||
input[value=Edit]{margin:12px 0 0 0;padding:5px 10px}
|
||||
.sys_view,.mb_view,.cpu_view,.cpu_open,.mem_view,.port_view,.ups_view,.fan_view,.docker_view,.vm_view,.parity_view,.array_view,.cache_view,.my_view,.extra_view{display:none}
|
||||
.sys_view,.mb_view,.cpu_view,.cpu_open,.mem_view,.port_view,.ups_view,.fan_view,.docker_view,.vm_view,.parity_view,.array_view,.my_view,.extra_view{display:none}
|
||||
.share1,.share2,.share3,.view1,.view2,.view3,.user1,.user2,.user3{display:none}
|
||||
#shares_view_on,#users_view_on,#array_view_on,#cache_view_on,#extra_view_on{display:none}
|
||||
#shares_view_on,#users_view_on,#array_view_on,#extra_view_on{display:none}
|
||||
<?foreach ($pools as $pool):?>
|
||||
.<?=$pool?>_view{display:none}
|
||||
#<?=$pool?>_view_on{display:none}
|
||||
<?endforeach;?>
|
||||
form[name=boot]{display:none}
|
||||
.flat{height:0;lineheight:0}
|
||||
.wrap{white-space:normal}
|
||||
@@ -518,16 +530,19 @@ foreach ($users as $user) {
|
||||
<tr id='array_view_on'><td></td><td>_(Device)_</td><td>_(Status)_</td><td>_(Temp)_</td><td>_(SMART)_</td><td>_(Utilization)_</td><td></td></tr>
|
||||
</thead>
|
||||
<tbody sort='<?=$N?>' class='array_view sortable' id='array_list'></tbody>
|
||||
<?if ($cache_pool):?>
|
||||
<thead sort='<?=++$N?>' class='sortable'><tr><td></td><td colspan='5' class='next'>_(Cache)_<?if (!$started):?> (_(stopped)_)<?endif;?><i class='fa fa-fw chevron mt0' id='cache_view' onclick='toggleChevron("cache_view",0)'></i>
|
||||
<?$i=0?>
|
||||
<?foreach ($pools as $pool):?>
|
||||
<?if ($cache_pool[$pool]):?>
|
||||
<thead sort='<?=++$N?>' class='sortable'><tr><td></td><td colspan='5' class='next'><?=ucfirst($pool)?><?if (!$started):?> (_(stopped)_)<?endif;?><i class='fa fa-fw chevron mt0' id='<?=$pool?>_view' onclick='toggleChevron("<?=$pool?>_view",0)'></i>
|
||||
<a href='/Dashboard/Device?name=cache' title='_(Go to cache settings)_'><i class='fa fa-fw fa-cog chevron mt0'></i></a>
|
||||
<?if ($started):?><span class='info'><?=sprintf(_('%s used of %s (%s %%)'),my_scale($cache_used*1024,$unit)." $unit",my_scale($cache_size*1024,$unit,-1,-1)." $unit",$cache_percent)?></span><?endif;?>
|
||||
<?if ($started):?><span class='info'><?=sprintf(_('%s used of %s (%s %%)'),my_scale($cache_used[$pool]*1024,$unit)." $unit",my_scale($cache_size[$pool]*1024,$unit,-1,-1)." $unit",$cache_percent[$pool])?></span><?endif;?>
|
||||
</td><td></td></tr>
|
||||
<tr class='my_view'><td></td><td id='cache_info' colspan='5'></td><td></td></tr>
|
||||
<tr id='cache_view_on'><td></td><td>_(Device)_</td><td>_(Status)_</td><td>_(Temp)_</td><td>_(SMART)_</td><td>_(Utilization)_</td><td></td></tr>
|
||||
<tr class='my_view'><td></td><td id='cache_info<?=$i?>' colspan='5'></td><td></td></tr>
|
||||
<tr id='<?=$pool?>_view_on'><td></td><td>_(Device)_</td><td>_(Status)_</td><td>_(Temp)_</td><td>_(SMART)_</td><td>_(Utilization)_</td><td></td></tr>
|
||||
</thead>
|
||||
<tbody sort='<?=$N?>' class='cache_view sortable' id='cache_list'></tbody>
|
||||
<tbody sort='<?=$N?>' class='<?=$pool?>_view sortable' id='cache_list<?=$i++?>'></tbody>
|
||||
<?endif;?>
|
||||
<?endforeach;?>
|
||||
<?if ($devs):?>
|
||||
<thead sort='<?=++$N?>' class='sortable'><tr><td></td><td colspan='5' class='next'>_(Unassigned)_<i class='fa fa-fw chevron mt0' id='extra_view' onclick='toggleChevron("extra_view",0)'></i><span class='info'></span></td><td></td></tr>
|
||||
<tr class='my_view'><td></td><td id='extra_info' colspan='5'></td><td></td></tr>
|
||||
@@ -758,12 +773,15 @@ function update30() {
|
||||
$('#array_info').html(info);
|
||||
smartMenu('#array_list');
|
||||
$.post('<?=$url?>',{cmd:'cache',path:'<?=$path?>',hot:'<?=$display['hot']?>',max:'<?=$display['max']?>',unit:'<?=$display['unit']?>',text:<?=$display['text']?>,critical:'<?=$display['critical']?>',warning:'<?=$display['warning']?>'},function(d) {
|
||||
var data = d.split('\0');
|
||||
var info = moreInfo(data,'_(Cache)_');
|
||||
$('#cache_list').html(data[0]);
|
||||
$('#cache_info').parent().css('display',info?'':'none');
|
||||
$('#cache_info').html(info);
|
||||
smartMenu('#cache_list');
|
||||
var text = d.split('\r');
|
||||
for (var i=0,t; t=text[i]; i++) {
|
||||
var data = t.split('\0');
|
||||
var info = moreInfo(data,'_(Cache)_');
|
||||
$('#cache_list'+i).html(t);
|
||||
$('#cache_info'+i).parent().css('display',info?'':'none');
|
||||
$('#cache_info'+i).html(info);
|
||||
smartMenu('#cache_list'+i);
|
||||
}
|
||||
<?if ($devs):?>
|
||||
$.post('<?=$url?>',{cmd:'extra',path:'<?=$path?>',hot:'<?=$display['hot']?>',max:'<?=$display['max']?>',unit:'<?=$display['unit']?>',text:<?=$display['text']?>,critical:'<?=$display['critical']?>',warning:'<?=$display['warning']?>'},function(d) {
|
||||
var data = d.split('\0');
|
||||
@@ -865,7 +883,9 @@ function toggleView(field,init,view) {
|
||||
case 'shares_view':
|
||||
if (unset) visible = $('.share').is(':visible');
|
||||
case 'array_view':
|
||||
case 'cache_view':
|
||||
<?foreach ($pools as $pool):?>
|
||||
case '<?=$pool?>_view':
|
||||
<?endforeach;?>
|
||||
case 'extra_view':
|
||||
var on = $('#'+field+'_on');
|
||||
var off = $('#'+field+'_off');
|
||||
@@ -1051,9 +1071,9 @@ $(function() {
|
||||
<?endif;?>
|
||||
toggleView('parity_view',true);
|
||||
toggleView('array_view',true);
|
||||
<?if ($cache_pool):?>
|
||||
toggleView('cache_view',true);
|
||||
<?endif;?>
|
||||
<?foreach ($pools as $pool):?>
|
||||
toggleView('<?=$pool?>_view',true);
|
||||
<?endforeach;?>
|
||||
<?if ($devs):?>
|
||||
toggleView('extra_view',true);
|
||||
<?endif;?>
|
||||
|
||||
@@ -36,9 +36,15 @@ function my_clock($time) {
|
||||
function parity_disks($disk) {
|
||||
return $disk['type']=='Parity';
|
||||
}
|
||||
function cache_disks($disk) {
|
||||
return $disk['type']=='Cache';
|
||||
}
|
||||
function active_disks($disk) {
|
||||
return substr($disk['status'],0,7)!='DISK_NP' && in_array($disk['type'],['Parity','Data','Cache']);
|
||||
}
|
||||
function prefix($key) {
|
||||
return preg_replace('/[0-9]+$/','',$key);
|
||||
}
|
||||
function find_day($D) {
|
||||
global $days;
|
||||
if ($days[0] == '*') return $D;
|
||||
@@ -217,9 +223,9 @@ function device_usage(&$disk, $array, &$full, &$high) {
|
||||
return $text%10==0 ? "-" : "<span class='load'>-</span><div class='usage-disk sys none'><span></span></div>";
|
||||
}
|
||||
}
|
||||
function array_group($type) {
|
||||
function array_group($type,$pool=false) {
|
||||
global $disks,$error,$warning,$red,$orange,$fail,$smart,$full,$high;
|
||||
foreach ($disks as $disk) if ($disk['type']==$type && strpos($disk['status'],'DISK_NP')===false) {
|
||||
foreach ($disks as $disk) if ($disk['type']==$type && strpos($disk['status'],'DISK_NP')===false && ($pool==false||$pool==prefix($disk['name']))) {
|
||||
echo "<tr><td></td>";
|
||||
echo "<td>".device_name($disk,true)."</td>";
|
||||
echo "<td>".device_status($disk,true,$error,$warning)."</td>";
|
||||
@@ -266,8 +272,14 @@ case 'cache':
|
||||
require_once "$docroot/webGui/include/CustomMerge.php";
|
||||
require_once "$docroot/webGui/include/Preselect.php";
|
||||
$error = $warning = $red = $orange = $fail = $smart = $full = $high = 0;
|
||||
array_group('Cache');
|
||||
echo "\0".($error+$warning)."\0".($red+$orange)."\0".($fail+$smart)."\0".($full+$high);
|
||||
$cache = array_filter($disks,'cache_disks');
|
||||
$pools = array_unique(array_map('prefix',array_keys($cache)));
|
||||
foreach ($pools as $pool) {
|
||||
if ($cache[$pool]['devicesSb']) {
|
||||
array_group('Cache',$pool);
|
||||
echo "\0".($error+$warning)."\0".($red+$orange)."\0".($fail+$smart)."\0".($full+$high)."\r";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'extra':
|
||||
$path = $_POST['path'];
|
||||
|
||||
@@ -408,7 +408,7 @@ case 'cache':
|
||||
} else {
|
||||
if ($cache[$pool]['devicesSb']) {
|
||||
foreach ($cache as $disk) if (prefix($disk['name'])==$pool) array_online($disk);
|
||||
if ($display['total'] && $var['cacheSbNumDisks']>1) show_totals(sprintf(_('Pool of %s devices'),my_word($cache[$pool]['devicesSb'])),false);
|
||||
if ($display['total'] && $cache[$pool]['devicesSb']) show_totals(sprintf(_('Pool of %s devices'),my_word($cache[$pool]['devicesSb'])),false);
|
||||
echo "\0";
|
||||
}
|
||||
@unlink($tmp);
|
||||
|
||||
Reference in New Issue
Block a user