diff --git a/plugins/dynamix/include/DashUpdate.php b/plugins/dynamix/include/DashUpdate.php index 665323ba5..5132b683f 100644 --- a/plugins/dynamix/include/DashUpdate.php +++ b/plugins/dynamix/include/DashUpdate.php @@ -12,12 +12,8 @@ ?> "); break;} $temp = $disk['temp']; - $hot = $disk['hotTemp'] ?? $_POST['hot']; - $max = $disk['maxTemp'] ?? $_POST['max']; - $heat = $temp>=$max && $max>0 ? 'max' : ($temp>=$hot && $hot>0 ? 'hot' : ''); + $hot = $disk['hotTemp'] ?? $_POST['hot']; + $max = $disk['maxTemp'] ?? $_POST['max']; + $top = $_POST['top'] ?? 120; + $heat = exceed($temp,$max,$top) ? 'max' : (exceed($temp,$hot,$top) ? 'hot' : ''); if ($heat) my_insert($row6[$n],""); else @@ -136,13 +132,14 @@ case 'disk': $devRow = function($n,$disk) use (&$row4,&$row6,&$row7,$path) { $hot = $_POST['hot']; $max = $_POST['max']; + $top = $_POST['top'] ?? 120; $name = $dev['device']; $port = substr($name,-2)!='n1' ? $name : substr($name,0,-2); $smart = "state/smart/$name"; $state = exec("hdparm -C ".escapeshellarg("/dev/$port")."|grep -Po 'active|unknown'") ? 'blue-on' : 'blue-blink'; if ($state=='blue-on') my_smart($row7[$n],$name,'New'); $temp = file_exists($smart) ? exec("awk 'BEGIN{t=\"*\"} \$1==190||\$1==194{t=\$10;exit};\$1==\"Temperature:\"{t=\$2;exit} END{print t}' ".escapeshellarg($smart)) : '*'; - $heat = $temp>=$max && $max>0 ? 'max' : ($temp>=$hot && $hot>0 ? 'hot' : ''); + $heat = exceed($temp,$max,$top) ? 'max' : (exceed($temp,$hot,$top) ? 'hot' : ''); if ($heat) my_insert($row6[$n],""); else diff --git a/plugins/dynamix/include/SmartInfo.php b/plugins/dynamix/include/SmartInfo.php index 3a82e0d28..0c41cbb4c 100644 --- a/plugins/dynamix/include/SmartInfo.php +++ b/plugins/dynamix/include/SmartInfo.php @@ -11,7 +11,11 @@ */ ?> 4'",$output); if (strpos($output[0], 'SMART Attributes Data Structure')===0) { $output = array_slice($output, 3); @@ -69,7 +70,7 @@ case "attributes": $highlight = strpos($info[8],'FAILING_NOW')!==false || ($select ? $info[5]>0 && $info[3]<=$info[5]*$level : $info[9]>0); if (in_array($info[0], $events) && $highlight) $color = " class='warn'"; elseif (in_array($info[0], [190,194])) { - if ($info[9]>=$max && $max>0) $color = " class='alert'"; elseif ($info[9]>=$hot && $hot>0) $color = " class='warn'"; + if (exceed($info[9],$max,$top)) $color = " class='alert'"; elseif (exceed($info[9],$hot,$top)) $color = " class='warn'"; } if ($info[8]=='-') $info[8] = 'Never'; if ($info[0]==9 && is_numeric($info[9])) duration($info[9]); @@ -88,7 +89,7 @@ case "attributes": switch ($name) { case 'Temperature': $temp = strtok($value,' '); - if ($temp>=$max && $max>0) $color = " class='alert'"; elseif ($temp>=$hot && $hot>0) $color = " class='warn'"; + if (exceed($temp,$max)) $color = " class='alert'"; elseif (exceed($temp,$hot)) $color = " class='warn'"; break; case 'Power on hours': if (is_numeric($value)) duration($value); diff --git a/plugins/dynamix/include/Wrappers.php b/plugins/dynamix/include/Wrappers.php index ebd5d8381..498b44060 100644 --- a/plugins/dynamix/include/Wrappers.php +++ b/plugins/dynamix/include/Wrappers.php @@ -21,13 +21,11 @@ function parse_plugin_cfg($plugin, $sections=false) { $cfg = file_exists($ram) ? parse_ini_file($ram, $sections) : []; return file_exists($rom) ? array_replace_recursive($cfg, parse_ini_file($rom, $sections)) : $cfg; } - function parse_cron_cfg($plugin, $job, $text = "") { $cron = "/boot/config/plugins/$plugin/$job.cron"; if ($text) file_put_contents($cron, $text); else @unlink($cron); exec("/usr/local/sbin/update_cron"); } - function agent_fullname($agent, $state) { switch ($state) { case 'enabled' : return "/boot/config/plugins/dynamix/notifications/agents/$agent"; @@ -35,13 +33,11 @@ function agent_fullname($agent, $state) { default : return $agent; } } - function get_plugin_attr($attr, $file) { global $docroot; exec("$docroot/plugins/dynamix.plugin.manager/scripts/plugin ".escapeshellarg($attr)." ".escapeshellarg($file), $result, $error); if ($error===0) return $result[0]; } - function plugin_update_available($plugin, $os=false) { $local = get_plugin_attr('version', "/var/log/plugins/$plugin.plg"); $remote = get_plugin_attr('version', "/tmp/plugins/$plugin.plg"); @@ -52,13 +48,11 @@ function plugin_update_available($plugin, $os=false) { if (version_compare($server, $unraid, '>=')) return $remote; } } - -function get_value(&$object,$name,$default) { +function get_value(&$object, $name, $default) { global $var; $value = $object[$name] ?? -1; return $value!==-1 ? $value : ($var[$name] ?? $default); } - function get_ctlr_options(&$type, &$disk) { if (!$type) return; $ports = []; @@ -70,4 +64,7 @@ function get_ctlr_options(&$type, &$disk) { function port_name($port) { return substr($port,-2)!='n1' ? $port : substr($port,0,-2); } +function exceed($value, $limit, $top=100) { + return ($value>$limit && $limit>0 && $value<=$top); +} ?> diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index 74538402c..9dd891c19 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -30,6 +30,7 @@ $high1 = $unraid['display']['critical']; $high2 = $unraid['display']['warning']; $server = strtoupper($var['NAME']); $errors = []; +$top = 120; function plus($val,$word,$last) { return $val>0 ? (($val||$last) ? ($val.' '.$word.($val!=1?'s':'').($last ?'':', ')) : '') : ''; @@ -90,11 +91,11 @@ function read_write_parity_log($epoch,$duration,$speed,$status,$error) { return str_replace("\n","",$line); } function check_temp($name,$temp,$text,$info) { - global $notify,$disks,$saved,$unraid,$server; + global $notify,$disks,$saved,$unraid,$server,$top; $disk = &$disks[$name]; $hot = $disk['hotTemp'] ?? $unraid['display']['hot']; $max = $disk['maxTemp'] ?? $unraid['display']['max']; - $warn = $temp>=$max && $max>0 ? 'alert' : ($temp>=$hot && $hot>0 ? 'warning' : ''); + $warn = exceed($temp,$max,$top) ? 'alert' : (exceed($temp,$hot,$top) ? 'warning' : ''); $item = 'temp'; $last = $saved[$item][$name] ?? 0; if ($warn) { @@ -103,7 +104,7 @@ function check_temp($name,$temp,$text,$info) { $saved[$item][$name] = $max>0 && $temp<=$max ? $max : $temp; } } else { - if ($last) { + if ($last && $temp<=$top) { exec("$notify -e ".escapeshellarg("unRAID $text message")." -s ".escapeshellarg("Notice [$server] - $text returned to normal temperature")." -d ".escapeshellarg("$info")); unset($saved[$item][$name]); } @@ -171,9 +172,9 @@ function check_usage($name,$used,$text,$info) { global $notify,$disks,$saved,$unraid,$server; if ($used == -1) return; $disk = &$disks[$name]; - $warning = $disk['warning'] ?? $unraid['display']['warning']; + $warning = $disk['warning'] ?? $unraid['display']['warning']; $critical = $disk['critical'] ?? $unraid['display']['critical']; - $warn = $used>=$critical && $critical>0 ? 'alert' : ($used>=$warning && $warning>0 ? 'warning' : ''); + $warn = exceed($used,$critical) ? 'alert' : (exceed($used,$warning) ? 'warning' : ''); $item = 'used'; $last = $saved[$item][$name] ?? 0; if ($warn) { @@ -182,7 +183,7 @@ function check_usage($name,$used,$text,$info) { $saved[$item][$name] = $critical>0 && $used<=$critical ? $critical : $used; } } else { - if ($last) { + if ($last && $used<=100) { exec("$notify -e ".escapeshellarg("unRAID $text message")." -s ".escapeshellarg("Notice [$server] - $text returned to normal utilization level")." -d ".escapeshellarg("$info")); unset($saved[$item][$name]); }