Merge pull request #1273 from bergware/master

Dashboard: show ZFS indicator based on arcstats presence
This commit is contained in:
tom mortensen
2023-02-24 13:35:51 -08:00
committed by GitHub
4 changed files with 17 additions and 16 deletions
+1 -2
View File
@@ -69,7 +69,7 @@ $parity = $var['mdResync'];
$mover = file_exists('/var/run/mover.pid');
$btrfs = exec('pgrep -cf /sbin/btrfs');
$dot = $display['number'][0];
$zfs = false;
$zfs = file_exists('/proc/spl/kstat/zfs/arcstats');
foreach ($disks as $disk) {
switch ($disk['type']) {
@@ -87,7 +87,6 @@ foreach ($disks as $disk) {
$cache_type[$name] = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme';
$cache_rate[$name] = number_format(100*$cache_used[$name]/($cache_size[$name] ?: 1),1,$dot,'');
if (!$disks[$name]['devices']) unset($pools[array_search($name,$pools)]);
if (isset($disks[$name]['fsType']) && strpos($disks[$name]['fsType'],'zfs')!==false) $zfs = true;
}
break;
}
+7 -5
View File
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, 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,
@@ -11,9 +11,11 @@
*/
?>
<?
write_log("Saving file $file");
exec("mkdir -p ".escapeshellarg(dirname($file)));
file_put_contents($file, str_replace(["\r\n","\r"], "\n", $_POST['text']));
if ($file) {
write_log("Saving file $file");
exec("mkdir -p ".escapeshellarg(dirname($file)));
file_put_contents($file, str_replace(["\r\n","\r"], "\n", $_POST['text']));
}
// discard settings
$save = false;
?>
+1 -1
View File
@@ -23,7 +23,7 @@ while (true) {
exec("sensors -uA 2>/dev/null|grep -Po 'fan\d_input: \K\d+'",$rpms);
[$total,$free] = $memory;
$used = $total-$free;
$zfs = (exec("awk '/^size/{print \$3}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0)/1024;
$zfs = (exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0)/1024;
$info = max(round(100*(1-$free/$total)),0)."%\0".round(100*$zfs/$used)."%\0".implode("\0",$sys);
$rpms = count($rpms) ? implode(" RPM\0",$rpms).' RPM' : '';
+8 -8
View File
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, 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,
@@ -44,12 +44,12 @@ $docroot = $_SERVER['DOCUMENT_ROOT'];
if (isset($_POST['#file'])) {
$file = $_POST['#file'];
// prepend with boot (flash) if path is relative
if ($file[0]!='/') $file = "/boot/config/plugins/$file";
$section = isset($_POST['#section']) ? $_POST['#section'] : false;
if ($file && $file[0]!='/') $file = "/boot/config/plugins/$file";
$section = $_POST['#section'] ?? false;
$cleanup = isset($_POST['#cleanup']);
$default = isset($_POST['#default']) ? @parse_ini_file("$docroot/plugins/".basename(dirname($file))."/default.cfg", $section) : array();
$default = ($file && isset($_POST['#default'])) ? @parse_ini_file("$docroot/plugins/".basename(dirname($file))."/default.cfg", $section) : [];
$keys = @parse_ini_file($file, $section);
$keys = @parse_ini_file($file, $section) ?: [];
// the 'save' switch can be reset by the include file to disallow settings saving
$save = true;
if (isset($_POST['#include'])) {
@@ -62,13 +62,13 @@ if (isset($_POST['#file'])) {
if ($save) {
$text = "";
if ($section) {
foreach ($_POST as $key => $value) if ($key[0]!='#') $keys[$section][$key] = isset($default[$section][$key]) ? $default[$section][$key] : $value;
foreach ($_POST as $key => $value) if ($key[0]!='#') $keys[$section][$key] = $default[$section][$key] ?? $value;
foreach ($keys as $section => $block) {
$text .= "[$section]\n";
foreach ($block as $key => $value) if (strlen($value) || !$cleanup) $text .= "$key=\"$value\"\n";
}
} else {
foreach ($_POST as $key => $value) if ($key[0]!='#') $keys[$key] = isset($default[$key]) ? $default[$key] : $value;
foreach ($_POST as $key => $value) if ($key[0]!='#') $keys[$key] = $default[$key] ?? $value;
foreach ($keys as $key => $value) if (strlen($value) || !$cleanup) $text .= "$key=\"$value\"\n";
}
@mkdir(dirname($file));