Multi cache pools

This commit is contained in:
bergware
2020-03-20 16:37:48 +01:00
parent ba107a867f
commit 5e06bdbc11
4 changed files with 70 additions and 36 deletions
+16 -4
View File
@@ -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'];
+1 -1
View File
@@ -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);