Menu="Dashboard"
Title="Statistics"
---
exec('cat /sys/devices/system/cpu/*/topology/thread_siblings_list|sort -nu', $cpus);
$fans = exec("sensors -uA 2>/dev/null|grep -c 'fan[0-9]_input'");
$group = $var['shareSMBEnabled']=='yes' | $var['shareAFPEnabled']=='yes' | $var['shareNFSEnabled']=='yes';
$names = "";
$url = "/webGui/include/DashUpdate.php";
foreach ($shares as $share) {
if ($names) $names .= ',';
$names .= $share['name'];
}
$total = exec("awk '/^MemTotal/{print $2*1024/1.048576}' /proc/meminfo");
exec("ls /sys/class/net|grep -Po '^(lo|(bond|eth)\d+)$'",$ports);
$memory_installed = exec("dmidecode -t 17 | awk -F: '/^\tSize: [0-9]+ MB$/{t+=$2} /^\tSize: [0-9]+ GB$/{t+=$2*1024} END{print t}'")/1024;
$memory_maximum = exec("dmidecode -t 16 | awk -F: '/^\tMaximum Capacity: [0-9]+ GB$/{t+=$2} END{print t}'");
// If maximum < installed then roundup maximum to the next power of 2 size of installed. E.g. 6 -> 8 or 12 -> 16
if ($memory_maximum < $memory_installed) $memory_maximum = pow(2,ceil(log($memory_installed)/log(2)));
function init_row($label) {
echo "
| $label | ".str_repeat(" | ",30)."
";
}
function parity_status() {
global $var,$disks;
$parity_num_slots = 0;
$parity_disabled = [];
$parity_invalid = [];
foreach ($disks as $disk) {
if ($disk['type']=='Parity') {
$parity_num_slots++;
if (strpos($disk['status'],"DISK_NP")===0) {
$parity_disabled[] = trim('Parity ' . filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT));
}
if (strpos($disk['status'],"DISK_INVALID")===0) {
$parity_invalid[] = trim('Parity ' . filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT));
}
}
}
if ($parity_num_slots == count($parity_disabled)) {
echo "| Parity disk".($parity_num_slots>1?'s':'')." not present | |
";
return;
}
if ($parity_num_slots > count($parity_invalid)) {
if (count($parity_invalid)==0) {
echo "| Parity is valid |
";
} else {
echo "| Degraded parity: ".implode(' and ',$parity_invalid)." ".(count($parity_invalid)>1?'are':'is')." invalid |
";
}
if ($var['sbSyncExit']!=0) {
echo "Last check incomplete on ".my_time($var['sbSynced2']).day_count($var['sbSynced2']).", finding {$var['sbSyncErrs']} error".($var['sbSyncErrs']==1?'.':'s.');
echo " Error code: ".my_error($var['sbSyncExit'])." | |
";
return;
}
if ($var['sbSynced']==0) {
echo "| Parity has not been checked yet. | |
";
return;
}
if ($var['sbSynced2']==0) {
$idle = $var['mdResync']==0;
list($entry,$duration,$speed,$status,$error) = explode('|', read_parity_log($var['sbSynced'],!$idle));
if ($status==0) {
echo "".($idle ? "Last checked on " : "Activity started on ")."".my_time($var['sbSynced']).day_count($var['sbSynced']).", finding $error error".($error==1?'.':'s.');
echo " ".($idle ? "Duration: " : "Last result: ").my_check($duration,$speed)." | |
";
} else {
echo "Last check incomplete on ".my_time($var['sbSynced']).day_count($var['sbSynced']).", finding $error error".($error==1?'.':'s.');
echo " Error code: $status | |
";
}
} else {
$status = 0;
$duration = $var['sbSynced2']-$var['sbSynced'];
$speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';
echo "Last checked on ".my_time($var['sbSynced2']).day_count($var['sbSynced2']).", finding {$var['sbSyncErrs']} error".($var['sbSyncErrs']==1?'.':'s.');
echo " Duration: ".my_check($duration,$speed)." | |
";
}
} else {
if (empty($var['mdInvalidDisk'])) {
echo "| Parity is invalid |
";
} else {
echo "| Data is invalid |
";
}
}
}
function truncate($string,$len) {
return strlen($string) < $len ? $string : substr($string,0,$len-3).'...';
}
function export_settings($protocol,$share) {
if ($protocol!='yes' || $share['export']=='-') return "-";
if ($share['export']=='e') return ucfirst($share['security']);
return ''.ucfirst($share['security']).'';
}
function active_disks($disk) {
return substr($disk['status'],0,7)!='DISK_NP' && preg_match('/^(Parity|Data|Cache)$/',$disk['type']);
}
$disks = array_filter($disks,'active_disks');
$slots = count($disks) + count($devs);
?>
$row0 = array_fill(0,30,"| - | "); $i = 0;
foreach ($disks as $disk) if ($disk['type']=='Parity') $row0[$i++] = "Parity ".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)." | ";
foreach ($disks as $disk) if ($disk['type']=='Data') $row0[$i++] = "Disk ".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)." | ";
if ($slots <= 30) {
foreach ($disks as $disk) if ($disk['type']=='Cache') $row0[$i++] = "Cache ".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)." | ";
foreach ($devs as $dev) $row0[$i++] = "{$dev['device']} | ";
}
echo "Array Status | ".implode('',$row0);
?>
30):?>
$row0 = array_fill(0,30,"| - | "); $i = 0;
foreach ($disks as $disk) if ($disk['type']=='Cache') $row0[$i++] = "Cache ".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)." | ";
foreach ($devs as $dev) $row0[$i++] = "{$dev['device']} | ";
echo "Array Status | ".implode('',$row0);
?>
| Parity Status |
=parity_status()?>
| System Status |
|
| Load Statistics |
| Avg. CPU load |
|
1):?> |
| Per CPU load * |
$tr = false;
foreach ($cpus as $pair):
list($cpu1, $cpu2) = preg_split('/[,-]/',$pair);
if ($tr) echo "
";
if (isset($cpu2))
echo "| cpu $cpu1 / $cpu2 |
|
| ";
else
echo "cpu $cpu1 |
| ";
echo "
";
$tr = true;
endforeach;
?>
$text = '';
foreach ($cpus as $pair):
list($cpu1, $cpu2) = preg_split('/[,-]/',$pair);
if ($text) $text .= ", ";
$text .= isset($cpu2) ? "[$cpu1/$cpu2]" : $cpu1;
endforeach;
?>
| Per CPU load * | =$text?> |
if ($fans>0):
echo $fans>2 ? "| " : " |
| ";
echo "FAN speed | ";
for ($f=0; $f<$fans; $f+=2):
if ($f) echo "
";
if ($f+1<$fans)
echo "| fan ".($f)." / ".($f+1)." | "." | | ";
else
echo "fan ".($f)." | ";
echo " |
";
endfor;
endif;
$dck = exec("df /var/lib/docker|grep -om1 '^/'");
?>
| Memory usage |
|
| flash log docker |
|
|
Not available |
| Memory size | allocated | =my_scale($total,$unit,3)." $unit"?> |
| installed | ="$memory_installed GB (max. capacity $memory_maximum GB)"?> |
1):?> |
| Network * |
$c = 0;
foreach ($ports as $port):
if ($c) echo "
";
echo "| $port | |
";
endforeach;
?>
| Network * | Interface | Receive pkts | Transmit pkts |
$c = 0;
foreach ($ports as $port):
echo "| $port | | |
";
$c += 2;
endforeach;
?>
| Network * | Interface | Receive | Transmit |
$c = 0;
foreach ($ports as $port):
echo "| $port | | |
";
$c += 2;
endforeach;
?>
$text = '';
foreach ($ports as $port):
if ($text) $text .= ", ";
$text .= $port;
endforeach;
?>
| Network * | =$text?> |
| Users List |
| Name | Description | Write | Read |
foreach ($users as $user):
$list = truncate($user['name'],12);
$desc = truncate($user['desc'],28);
if ($list=='root'):
$write = '-'; $read = '-';
else:
$write = 0; $read = 0;
foreach ($shares as $share):
if (strpos($sec[$share['name']]['writeList'],$list)!==false) $write++;
if (strpos($sec[$share['name']]['readList'],$list)!==false) $read++;
endforeach;
endif;
echo "| $list | $desc | $write | $read |
";
endforeach;
?>
style='display:none'>
foreach ($users as $user):
$list = truncate($user['name'],12);
$desc = truncate($user['desc'],28);
if ($list=='root'):
$write = '-'; $read = '-';
else:
$write = 0; $read = 0;
foreach ($shares as $share):
if (strpos($sec_afp[$share['name']]['writeList'],$list)!==false) $write++;
if (strpos($sec_afp[$share['name']]['readList'],$list)!==false) $read++;
endforeach;
endif;
echo "| $list | $desc | $write | $read |
";
endforeach;
?>
style='display:none'>
foreach ($users as $user):
$list = truncate($user['name'],12);
$desc = truncate($user['desc'],28);
$write = '-'; $read = '-';
echo "| $list | $desc | $write | $read |
";
endforeach;
?>
foreach ($users as $user):
$list = truncate($user['name'],12);
$desc = truncate($user['desc'],28);
echo "| $list | $desc | - | - |
";
endforeach;
?>
| Shares List |
|
| Name | Description | Security | Streams |
$i = 0;
foreach ($shares as $name => $share):
$i++;
$list = truncate($name,12);
$comment = truncate($share['comment'],28);
$security = export_settings($var['shareSMBEnabled'], $sec[$name]);
echo "| $list | $comment | $security | 0 |
";
endforeach;
if (!count($shares)) echo "| No shares present |
";
?>
style='display:none'>
foreach ($shares as $name => $share):
$list = truncate($name,12);
$comment = truncate($share['comment'],28);
$security = export_settings($var['shareAFPEnabled'], $sec_afp[$name]);
echo "| $list | $comment | $security | - |
";
endforeach;
if (!count($shares)) echo "| No shares present |
";
?>
style='display:none'>
foreach ($shares as $name => $share):
$list = truncate($name,12);
$comment = truncate($share['comment'],28);
$security = export_settings($var['shareNFSEnabled'], $sec_nfs[$name]);
echo "| $list | $comment | $security | - |
";
endforeach;
if (!count($shares)) echo "| No shares present |
";
?>
foreach ($shares as $name => $share):
$list = truncate($name,12);
$comment = truncate($share['comment'],28);
echo "| $list | $comment | - | - |
";
endforeach;
if (!count($shares)) echo "| No shares present |
";
?>