diff options
author | Chris Buechler <cmb@pfsense.org> | 2013-09-03 10:03:08 -0700 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2013-09-03 10:03:08 -0700 |
commit | 96551a20bae80cf791bd25e2e0a1cd0cc48cb32b (patch) | |
tree | b9268adc4f683d555447f053d09a42a30a4a209a /etc/inc | |
parent | c9d099d788071ad944d47676e086da91faf7faf3 (diff) | |
parent | e9215ad443d485a1fc7c2fa3a065025539ede861 (diff) | |
download | pfsense-96551a20bae80cf791bd25e2e0a1cd0cc48cb32b.zip pfsense-96551a20bae80cf791bd25e2e0a1cd0cc48cb32b.tar.gz |
Merge pull request #794 from phil-davis/RELENG_2_1
Backport get_memory changes to 2.1
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/config.console.inc | 7 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 4 | ||||
-rw-r--r-- | etc/inc/system.inc | 12 | ||||
-rw-r--r-- | etc/inc/util.inc | 9 |
4 files changed, 17 insertions, 15 deletions
diff --git a/etc/inc/config.console.inc b/etc/inc/config.console.inc index f7494db..6c290c0 100644 --- a/etc/inc/config.console.inc +++ b/etc/inc/config.console.inc @@ -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"; diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 764d010..ac2db3f 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -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; } diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 7e59a59..2104790 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -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; diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 6a62563..80efd9b 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -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() { |