mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
system: allow to adjust default of 50% RAM usage for MFS options; closes #5727
Add a maximum for /tmp MFS as well and make it adjustable while we still know what we are doing. ;)
This commit is contained in:
parent
5d468642c4
commit
228e74cd5f
@ -42,7 +42,15 @@ fi
|
||||
mkdir -p /tmp
|
||||
|
||||
if [ ${USE_MFS_TMP} -ne 0 ]; then
|
||||
mount -t tmpfs -o mode=01777 tmpfs /tmp
|
||||
MAX_MFS_TMP=$(grep 'max_mfs_tmp' /conf/config.xml | sed 's/[^>]*>\([^<]*\)<.*/\1/')
|
||||
MAX_MEM_SYS=$(sysctl -n hw.physmem)
|
||||
|
||||
if [ -z "${MAX_MFS_TMP}" ]; then
|
||||
# cap to 50% by default to avoid swapping
|
||||
MAX_MFS_TMP=50
|
||||
fi
|
||||
|
||||
mount -t tmpfs -o mode=01777,size=$((MAX_MEM_SYS / 100 * MAX_MFS_TMP)) tmpfs /tmp
|
||||
else
|
||||
rm -rf /tmp/*
|
||||
chmod 1777 /tmp
|
||||
|
||||
@ -77,7 +77,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$pconfig['crypto_hardware'] = !empty($config['system']['crypto_hardware']) ? explode(',', $config['system']['crypto_hardware']) : [];
|
||||
$pconfig['thermal_hardware'] = !empty($config['system']['thermal_hardware']) ? $config['system']['thermal_hardware'] : null;
|
||||
$pconfig['use_mfs_var'] = isset($config['system']['use_mfs_var']);
|
||||
$pconfig['max_mfs_var'] = $config['system']['max_mfs_var'] ?? null;
|
||||
$pconfig['use_mfs_tmp'] = isset($config['system']['use_mfs_tmp']);
|
||||
$pconfig['max_mfs_tmp'] = $config['system']['max_mfs_tmp'] ?? null;
|
||||
$pconfig['use_swap_file'] = isset($config['system']['use_swap_file']);
|
||||
$pconfig['dhparamusage'] = !empty($config['system']['dhparamusage']) ? $config['system']['dhparamusage'] : null;
|
||||
$pconfig['rrdbackup'] = !empty($config['system']['rrdbackup']) ? $config['system']['rrdbackup'] : null;
|
||||
@ -105,11 +107,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (!empty($pconfig['crypto_hardware'])) {
|
||||
if (count(array_intersect($pconfig['crypto_hardware'], crypto_modules())) == count($pconfig['crypto_hardware'])) {
|
||||
$input_errors[] = gettext('Please select a valid Cryptographic Accelerator.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$pconfig['crypto_hardware'] = [];
|
||||
}
|
||||
|
||||
if (isset($pconfig['max_mfs_var']) && $pconfig['max_mfs_var'] != '') {
|
||||
if (!is_numeric($pconfig['max_mfs_var'])) {
|
||||
$input_errors[] = gettext('Memory usage percentage is not a number.');
|
||||
} else if ($pconfig['max_mfs_var'] < 0 || $pconfig['max_mfs_var'] > 100) {
|
||||
$input_errors[] = gettext('Memory usage percentage out of bounds.');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($pconfig['max_mfs_tmp']) && $pconfig['max_mfs_tmp'] != '') {
|
||||
if (!is_numeric($pconfig['max_mfs_tmp'])) {
|
||||
$input_errors[] = gettext('Memory usage percentage is not a number.');
|
||||
} else if ($pconfig['max_mfs_tmp'] < 0 || $pconfig['max_mfs_tmp'] > 100) {
|
||||
$input_errors[] = gettext('Memory usage percentage out of bounds.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($pconfig['thermal_hardware']) && !array_key_exists($pconfig['thermal_hardware'], thermal_modules())) {
|
||||
$input_errors[] = gettext("Please select a valid Thermal Hardware Sensor.");
|
||||
}
|
||||
@ -143,12 +161,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
unset($config['system']['use_mfs_var']);
|
||||
}
|
||||
|
||||
if (isset($pconfig['max_mfs_var']) && $pconfig['max_mfs_var'] != '') {
|
||||
$pconfig['max_mfs_var'] = trim($pconfig['max_mfs_var']);
|
||||
$config['system']['max_mfs_var'] = $pconfig['max_mfs_var'];
|
||||
} elseif (isset($config['system']['max_mfs_var'])) {
|
||||
unset($config['system']['max_mfs_var']);
|
||||
}
|
||||
|
||||
if (!empty($pconfig['use_mfs_tmp'])) {
|
||||
$config['system']['use_mfs_tmp'] = true;
|
||||
} elseif (isset($config['system']['use_mfs_tmp'])) {
|
||||
unset($config['system']['use_mfs_tmp']);
|
||||
}
|
||||
|
||||
if (isset($pconfig['max_mfs_tmp']) && $pconfig['max_mfs_tmp'] != '') {
|
||||
$pconfig['max_mfs_tmp'] = trim($pconfig['max_mfs_tmp']);
|
||||
$config['system']['max_mfs_tmp'] = $pconfig['max_mfs_tmp'];
|
||||
} elseif (isset($config['system']['max_mfs_tmp'])) {
|
||||
unset($config['system']['max_mfs_tmp']);
|
||||
}
|
||||
|
||||
if (!empty($pconfig['use_swap_file'])) {
|
||||
/* set explicit value here in case we want to make it flexible */
|
||||
$config['system']['use_swap_file'] = 2048;
|
||||
@ -495,6 +527,15 @@ include("head.inc");
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_max_mfs_var" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('/var/log RAM usage'); ?></td>
|
||||
<td>
|
||||
<input name="max_mfs_var" type="text" id="max_mfs_var" placeholder="50" value="<?= html_safe($pconfig['max_mfs_var']) ?>"/>
|
||||
<div class="hidden" data-for="help_for_max_mfs_var">
|
||||
<?= gettext('Percentage of RAM used for the respective memory disk. A value of "0" means unlimited.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_use_mfs_tmp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('/tmp RAM disk'); ?></td>
|
||||
<td>
|
||||
@ -505,6 +546,15 @@ include("head.inc");
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_max_mfs_tmp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('/tmp RAM usage'); ?></td>
|
||||
<td>
|
||||
<input name="max_mfs_tmp" type="text" id="max_mfs_tmp" placeholder="50" value="<?= html_safe($pconfig['max_mfs_tmp']) ?>"/>
|
||||
<div class="hidden" data-for="help_for_max_mfs_tmp">
|
||||
<?= gettext('Percentage of RAM used for the respective memory disk. A value of "0" means unlimited.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="content-box tab-content table-responsive __mb">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user