mirror of
https://github.com/unraid/webgui.git
synced 2026-05-03 16:29:45 -05:00
Introduce new disk setting "Default SSD offset temperature"
- add celsius / fahrenheit conversion routines
This commit is contained in:
@@ -941,6 +941,12 @@ A value of zero will disable the warning threshold (including notifications).
|
||||
A value of zero will disable the critical threshold (including notifications).
|
||||
:end
|
||||
|
||||
:ssd_default_disk_offset_temperature_help:
|
||||
*SSD offset temperature* adds the given number of degrees to the default warning and critical thresholds for SSD devices.
|
||||
|
||||
Usually SSD devices can tolerate higher temperature thresholds than regular HDD devices.
|
||||
:end
|
||||
|
||||
:disk_default_smart_notification_help:
|
||||
SMART notifications are generated on either an increasing RAW value of the attribute, or a decreasing NORMALIZED value which reaches a predefined threshold set by the manufacturer.
|
||||
|
||||
|
||||
@@ -26,14 +26,6 @@ $events = explode('|',$disk['smEvents'] ?? $var['smEvents'] ?? $numbers);
|
||||
$mode = ['Disabled','Hourly','Daily','Weekly','Monthly'];
|
||||
$days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
|
||||
|
||||
function setTemp(&$disk, $zone) {
|
||||
global $display;
|
||||
switch ($zone) {
|
||||
case 'hot': $nvme = 'wctemp'; break;
|
||||
case 'max': $nvme = 'cctemp'; break;
|
||||
}
|
||||
return _var($disk,'transport')=='nvme' ? get_nvme_info(_var($disk,'device'),$nvme) : (_var($disk,'rotational',1)==0 && $display[$zone]>0 ? $display[$zone]+$display['ssd'] : $display[$zone]);
|
||||
}
|
||||
function sanitize(&$val) {
|
||||
$data = explode('.',str_replace([' ',','],['','.'],$val));
|
||||
$last = array_pop($data);
|
||||
@@ -79,9 +71,13 @@ function makeList($list) {
|
||||
function sharename($share) {
|
||||
return basename($share,'.cfg');
|
||||
}
|
||||
function displayTemp($temp) {
|
||||
function makeTemp(&$disk, $zone) {
|
||||
global $display;
|
||||
return (_var($display,'unit')=='F' && is_numeric($temp)) ? round($temp*9/5)+32 : $temp;
|
||||
switch ($zone) {
|
||||
case 'hot': $nvme = 'wctemp'; break;
|
||||
case 'max': $nvme = 'cctemp'; break;
|
||||
}
|
||||
return _var($disk,'transport')=='nvme' ? get_nvme_info(_var($disk,'device'),$nvme) : (_var($disk,'rotational',1)==0 && $display[$zone]>0 ? $display[$zone]+$display['ssd'] : $display[$zone]);
|
||||
}
|
||||
function maintenance_mode() {
|
||||
global $var;
|
||||
@@ -109,6 +105,8 @@ $text = isPool($name) ? _('This will ERASE content of ALL devices in the pool')
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/plugins/dynamix.docker.manager/styles/style-$theme.css")?>">
|
||||
|
||||
<script>
|
||||
String.prototype.celsius = function(){return Math.round((parseInt(this)-32)*5/9).toString();}
|
||||
|
||||
if ($.cookie('deletepool')) {
|
||||
$.removeCookie('deletepool');
|
||||
done();
|
||||
@@ -292,8 +290,8 @@ function prepareDeviceInfo(form) {
|
||||
if (form.smEvents.value == '<?=$numbers?>') form.smEvents.value = '';
|
||||
if (form.smLevel.value == 1.00) form.smLevel.value = '';
|
||||
<?if (_var($display,'unit')=='F'):?>
|
||||
if (form.hotTemp.value>0) form.hotTemp.value = Math.round((form.hotTemp.value-32)*5/9);
|
||||
if (form.maxTemp.value>0) form.maxTemp.value = Math.round((form.maxTemp.value-32)*5/9);
|
||||
if (form.hotTemp.value>0) form.hotTemp.value = form.hotTemp.value.celsius();
|
||||
if (form.maxTemp.value>0) form.maxTemp.value = form.maxTemp.value.celsius();
|
||||
<?endif;?>
|
||||
}
|
||||
function setGlue(form,reset) {
|
||||
@@ -1183,12 +1181,12 @@ _(xfs_repair status)_:
|
||||
<input type="hidden" name="smEvents" value="">
|
||||
<input type="hidden" name="smGlue" value="<?=_var($var,'smGlue')?>">
|
||||
_(Warning disk temperature threshold)_ (°<?=_var($display,'unit','C')?>):
|
||||
: <input type="number" min="0" max="300" name="hotTemp" class="narrow" value="<?=displayTemp(_var($disk,'hotTemp'))?>" placeholder="<?=displayTemp(setTemp($disk,'hot'))?>">
|
||||
: <input type="number" min="0" max="300" name="hotTemp" class="narrow" value="<?=displayTemp(_var($disk,'hotTemp'))?>" placeholder="<?=displayTemp(makeTemp($disk,'hot'))?>">
|
||||
|
||||
:info_warning_temp_help:
|
||||
|
||||
_(Critical disk temperature threshold)_ (°<?=_var($display,'unit','C')?>):
|
||||
: <input type="number" min="0" max="300" name="maxTemp" class="narrow" value="<?=displayTemp(_var($disk,'maxTemp'))?>" placeholder="<?=displayTemp(setTemp($disk,'max'))?>">
|
||||
: <input type="number" min="0" max="300" name="maxTemp" class="narrow" value="<?=displayTemp(_var($disk,'maxTemp'))?>" placeholder="<?=displayTemp(makeTemp($disk,'max'))?>">
|
||||
|
||||
:info_critical_temp_help:
|
||||
|
||||
|
||||
@@ -24,21 +24,19 @@ $reply = '/var/tmp/luks.reply';
|
||||
$keyfile = is_file($var['luksKeyfile']);
|
||||
$encrypt = false;
|
||||
foreach ($disks as $disk) if (isset($disk['fsType']) && strncmp($disk['fsType'],'luks:',5)===0) $encrypt = true;
|
||||
|
||||
function displayTemp($temp) {
|
||||
global $display;
|
||||
return (is_numeric($temp) && _var($display,'unit')=='F') ? round(9/5*$temp)+32 : $temp;
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
String.prototype.celsius = function(){return Math.round((parseInt(this)-32)*5/9).toString();}
|
||||
|
||||
function base64(str) {
|
||||
return window.btoa(unescape(encodeURIComponent(str)));
|
||||
}
|
||||
function doDispatch(form) {
|
||||
var fields = {};
|
||||
<?if (_var($display,'unit')=='F'):?>
|
||||
form.display_hot.value = Math.round((form.display_hot.value-32)*5/9);
|
||||
form.display_max.value = Math.round((form.display_max.value-32)*5/9);
|
||||
<?if ($display['unit']=='F'):?>
|
||||
form.display_hot.value = form.display_hot.value.celsius();
|
||||
form.display_max.value = form.display_max.value.celsius();
|
||||
form.display_ssd.value = form.display_ssd.value.celsius();
|
||||
<?endif;?>
|
||||
fields['#cfg'] = "/boot/config/plugins/dynamix/dynamix.cfg";
|
||||
fields['#cleanup'] = true;
|
||||
@@ -246,6 +244,11 @@ _(Default critical disk temperature threshold)_ (°<?=_var($display,'unit','C
|
||||
|
||||
:disk_default_critical_temperature_help:
|
||||
|
||||
_(Default SSD offset temperature)_ (°<?=_var($display,'unit','C')?>):
|
||||
: <input type="number" min="0" max="300" name="display_ssd" class="narrow" value="<?=displayTemp($display['ssd'])?>" placeholder="<?=displayTemp($default['display']['ssd'])?>">
|
||||
|
||||
:ssd_default_disk_offset_temperature_help:
|
||||
|
||||
|
||||
: <input type="submit" name="changeDisk" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</form>
|
||||
|
||||
@@ -51,7 +51,7 @@ function my_temp($value) {
|
||||
global $display;
|
||||
$unit = _var($display,'unit','C');
|
||||
$number = _var($display,'number','.,');
|
||||
return is_numeric($value) ? (($unit=='F' ? round(9/5*$value+32) : str_replace('.', $number[0], $value))." $unit") : $value;
|
||||
return is_numeric($value) ? (($unit=='F' ? fahrenheit($value) : str_replace('.', $number[0], $value))." $unit") : $value;
|
||||
}
|
||||
function my_disk($name, $raw=false) {
|
||||
global $display;
|
||||
|
||||
@@ -59,6 +59,16 @@ function plugin_update_available($plugin, $os=false) {
|
||||
function _var(&$name, $key=null, $default='') {
|
||||
return is_null($key) ? ($name ?? $default) : ($name[$key] ?? $default);
|
||||
}
|
||||
function celsius($temp) {
|
||||
return round(($temp-32)*5/9);
|
||||
}
|
||||
function fahrenheit($temp) {
|
||||
return round(9/5*$temp)+32;
|
||||
}
|
||||
function displayTemp($temp) {
|
||||
global $display;
|
||||
return (is_numeric($temp) && _var($display,'unit')=='F') ? fahrenheit($temp) : $temp;
|
||||
}
|
||||
function get_value(&$name, $key, $default) {
|
||||
global $var;
|
||||
$value = $name[$key] ?? -1;
|
||||
|
||||
@@ -120,9 +120,6 @@ function normalize($type,$count) {
|
||||
foreach ($words as &$word) $word = $word==strtoupper($word) ? $word : preg_replace(['/^(ct|cnt)$/','/^blk$/'],['count','block'],strtolower($word));
|
||||
return ucfirst(implode(' ',$words)).": ".str_replace('_',' ',strtolower($count))."\n";
|
||||
}
|
||||
function my_unit($value,$unit) {
|
||||
return ($unit=='F' ? round(9/5*$value+32) : $value)." $unit";
|
||||
}
|
||||
function active_disks($disk) {
|
||||
return substr(_var($disk,'status'),0,7)!='DISK_NP' && in_array(_var($disk,'type'),['Parity','Data']);
|
||||
}
|
||||
@@ -169,7 +166,7 @@ function device_temp(&$disk, &$red, &$orange) {
|
||||
} elseif (exceed($temp,$hot,$top)) {
|
||||
$heat = 'fire'; $color = 'orange'; $orange++;
|
||||
}
|
||||
return ($spin && $temp>0) ? "<span class='$color-text'>".my_unit($temp,_var($display,'unit','C'))."</span>".($heat ? "<i class='fa fa-$heat $color-text heat'></i>" : "") : "*";
|
||||
return ($spin && $temp>0) ? "<span class='$color-text'>".my_temp($temp)."</span>".($heat ? "<i class='fa fa-$heat $color-text heat'></i>" : "") : "*";
|
||||
}
|
||||
function device_smart(&$disk, &$fail, &$smart) {
|
||||
global $numbers,$saved;
|
||||
|
||||
@@ -35,7 +35,7 @@ function my_temp($value) {
|
||||
global $display;
|
||||
if ($value=='*') return ' - standby';
|
||||
$unit = _var($display,'unit','C');
|
||||
return ' - active '.($unit=='F' ? round(9/5*$value+32) : str_replace('.',_var($display,'number','.,')[0], $value)).' '.$unit;
|
||||
return ' - active '.($unit=='F' ? fahrenheit($value) : str_replace('.',_var($display,'number','.,')[0], $value)).' '.$unit;
|
||||
}
|
||||
function my_disk($name) {
|
||||
return ucfirst(preg_replace('/(\d+)$/',' $1',$name));
|
||||
|
||||
Reference in New Issue
Block a user