mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Merge pull request #794 from phil-davis/RELENG_2_1
Backport get_memory changes to 2.1
This commit is contained in:
commit
96551a20ba
@ -51,13 +51,14 @@ function set_networking_interfaces_ports() {
|
||||
$fp = fopen('php://stdin', 'r');
|
||||
|
||||
$memory = get_memory();
|
||||
$avail = $memory[1];
|
||||
$physmem = $memory[0];
|
||||
$realmem = $memory[1];
|
||||
|
||||
if($avail < $g['minimum_ram_warning']) {
|
||||
if($physmem < $g['minimum_ram_warning']) {
|
||||
echo "\n\n\n";
|
||||
echo gettext("DANGER! WARNING! ACHTUNG!") . "\n\n";
|
||||
printf(gettext("%s requires *AT LEAST* %s RAM to function correctly.%s"), $g['product_name'], $g['minimum_ram_warning_text'], "\n");
|
||||
printf(gettext("Only (%s) MB RAM has been detected.%s"), $avail, "\n");
|
||||
printf(gettext("Only (%s) MB RAM has been detected, with (%s) available to %s.%s"), $realmem, $physmem, $g['product_name'], "\n");
|
||||
echo "\n" . gettext("Press ENTER to continue.") . " ";
|
||||
fgets($fp);
|
||||
echo "\n";
|
||||
|
||||
@ -1494,9 +1494,9 @@ function is_fqdn($fqdn) {
|
||||
function pfsense_default_state_size() {
|
||||
/* get system memory amount */
|
||||
$memory = get_memory();
|
||||
$avail = $memory[1];
|
||||
$physmem = $memory[0];
|
||||
/* Be cautious and only allocate 10% of system memory to the state table */
|
||||
$max_states = (int) ($avail/10)*1000;
|
||||
$max_states = (int) ($physmem/10)*1000;
|
||||
return $max_states;
|
||||
}
|
||||
|
||||
|
||||
@ -878,21 +878,21 @@ function system_generate_lighty_config($filename,
|
||||
$lighty_port = $port;
|
||||
|
||||
$memory = get_memory();
|
||||
$avail = $memory[1];
|
||||
$realmem = $memory[1];
|
||||
|
||||
// Determine web GUI process settings and take into account low memory systems
|
||||
if ($avail < 255)
|
||||
if ($realmem < 255)
|
||||
$max_procs = 1;
|
||||
else
|
||||
$max_procs = ($config['system']['webgui']['max_procs']) ? $config['system']['webgui']['max_procs'] : 2;
|
||||
|
||||
// Ramp up captive portal max procs, assuming each PHP process can consume up to 64MB RAM
|
||||
if ($captive_portal !== false) {
|
||||
if ($avail > 135 and $avail < 256) {
|
||||
if ($realmem > 135 and $realmem < 256) {
|
||||
$max_procs += 1; // 2 worker processes
|
||||
} else if ($avail > 255 and $avail < 513) {
|
||||
} else if ($realmem > 255 and $realmem < 513) {
|
||||
$max_procs += 2; // 3 worker processes
|
||||
} else if ($avail > 512) {
|
||||
} else if ($realmem > 512) {
|
||||
$max_procs += 4; // 6 worker processes
|
||||
}
|
||||
if ($max_procs > 1)
|
||||
@ -901,7 +901,7 @@ function system_generate_lighty_config($filename,
|
||||
$max_php_children = 1;
|
||||
|
||||
} else {
|
||||
if ($avail < 78)
|
||||
if ($realmem < 78)
|
||||
$max_php_children = 0;
|
||||
else
|
||||
$max_php_children = 1;
|
||||
|
||||
@ -1514,14 +1514,15 @@ function set_sysctl($values) {
|
||||
* get_memory()
|
||||
* returns an array listing the amount of
|
||||
* memory installed in the hardware
|
||||
* [0]real and [1]available
|
||||
* [0] net memory available for the OS (FreeBSD) after some is taken by BIOS, video or whatever - e.g. 235 MBytes
|
||||
* [1] real (actual) memory of the system, should be the size of the RAM card/s - e.g. 256 MBytes
|
||||
*/
|
||||
function get_memory() {
|
||||
|
||||
$real = trim(`sysctl -n hw.physmem`, " \n");
|
||||
$avail = trim(`sysctl -n hw.realmem`, " \n");
|
||||
$physmem = trim(`sysctl -n hw.physmem`, " \n");
|
||||
$realmem = trim(`sysctl -n hw.realmem`, " \n");
|
||||
/* convert from bytes to megabytes */
|
||||
return array(($real/1048576),($avail/1048576));
|
||||
return array(($physmem/1048576),($realmem/1048576));
|
||||
}
|
||||
|
||||
function mute_kernel_msgs() {
|
||||
|
||||
@ -128,7 +128,8 @@ echo ".";
|
||||
|
||||
/* get system memory amount */
|
||||
$memory = get_memory();
|
||||
$avail = $memory[1];
|
||||
$physmem = $memory[0];
|
||||
$realmem = $memory[1];
|
||||
echo " done.\n";
|
||||
|
||||
conf_mount_rw();
|
||||
@ -295,8 +296,8 @@ echo "Synchronizing user settings...";
|
||||
local_sync_accounts();
|
||||
echo "done.\n";
|
||||
|
||||
if($avail > 0 and $avail < 65) {
|
||||
echo "System has less than 65 megabytes of ram {$avail}. Delaying webConfigurator startup.\n";
|
||||
if($realmem > 0 and $realmem < 65) {
|
||||
echo "System has less than 65 megabytes of ram {$realmem}. Delaying webConfigurator startup.\n";
|
||||
/* start webConfigurator up on final pass */
|
||||
mwexec("/usr/local/sbin/pfSctl -c 'service restart webgui'");
|
||||
} else {
|
||||
@ -385,7 +386,7 @@ if($config['system']['afterbootupshellcmd'] <> "") {
|
||||
mwexec($config['system']['afterbootupshellcmd']);
|
||||
}
|
||||
|
||||
if($avail < $g['minimum_ram_warning']) {
|
||||
if($physmem < $g['minimum_ram_warning']) {
|
||||
require_once("/etc/inc/notices.inc");
|
||||
file_notice("{$g['product_name']}MemoryRequirements", "{$g['product_name']} requires at least {$g['minimum_ram_warning_text']} of RAM. Expect unusual performance. This platform is not supported.", "Memory", "", 1);
|
||||
mwexec("/sbin/sysctl net.inet.tcp.recvspace=4096");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user