diff --git a/plugins/dynamix.apcupsd/include/UPSstatus.php b/plugins/dynamix.apcupsd/include/UPSstatus.php index b615a2bd3..71d55556a 100644 --- a/plugins/dynamix.apcupsd/include/UPSstatus.php +++ b/plugins/dynamix.apcupsd/include/UPSstatus.php @@ -1,5 +1,5 @@ ',device:'parity'},function(data) { if (data) {$.each(data.split(';'),function(k,v) {if ($('#line'+k).length>0) $('#line'+k).html(v);});} - if ($('#tab'+$('input[name$="tabs"]').length).is(':checked')) timer = setTimeout(parity_status,3000); + if ($('#tab'+$('input[name$="tabs"]').length).is(':checked')) timer = setTimeout(parityStatus,3000); - setTimeout(parity_status,3000); + setTimeout(parityStatus,3000); if (!data && $('#cancelButton').length>0 && $('#cancelButton').val()=='Cancel') { $('#cancelButton').val('Done').unbind().bind({click:function(){refresh();}}); @@ -71,7 +71,7 @@ function parity_status() { } }); } -function parity_warning(form) { +function parityWarning(form) { var text = 'Dual parity valid requires ALL disks in their original slots'; @@ -84,7 +84,7 @@ function parity_warning(form) { form.submit(); } } -function stop_array(form) { +function stopArray(form) { $(form).append(''); swal({title:'Proceed?',text:'This will stop the array',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmdStop"]').remove();}); @@ -92,7 +92,7 @@ function stop_array(form) { form.submit(); } -function stop_parity(form,text) { +function stopParity(form,text) { $(form).append(''); swal({title:'Proceed?',text:'This will stop the running '+text+' operation',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmdNoCheck"]').remove();}); @@ -100,7 +100,7 @@ function stop_parity(form,text) { form.submit(); } -function shut_down(form,cmd) { +function shutdown(form,cmd) { $(form).append(''); swal({title:'Proceed?',text:'This will '+cmd+' the system',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmd"]').remove();}); @@ -170,11 +170,11 @@ function getFileContent(event,form) { reader.onload = function(){form.file.value=reader.result;toggleStart(false);}; reader.readAsDataURL(input.files[0]); } -parity_status(); +parityStatus(); $('.tabs').append(ctrl); if ($.cookie('tab')=='tab0') $('i.toggle').hide(); -$('#tab'+$('input[name$="tabs"]').length).bind({click:function() {clearTimeout(timer); parity_status(); tab0(); $('i.toggle').hide('slow');}}); +$('#tab'+$('input[name$="tabs"]').length).bind({click:function() {clearTimeout(timer); parityStatus(); tab0(); $('i.toggle').hide('slow');}}); $('div[id=title]:not(":last, .disable_diskio")').each(function(){$(this).append(ctrl);}); @@ -219,7 +219,7 @@ $(function(){ switch ($var['fsState']): case "Started":?> Started - disabled> + disabled> Stop will take the array off-line.$parity":($mover?"
$mover":"")?> 0):?> Unmountable disk present:
@@ -227,8 +227,8 @@ $(function(){ echo "".my_disk($disk['name'])." • ".my_id($disk['id'])." (".$disk['device'].")
";?> Format will create a file system in all Unmountable disks, discarding all data currently on those disks.
- - Yes I want to do this  + + Yes I want to do this All data is permanently lost !!!
This is not used to recover data
Parity is valid.Check will start Parity-Check.
Write corrections to parity - - + + + Last check incomplete on , finding error.
Error code: - - Last checked on -
Duration: - - - + + Last checked on , finding error. +
Duration: + + Last check incomplete on , finding error. +
Error code: + Last checked on , finding error.
Duration: Last check incomplete on , finding error. -
Error code: +
Error code: - Last check completed on , finding error.
Duration: - Read-Check in progress. + Read-Check in progress. Cancel will stop the Read-Check. - Parity-Check in progress. + Parity-Check in progress. Cancel will stop the Parity-Check. - Parity-Sync/Data-Rebuild in progress. + Parity-Sync/Data-Rebuild in progress. Cancel will stop Parity-Sync/Data-Rebuild.
WARNING: canceling may leave the array unprotected! - Clearing in progress. + Clearing in progress. Cancel will stop Clearing. Total size: @@ -359,7 +363,7 @@ $(function(){ Start will record all disk information and bring the array on-line.
The array will be immediately available, but unprotected since parity has not been assigned. - Stopped. Configuration valid. + Stopped. Configuration valid. Start will record all disk information, bring the array on-line, and start Parity-Sync.
The array will be immediately available, but unprotected until Parity-Sync completes.
Parity is already valid. @@ -454,38 +458,40 @@ $(function(){
- - - + + + +
>>Spin Down will immediately spin down all disks.
Spin Up will immediately spin up all disks.
Clear Statistics will immediately clear all disk statistics.
>>Spin Down will immediately spin down all disks.
Spin Up will immediately spin up all disks.
Clear Statistics will immediately clear all disk statistics.
- + - + - + - +
Mover is running.Disabled - Mover is running. Click to invoke the Mover.Move now will immediately invoke the Mover.
-
+ - +
Delete encryption keyfile
Delete will delete the encryption keyfile, device encryption remains functional. +
Yes I want to do this
- - + +
Reboot will activate a clean system reset.
Power down will activate a clean power down.
Reboot will activate a clean system reset.
Power down will activate a clean power down.
Once you have assigned all of your hard drives, refer to the Array Status section below > and Start the array. - +
> #### Encryption input > +> Passphrase or file is stored in /root/keyfile.
> This keyfile is read during array Start and is used to encrypt/decrypt content of encrypted devices. > -> With array Stopped, the keyfile may be deleted and the user can specify a new encryption key. Note that once a device +> With array Stopped, the user can specify a new encryption key. Note that once a device > is formatted with a particular key it may only be opened using that same key. Changing the encryption key requires > encrypted devices to be reformatted **resulting in permanent loss of all existing data on those devices.** > diff --git a/plugins/dynamix/DashStats.page b/plugins/dynamix/DashStats.page index 0a2e1c4f2..37ee0f535 100644 --- a/plugins/dynamix/DashStats.page +++ b/plugins/dynamix/DashStats.page @@ -39,7 +39,6 @@ function init_row($label) { } function parity_status() { global $var,$disks; - $parity_num_slots = 0; $parity_disabled = []; $parity_invalid = []; @@ -54,7 +53,6 @@ function parity_status() { } } } - if ($parity_num_slots == count($parity_disabled)) { echo "Parity disk".($parity_num_slots>1?'s':'')." not present"; return; @@ -71,7 +69,16 @@ function parity_status() { return; } if ($var['sbSynced']==0) { - echo "Parity has not been checked yet."; + list($date,$duration,$speed,$status,$error) = last_parity_log(); + if (!$date) { + echo "Parity has not been checked yet."; + } elseif ($status==0) { + echo "Last checked on ".my_time($date).day_count($date).", finding $error error".($error==1?'.':'s.'); + echo "
Duration: ".my_check($duration,$speed).""; + } else { + echo "Last check incomplete on ".my_time($date).day_count($date).", finding $error error".($error==1?'.':'s.'); + echo "
Error code: ".my_error($status).""; + } return; } if ($var['sbSynced2']==0) { @@ -82,7 +89,7 @@ function parity_status() { 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"; + echo "
Error code: ".my_error($status).""; } } else { $status = 0; diff --git a/plugins/dynamix/MoverSettings.page b/plugins/dynamix/MoverSettings.page index c5dfa314b..cf339f90b 100644 --- a/plugins/dynamix/MoverSettings.page +++ b/plugins/dynamix/MoverSettings.page @@ -15,16 +15,12 @@ Tag="calendar-check-o" */ ?> No Cache disk present!

"; - $disabled = 'disabled'; } elseif ($var['shareCacheEnabled']!='yes') { echo "

Cache disk not enabled!

"; - $disabled = 'disabled'; } elseif ($var['shareUser']=='-') { echo "

User shares not enabled!

"; - $disabled = 'disabled'; } $cron = explode(' ',$var['shareMoverSchedule']); $move = $cron[2]!='*' ? 3 : ($cron[4]!='*' ? 2 : (substr($cron[1],0,1)!='*' ? 1 : 0)); @@ -124,10 +120,12 @@ Mover logging:   : +   : Mover is running. -: > Click to invoke the Mover. +: Click to invoke the Mover. + \ No newline at end of file diff --git a/plugins/dynamix/include/Acknowledge.php b/plugins/dynamix/include/Acknowledge.php index 52cb21b7c..d9c86cc74 100644 --- a/plugins/dynamix/include/Acknowledge.php +++ b/plugins/dynamix/include/Acknowledge.php @@ -1,6 +1,6 @@ diff --git a/plugins/dynamix/include/CheckPort.php b/plugins/dynamix/include/CheckPort.php index 7bc6457ab..1aa058f58 100644 --- a/plugins/dynamix/include/CheckPort.php +++ b/plugins/dynamix/include/CheckPort.php @@ -1,6 +1,6 @@ "); 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/DeleteLogFile.php b/plugins/dynamix/include/DeleteLogFile.php index d3fced3bb..f4ca94f42 100644 --- a/plugins/dynamix/include/DeleteLogFile.php +++ b/plugins/dynamix/include/DeleteLogFile.php @@ -1,6 +1,6 @@ $help"; $link = (strcmp($disk['status'], 'DISK_NP')!=0 || $disk['name']=="cache") ? "".$fancyname."" : $fancyname; - if ($show && $online) switch ($disk['luksState']) { + if ($crypto && $online) switch ($disk['luksState']) { case 0: $luks = ""; break; - case 1: $luks = "Encrypted and unlocked"; break; - case 2: $luks = "Locked: missing encryption key"; break; - case 3: $luks = "Locked: wrong encryption key"; break; - default: $luks = "Locked: unknown error"; break; + case 1: $luks = "Device encrypted and unlocked"; break; + case 2: $luks = "Device locked: missing encryption key"; break; + case 3: $luks = "Device locked: wrong encryption key"; break; + default: $luks = "Device locked: unknown error"; break; } else $luks = ''; return $status.$luks.$link; } @@ -90,19 +90,22 @@ function assignment(&$disk) { $out .= ""; } else $out .= ""; - if ($disk['type']=="Cache") + if ($disk['type']=='Cache') foreach ($devs as $dev) {$out .= "";} else foreach ($devs as $dev) if ($dev['tag']==0) {$out .= "";} return "$out"; } +function str_strip($fs) { + return str_replace('luks:','',$fs); +} function fs_info(&$disk) { global $display; if ($disk['fsStatus']=='-') { - echo $disk['type']=='Cache' ? "".str_replace('luks:','',$disk['fsType'])."Device is part of cache pool" : ""; + echo $disk['type']=='Cache' ? "".str_strip($disk['fsType'])."Device is part of cache pool" : ""; return; } elseif ($disk['fsStatus']=='Mounted') { - echo "".str_replace('luks:','',$disk['fsType']).""; + echo "".str_strip($disk['fsType']).""; echo "".my_scale($disk['fsSize']*1024,$unit,-1)." $unit"; if ($display['text']%10==0) { echo "".my_scale($disk['fsUsed']*1024,$unit)." $unit"; @@ -118,27 +121,31 @@ function fs_info(&$disk) { } echo "".device_browse($disk).""; } else - echo "".str_replace('luks:','',$disk['fsType'])."{$disk['fsStatus']}"; + echo "".str_strip($disk['fsType'])."{$disk['fsStatus']}"; } function my_diskio($data) { return my_scale($data,$unit,1)." $unit/s"; } +function parity_only($disk) { + return $disk['type']=='Parity'; +} +function data_only($disk) { + return $disk['type']=='Data'; +} +function cache_only($disk) { + return $disk['type']=='Cache'; +} function array_offline(&$disk) { global $var, $disks; - if (strpos($var['mdState'],"ERROR:")===false) { - $w = 'All existing data on this device will be OVERWRITTEN when array is Started'; - if ($disk['type']=="Cache") { - if (!empty($disks['cache']['uuid']) && $disk['status']=="DISK_NEW") $warning = $w; - } - else { - if ($var['mdState']=="NEW_ARRAY") { - if ($disk['type']=="Parity") $warning = $w; - } - else { - if ($disk['status']=="DISK_INVALID" || - $disk['status']=="DISK_DSBL_NEW" || - $disk['status']=="DISK_WRONG" || - $disk['status']=="DISK_NEW") $warning = $w; + if (strpos($var['mdState'],'ERROR:')===false) { + $text = 'All existing data on this device will be OVERWRITTEN when array is Started'; + if ($disk['type']=='Cache') { + if (!empty($disks['cache']['uuid']) && $disk['status']=='DISK_NEW') $warning = $text; + } else { + if ($var['mdState']=='NEW_ARRAY') { + if ($disk['type']=='Parity') $warning = $text; + } else { + if (in_array($disk['status'],['DISK_INVALID','DISK_DSBL_NEW','DISK_WRONG','DISK_NEW'])) $warning = $text; } } } @@ -231,7 +238,7 @@ function my_clock($time) { } function read_disk($name, $part) { global $var; - $port = substr($name,-2)!='n1' ? $name : substr($name,0,-2); + $port = port_name($name); switch ($part) { case 'color': return exec("hdparm -C ".escapeshellarg("/dev/$port")."|grep -Po 'active|unknown'") ? 'blue-on' : 'blue-blink'; @@ -302,24 +309,26 @@ function cache_slots() { $out .= ""; return $out; } -$show = false; +$crypto = false; switch ($_POST['device']) { case 'array': - foreach ($disks as $disk) if ($disk['type']=='Data') $show |= strpos($disk['fsType'],'luks:')!==false; + $parity = array_filter($disks,'parity_only'); + $data = array_filter($disks,'data_only'); + foreach ($data as $disk) $crypto |= strpos($disk['fsType'],'luks:')!==false; if ($var['fsState']=='Stopped') { - foreach ($disks as $disk) {if ($disk['type']=='Parity') array_offline($disk);} + foreach ($parity as $disk) array_offline($disk); echo ""; - foreach ($disks as $disk) {if ($disk['type']=='Data') array_offline($disk);} + foreach ($data as $disk) array_offline($disk); echo "Slots:".array_slots().""; } else { - foreach ($disks as $disk) {if ($disk['type']=='Parity' && $disk['status']!='DISK_NP_DSBL') array_online($disk);} - foreach ($disks as $disk) {if ($disk['type']=='Data') array_online($disk);} + foreach ($parity as $disk) if ($disk['status']!='DISK_NP_DSBL') array_online($disk); + foreach ($data as $disk) array_online($disk); if ($display['total']) show_totals('Array of '.my_word($var['mdNumDisks']).' devices'); } break; case 'flash': $disk = &$disks['flash']; - $data = $diskio ? explode(' ',$diskio[$disk['device']]) : []; + $data = explode(' ',$diskio[$disk['device']] ?? ''); $disk['fsUsed'] = $disk['fsSize']-$disk['fsFree']; echo ""; echo "".device_info($disk,true).""; @@ -332,19 +341,20 @@ case 'flash': echo ""; break; case 'cache': - foreach ($disks as $disk) if ($disk['type']=='Cache') $show |= strpos($disk['fsType'],'luks:')!==false; + $cache = array_filter($disks,'cache_only'); + foreach ($cache as $disk) $crypto |= strpos($disk['fsType'],'luks:')!==false; if ($var['fsState']=='Stopped') { - foreach ($disks as $disk) {if ($disk['type']=='Cache') array_offline($disk);} + foreach ($cache as $disk) array_offline($disk); echo "Slots:".cache_slots().""; } else { - foreach ($disks as $disk) {if ($disk['type']=='Cache') array_online($disk);} + foreach ($cache as $disk) array_online($disk); if ($display['total'] && $var['cacheSbNumDisks']>1) show_totals('Pool of '.my_word($var['cacheNumDevices']).' devices'); } break; case 'open': foreach ($devs as $disk) { $dev = $disk['device']; - $data = $diskio ? explode(' ',$diskio[$dev]) : []; + $data = explode(' ',$diskio[$dev] ?? ''); $disk['name'] = $dev; $disk['type'] = 'New'; $disk['color'] = read_disk($dev,'color'); diff --git a/plugins/dynamix/include/DiskList.php b/plugins/dynamix/include/DiskList.php index 3096c62f1..217ae7ecd 100644 --- a/plugins/dynamix/include/DiskList.php +++ b/plugins/dynamix/include/DiskList.php @@ -46,11 +46,17 @@ function shareInclude($name) { return !$include || substr($name,0,4)!='disk' || strpos("$include,", "$name,")!==false; } +function sharesOnly($disk) { + return strpos('Data,Cache',$disk['type'])!==false && $disk['exportable']=='yes'; +} +// filter disk shares +$disks = array_filter($disks,'sharesOnly'); + // Compute all disk shares & check encryption -$show = false; +$crypto = false; foreach ($disks as $name => $disk) { - if ($compute=='yes' && $disk['exportable']=='yes') exec("webGui/scripts/disk_size ".escapeshellarg($name)." ssz2"); - if (strstr('Data,Cache',$disk['type'])) $show |= strpos($disk['fsType'],'luks:')!==false; + if ($compute=='yes') exec("webGui/scripts/disk_size ".escapeshellarg($name)." ssz2"); + $crypto |= strpos($disk['fsType'],'luks:')!==false; } // global shares include/exclude @@ -66,14 +72,14 @@ else // Build table $row = 0; foreach ($disks as $name => $disk) { - if (!strstr('Data,Cache',$disk['type']) || $disk['fsColor']=='grey-off' || $disk['exportable']=='no') continue; + $color = $disk['fsColor']; $row++; - $ball = "/webGui/images/{$disk['fsColor']}.png"; - switch ($disk['fsColor']) { + $ball = "/webGui/images/$color.png"; + switch ($color) { case 'green-on': $help = 'All files protected'; break; case 'yellow-on': $help = 'All files unprotected'; break; } - if ($show) switch ($disk['luksState']) { + if ($crypto) switch ($disk['luksState']) { case 0: $luks = ""; break; case 1: $luks = "All files encrypted"; break; case 2: $luks = "Some or all files unencrypted"; break; diff --git a/plugins/dynamix/include/HardwareCollect.php b/plugins/dynamix/include/HardwareCollect.php index 8e7effde8..2bbb31b96 100644 --- a/plugins/dynamix/include/HardwareCollect.php +++ b/plugins/dynamix/include/HardwareCollect.php @@ -1,6 +1,6 @@ user abort
"; + return "aborted"; default: return "$code"; } @@ -176,6 +176,13 @@ function read_parity_log($epoch, $busy=false) { } return $line ?: $last ?: '0|0|0|0|0'; } +function last_parity_log() { + $log = '/boot/config/parity-checks.log'; + if (!file_exists($log)) return [0,0,0,0,0]; + list($date,$duration,$speed,$status,$error) = explode('|',exec("tail -1 $log")); + list($y,$m,$d,$t) = preg_split('/ +/',$date); + return [strtotime("$d-$m-$y $t"), $duration, $speed, $status, $error]; +} function urlencode_path($path) { return str_replace("%2F", "/", urlencode($path)); } diff --git a/plugins/dynamix/include/InstallKey.php b/plugins/dynamix/include/InstallKey.php index cd51a7854..10295f09c 100644 --- a/plugins/dynamix/include/InstallKey.php +++ b/plugins/dynamix/include/InstallKey.php @@ -1,5 +1,5 @@ addLog('$line');"; } diff --git a/plugins/dynamix/include/Markdown.php b/plugins/dynamix/include/Markdown.php index 3309f571d..56bb38cf6 100644 --- a/plugins/dynamix/include/Markdown.php +++ b/plugins/dynamix/include/Markdown.php @@ -3,7 +3,7 @@ # Markdown Extra - A text-to-HTML conversion tool for web writers # # LimeTech - Give all blockquotes class="inline_help". -# Copyright 2005-2016, Lime Technology +# Copyright 2005-2017, Lime Technology # # # PHP Markdown & Extra diff --git a/plugins/dynamix/include/Notify.php b/plugins/dynamix/include/Notify.php index 8cdd3b310..0b92eaa69 100644 --- a/plugins/dynamix/include/Notify.php +++ b/plugins/dynamix/include/Notify.php @@ -1,6 +1,6 @@ /dev/null & echo $!',$op); diff --git a/plugins/dynamix/include/ShareData.php b/plugins/dynamix/include/ShareData.php index 50dcf0004..981dfd4f2 100644 --- a/plugins/dynamix/include/ShareData.php +++ b/plugins/dynamix/include/ShareData.php @@ -1,6 +1,6 @@ $share) { if ($compute=='yes') exec("webGui/scripts/share_size ".escapeshellarg($name)." ssz1"); - $show |= $share['luksStatus']>0; + $crypto |= $share['luksStatus']>0; } // global shares include/exclude @@ -74,12 +74,13 @@ else $row = 0; foreach ($shares as $name => $share) { $row++; - $ball = "/webGui/images/{$share['color']}.png"; - switch ($share['color']) { + $color = $share['color']; + $ball = "/webGui/images/$color.png"; + switch ($color) { case 'green-on': $help = 'All files protected'; break; case 'yellow-on': $help = 'Some or all files unprotected'; break; } - if ($show) switch ($share['luksStatus']) { + if ($crypto) switch ($share['luksStatus']) { case 0: $luks = ""; break; case 1: $luks = "All files encrypted"; break; case 2: $luks = "Some or all files unencrypted"; break; 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/include/local_prepend.php b/plugins/dynamix/include/local_prepend.php index 978487239..a93f23053 100644 --- a/plugins/dynamix/include/local_prepend.php +++ b/plugins/dynamix/include/local_prepend.php @@ -1,5 +1,5 @@ ErrorWarningSystemArray

\n"; -$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; +$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; require_once "$docroot/webGui/include/ColorCoding.php"; $ata = exec("ls -n ".escapeshellarg("/sys/block/{$argv[1]}")."|grep -Po 'ata\d+'"); diff --git a/plugins/dynamix/scripts/emhttpd_update b/plugins/dynamix/scripts/emhttpd_update index e626c30c1..8d41f9c48 100755 --- a/plugins/dynamix/scripts/emhttpd_update +++ b/plugins/dynamix/scripts/emhttpd_update @@ -12,7 +12,7 @@ */ ?> 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]); } diff --git a/plugins/dynamix/scripts/notify b/plugins/dynamix/scripts/notify index 01f58c190..4550191e7 100755 --- a/plugins/dynamix/scripts/notify +++ b/plugins/dynamix/scripts/notify @@ -13,7 +13,7 @@ */ ?> ErrorWarningSystemArray

\n"; -$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; +$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; require_once "$docroot/webGui/include/ColorCoding.php"; $handle = popen('/usr/bin/tail -n 40 -f '.escapeshellarg("/var/log/{$argv[1]}").' 2>&1', 'r'); diff --git a/plugins/dynamix/styles/default-azure.css b/plugins/dynamix/styles/default-azure.css index 453a8f8ec..6eda62898 100644 --- a/plugins/dynamix/styles/default-azure.css +++ b/plugins/dynamix/styles/default-azure.css @@ -138,7 +138,7 @@ table.disk_status tr td:last-child{width:4%;padding-right:10px} table.disk_status tbody tr{border-bottom:#F3F0F4 1px solid;line-height:30px} table.disk_status.stats tr>td+td{text-align:left;padding-left:0;padding-right:12px} table.array_status{line-height:30px} -table.array_status td{padding:12px 0} +table.array_status td{padding:4px 0} table.array_status td:first-child{text-transform:uppercase} table.array_status tr>td{text-align:left;white-space:nowrap;padding-left:12px;width:30%} table.array_status tr>td+td{padding-left:2px;width:20%} diff --git a/plugins/dynamix/styles/default-gray.css b/plugins/dynamix/styles/default-gray.css index 2bcfb7102..8df517c83 100644 --- a/plugins/dynamix/styles/default-gray.css +++ b/plugins/dynamix/styles/default-gray.css @@ -138,7 +138,7 @@ table.disk_status tr td:last-child{width:4%;padding-right:10px} table.disk_status tbody tr{border-bottom:#0C0F0B 1px solid;line-height:30px} table.disk_status.stats tr>td+td{text-align:left;padding-left:0;padding-right:12px} table.array_status{line-height:30px} -table.array_status td{padding:12px 0} +table.array_status td{padding:4px 0} table.array_status td:first-child{text-transform:uppercase} table.array_status tr>td{text-align:left;white-space:nowrap;padding-left:12px;width:30%} table.array_status tr>td+td{padding-left:2px;width:20%}