mirror of
https://github.com/unraid/webgui.git
synced 2026-05-19 20:59:38 -05:00
Merge pull request #725 from bergware/mutli-language
Fixed: monitor may spinup disk
This commit is contained in:
@@ -27,10 +27,10 @@ $DockerStopped = pgrep('dockerd')===false;
|
||||
$realfile = $dockercfg['DOCKER_IMAGE_FILE'];
|
||||
if (file_exists($realfile)) {
|
||||
$realfile = transpose_user_path($realfile);
|
||||
if (exec("stat -c %T -f " . escapeshellarg($realfile)) == "btrfs") {
|
||||
if (shell_exec("lsattr " . escapeshellarg($realfile) . " | grep \"\\-C\"") == "") {
|
||||
echo '<p class="notice">'._('Your existing Docker image file needs to be recreated due to an issue from an earlier beta of Unraid 6').' ';
|
||||
echo _('Failure to do so may result in your docker image suffering corruption at a later time').' ';
|
||||
if (is_file($realfile) && exec("stat -c %T -f ".escapeshellarg($realfile))=="btrfs") {
|
||||
if (shell_exec("lsattr ".escapeshellarg($realfile)."|grep \"\\-C\"")=="") {
|
||||
echo '<p class="notice">'._('Your existing Docker image file needs to be recreated due to an issue from an earlier beta of Unraid 6').'. ';
|
||||
echo _('Failure to do so may result in your docker image suffering corruption at a later time').'. ';
|
||||
echo _('Please do this NOW').'!</p>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,12 +278,13 @@ function read_disk($name, $part) {
|
||||
$port = port_name($name);
|
||||
switch ($part) {
|
||||
case 'color':
|
||||
return exec("hdparm -C ".escapeshellarg("/dev/$port")."|grep -Po 'active|unknown'") ? 'blue-on' : 'blue-blink';
|
||||
return disk_active($port) ? 'blue-on' : 'blue-blink';
|
||||
case 'temp':
|
||||
$smart = "/var/local/emhttp/smart/$name";
|
||||
$type = $var['smType'] ?? '';
|
||||
if (!file_exists($smart) || (time()-filemtime($smart)>=$var['poll_attributes'])) exec("smartctl -n standby -A $type ".escapeshellarg("/dev/$port")." >".escapeshellarg($smart)." &");
|
||||
return exec("awk 'BEGIN{s=t=\"*\"}\$1==190{s=\$10};\$1==194{t=\$10;exit};\$1==\"Temperature:\"{t=\$2;exit};/^Current Drive Temperature:/{t=\$4;exit} END{if(t!=\"*\")print t; else print s}' ".escapeshellarg($smart)." 2>/dev/null");
|
||||
// read and store SMART attributes of unassigned devices, take SMART poll interval and active disk status into consideration
|
||||
if (poll_timer($smart) && disk_active($port)) exec("smartctl -A $type /dev/$port >".escapeshellarg($smart));
|
||||
return read_temp($smart);
|
||||
}
|
||||
}
|
||||
function show_totals($text,$array,$name) {
|
||||
|
||||
@@ -252,4 +252,14 @@ function cpu_list() {
|
||||
exec('cat /sys/devices/system/cpu/*/topology/thread_siblings_list|sort -nu', $cpus);
|
||||
return $cpus;
|
||||
}
|
||||
function poll_timer($file) {
|
||||
global $var;
|
||||
return !file_exists($file) || time()-filemtime($file)>=$var['poll_attributes'];
|
||||
}
|
||||
function disk_active($port) {
|
||||
return exec("hdparm -C /dev/$port|grep -Eom1 'active|unknown'")!='';
|
||||
}
|
||||
function read_temp($smart) {
|
||||
return exec("awk 'BEGIN{s=t=\"*\"}\$1==190{s=\$10};\$1==194{t=\$10;exit};\$1==\"Temperature:\"{t=\$2;exit};/^Current Drive Temperature:/{t=\$4;exit} END{if(t!=\"*\")print t; else print s}' ".escapeshellarg($smart)." 2>/dev/null");
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
// Multi-language support
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
// Multi-language handling
|
||||
if (!function_exists('_')) {
|
||||
function _($text) {return $text;}
|
||||
}
|
||||
@@ -21,7 +23,6 @@ $var = parse_ini_file("/var/local/emhttp/var.ini");
|
||||
$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/Helpers.php";
|
||||
require_once "$docroot/webGui/include/Preselect.php";
|
||||
require_once "$docroot/webGui/include/CustomMerge.php";
|
||||
@@ -39,7 +40,6 @@ $pools = pools_filter($disks);
|
||||
$errors = [];
|
||||
$top = 120;
|
||||
|
||||
|
||||
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));
|
||||
@@ -133,7 +133,8 @@ function check_smart($name,$port,$text,$info) {
|
||||
}
|
||||
}
|
||||
$file .= '.ssa';
|
||||
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));
|
||||
// read and store SMART status (PASSED/FAILED) of all devices, take SMART poll interval and active disk status into consideration
|
||||
if (poll_timer($file) && disk_active($port)) exec("smartctl -H $type /dev/$port|grep -Pom1 '^SMART.*: \K[A-Z]+'|tr -d '\n' >".escapeshellarg($file)." &");
|
||||
}
|
||||
function check_usage($name,$used,$text,$info) {
|
||||
global $notify,$disks,$saved,$display,$server;
|
||||
@@ -228,8 +229,9 @@ foreach ($devs as $dev) {
|
||||
$smart = "/var/local/emhttp/smart/$name";
|
||||
$type = $var['smType'] ?? '';
|
||||
$port = port_name($name);
|
||||
if (!file_exists($smart) || (time()-filectime($smart)>$var['poll_attributes'])) exec("smartctl -n standby -A $type ".escapeshellarg("/dev/$port")." >".escapeshellarg($smart));
|
||||
$temp = exec("awk 'BEGIN{s=t=\"*\"}\$1==190{s=\$10};\$1==194{t=\$10;exit};\$1==\"Temperature:\"{t=\$2;exit};/^Current Drive Temperature:/{t=\$4;exit} END{if(t!=\"*\")print t; else print s}' ".escapeshellarg($smart)." 2>/dev/null");
|
||||
// read and store SMART attributes of unassigned devices, take SMART poll interval and active disk status into consideration
|
||||
if (poll_timer($smart) && disk_active($port)) exec("smartctl -A $type /dev/$port >".escapeshellarg($smart));
|
||||
$temp = read_temp($smart);
|
||||
$text = "device $name";
|
||||
$info = !empty($dev['id']) ? "{$dev['id']} ($name)": "No device identification ($name)";
|
||||
// process disk temperature notifications
|
||||
|
||||
Reference in New Issue
Block a user