Menu="OtherSettings"
Title="Disk Settings"
Icon="icon-disks"
Tag="icon-disk"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
 * Copyright 2012-2020, 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,
 * as published by the Free Software Foundation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 */
?>
<?
require_once "$docroot/webGui/include/Preselect.php";
$events = explode('|',$var['smEvents'] ?? $numbers);

function displayTemp($temp) {
  global $display;
  return $display['unit']=='F' ? round(9/5*$temp)+32 : $temp;
}
?>
<style>
span.code{display:inline-block;width:186px}
</style>
<script>
function doDispatch(form) {
  var fields = {};
<?if ($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);
<?endif;?>
  fields['#cfg'] = "/boot/config/plugins/dynamix/dynamix.cfg";
  fields['#cleanup'] = true;
  $(form).find('input[name^="display_"]').each(function(){fields[$(this).attr('name')] = $(this).val(); $(this).prop('disabled',true);});
  $.post('/webGui/include/Dispatcher.php',fields);
}
function prepareDiskSettings(form) {
  var events = [];
  for (var i=0; i < <?=count($preselect)?>; i++) {
    if (form.elements['at'+i].checked) events.push(form.elements['at'+i].value);
    form.elements['at'+i].disabled = true;
  }
  var custom = form.smCustom.value.trim();
  var custom = custom.length ? custom.split(',') : [];
  for (var i=0; i < custom.length; i++) events.push(custom[i].trim());
  form.smEvents.value = events.join('|');
  if (form.smEvents.value == '<?=$numbers?>') form.smEvents.value = '';
  if (form.smLevel.value == 1.00) form.smLevel.value = '';
}
function setIndex(form) {
  form.smIndex.value = form.smType.selectedIndex;
}
</script>

<form markdown="1" method="POST" action="/update.htm" target="progressFrame" onsubmit="doDispatch(this)">
_(Enable auto start)_:
: <select name="startArray" size="1">
  <?=mk_option($var['startArray'], "no", _('No'))?>
  <?=mk_option($var['startArray'], "yes", _('Yes'))?>
  </select>

:disk_enable_autostart_help:

_(Default spin down delay)_:
: <select name="spindownDelay" size="1">
  <?=mk_option($var['spindownDelay'], "0",  _('Never'))?>
  <?=mk_option($var['spindownDelay'], "15", "15 "._('minutes'))?>
  <?=mk_option($var['spindownDelay'], "30", "30 "._('minutes'))?>
  <?=mk_option($var['spindownDelay'], "45", "45 "._('minutes'))?>
  <?=mk_option($var['spindownDelay'], "1",  "1 "._('hour'))?>
  <?=mk_option($var['spindownDelay'], "2",  "2 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "3",  "3 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "4",  "4 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "5",  "5 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "6",  "6 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "7",  "7 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "8",  "8 "._('hours'))?>
  <?=mk_option($var['spindownDelay'], "9",  "9 "._('hours'))?>
  </select>

:disk_spindown_delay_help:

_(Enable spinup groups)_:
: <select name="spinupGroups" size="1">
  <?=mk_option($var['spinupGroups'], "no", _('No'))?>
  <?=mk_option($var['spinupGroups'], "yes", _('Yes'))?>
  </select>

:disk_spinup_groups_help:

_(Default file system)_:
: <select name="defaultFsType" size="1">
  <?=mk_option($var['defaultFsType'], "xfs", _('xfs'));?>
  <?=mk_option($var['defaultFsType'], "btrfs", _('btrfs'));?>
  <?=mk_option($var['defaultFsType'], "reiserfs", _('reiserfs'));?>
  <?=mk_option($var['defaultFsType'], "luks:xfs", _('xfs')." - "._('encrypted'));?>
  <?=mk_option($var['defaultFsType'], "luks:btrfs", _('btrfs')." - "._('encrypted'));?>
  <?=mk_option($var['defaultFsType'], "luks:reiserfs", _('reiserfs')." - "._('encrypted'));?>
  </select>

:disk_default_file_system_help:

_(Shutdown time-out)_:
: <input type="text" name="shutdownTimeout" maxlength="10" value="<?=$var['shutdownTimeout']?>" class="narrow">

:disk_shutdown_timeout_help:

_(Tunable (poll_attributes))_:
: <input type="text" name="poll_attributes" maxlength="10" value="<?=$var['poll_attributes']?>" class="narrow"><?=_($var['poll_attributes_status'])?>

:disk_tunable_poll_attributes_help:

_(Tunable (enable NCQ))_:
: <select name="queueDepth" size="1">
  <?=mk_option($var['queueDepth'], "auto", _('Auto'))?>
  <?=mk_option($var['queueDepth'], "1", _('No'))?>
  </select>

:disk_tunable_enable_ncq_help:

_(Tunable (nr_requests))_:
: <input type="text" name="nr_requests" maxlength="10" value="<?=$var['nr_requests']?>" class="narrow"><?=_($var['nr_requests_status'])?>

:disk_tunable_nr_requests_help:

_(Tunable (scheduler))_:
: <select name="md_scheduler" size="1">
  <?=mk_option($var['md_scheduler'], "auto", _('Auto'))?>
  <?=mk_option($var['md_scheduler'], "mq-deadline", _('mq-deadline'))?>
  <?=mk_option($var['md_scheduler'], "kyber", _('kyber'))?>
  <?=mk_option($var['md_scheduler'], "bfq", _('bfq'))?>
  <?=mk_option($var['md_scheduler'], "none", _('none'))?>
  </select>

:disk_tunable_scheduler_help:

_(Tunable (md_num_stripes))_:
: <input type="text" name="md_num_stripes" maxlength="10" value="<?=$var['md_num_stripes']?>" class="narrow"><?=_($var['md_num_stripes_status'])?>

:disk_tunable_md_num_stripes_help:

_(Tunable (md_queue_limit))_:
: <input type="text" name="md_queue_limit" maxlength="10" value="<?=$var['md_queue_limit']?>" class="narrow"><?=_($var['md_queue_limit_status'])?>

:disk_tunable_md_queue_limit_help:

_(Tunable (md_sync_limit))_:
: <input type="text" name="md_sync_limit" maxlength="10" value="<?=$var['md_sync_limit']?>" class="narrow"><?=_($var['md_sync_limit_status'])?>

:disk_tunable_md_sync_limit_help:

_(Tunable (md_write_method))_:
: <select name="md_write_method" size="1">
  <?=mk_option($var['md_write_method'], "auto", _('Auto'))?>
  <?=mk_option($var['md_write_method'], "0", _('read/modify/write'))?>
  <?=mk_option($var['md_write_method'], "1", _('reconstruct write'))?>
  </select>

:disk_tunable_md_write_method_help:

_(Default warning disk utilization threshold)_ (%):
: <input type="number" min="0" max="100" name="display_warning" class="narrow" value="<?=$display['warning']?>">

:disk_default_warning_utilization_help:

_(Default critical disk utilization threshold)_ (%):
: <input type="number" min="0" max="100" name="display_critical" class="narrow" value="<?=$display['critical']?>">

:disk_default_critical_utilization_help:

_(Default warning disk temperature threshold)_ (&deg;<?=$display['unit']?>):
: <input type="number" min="0" max="300" name="display_hot" class="narrow" value="<?=displayTemp($display['hot'])?>">

:disk_default_warning_temperature_help:

_(Default critical disk temperature threshold)_ (&deg;<?=$display['unit']?>):
: <input type="number" min="0" max="300" name="display_max" class="narrow" value="<?=displayTemp($display['max'])?>">

:disk_default_critical_temperature_help:

&nbsp;
: <input type="submit" name="changeDisk" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
</form>

<div id="title"><span class="left"><i class="title fa fa-plus-square"></i>_(Global SMART Settings)_</span></div>

<form markdown="1" name="smart_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareDiskSettings(this)">
<input type="hidden" name="#file" value="/boot/config/smart-all.cfg">
<input type="hidden" name="#include" value="webGui/include/update.smart.php">
<input type="hidden" name="#cleanup" value="true">
<input type="hidden" name="#top" value="1">
<input type="hidden" name="smEvents" value="">
<input type="hidden" name="smIndex" value="0">
_(Default SMART notification value)_:
: <select name="smSelect" size="1">
  <?=mk_option($var['smSelect'], "0", _('Raw'))?>
  <?=mk_option($var['smSelect'], "1", _('Normalized'))?>
  </select>

:disk_default_smart_notification_help:

_(Default SMART notification tolerance level)_:
: <select name="smLevel" size="1">
  <?=mk_option($var['smLevel'], "1.00", _('Absolute'))?>
  <?=mk_option($var['smLevel'], "1.05", "5%")?>
  <?=mk_option($var['smLevel'], "1.10", "10%")?>
  <?=mk_option($var['smLevel'], "1.15", "15%")?>
  <?=mk_option($var['smLevel'], "1.20", "20%")?>
  <?=mk_option($var['smLevel'], "1.25", "25%")?>
  <?=mk_option($var['smLevel'], "1.50", "50%")?>
  </select>

:disk_default_smart_tolerance_help:

_(Default SMART controller type)_:
: <select name="smType" size="1" onchange="setIndex(this.form)">
  <?=mk_option($var['smType'], "", _('Automatic'))?>
  <?=mk_option($var['smType'], "-d ata", "ATA")?>
  <?=mk_option($var['smType'], "-d nvme", "NVMe")?>
  <?=mk_option($var['smType'], "-d sat", "SAT")?>
  <?=mk_option($var['smType'], "-d scsi", "SCSI")?>
  <?=mk_option($var['smType'], "-d 3ware", "3Ware")?>
  <?=mk_option($var['smType'], "-d aacraid", "Adaptec")?>
  <?=mk_option($var['smType'], "-d areca", "Areca")?>
  <?=mk_option($var['smType'], "-d hpt", "HighPoint")?>
  <?=mk_option($var['smType'], "-d cciss", "HP cciss")?>
  <?=mk_option($var['smType'], "-d marvell", "Marvell")?>
  <?=mk_option($var['smType'], "-d megaraid", "MegaRAID")?>
  </select>

:disk_default_smart_controller_help:

_(Default SMART attribute notifications)_:
: <input type="text" name="smCustom" value="<?=$var['smCustom']??''?>" class="narrow">_(Custom attributes (use comma to separate numbers))_

<?for ($x = 0; $x < count($preselect); $x++):?>
&nbsp;
: <input type="checkbox" name="at<?=$x?>" value="<?=$preselect[$x]['code']?>"<?=in_array($preselect[$x]['code'],$events)?' checked':''?>><span class="code">_(Attribute)_ = <?=$preselect[$x]['code']?></span><?=$preselect[$x]['text']?>
<?endfor;?>

:disk_default_smart_attribute_help:

<input type="submit" name="#default" value="_(Default)_">
: <input type="submit" name="#apply" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
</form>
