summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-09-18 05:16:25 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-09-18 05:16:25 +0000
commit27f586993574ef74e00b2ad71c68938353c744de (patch)
tree4c62c6f58c51c4f6dd8d58b3be8477fe9dbbc9c1
parent92ab056608e0e4785bf53cf33d4539dd719e29fa (diff)
downloadpfsense-27f586993574ef74e00b2ad71c68938353c744de.zip
pfsense-27f586993574ef74e00b2ad71c68938353c744de.tar.gz
* Introduce get_memory() which returns amount of memory in the machine
* Use memory to control how many processes will be running and waiting for captive portal authenticaion
-rw-r--r--etc/inc/captiveportal.inc22
-rw-r--r--etc/inc/pfsense-utils.inc20
2 files changed, 39 insertions, 3 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 01a5afd..849ba4e 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -168,11 +168,31 @@ EOD;
fwrite($fd, $key);
fclose($fd);
}
+ /* get memory in meachine */
+ $memory = get_memory();
+ $avail = $memory[0];
+ if($avail > 0 and $avail < 65) {
+ $procs = 1;
+ } else if($avail > 64 and $avail < 128) {
+ $procs = 5;
+ } else if($avail > 128 and $avail < 164) {
+ $procs = 15;
+ } else if($avail > 164 and $avail < 256) {
+ $procs = 20;
+ } else if($avail > 256 and $avail < 384) {
+ $procs = 25;
+ } else if($avail > 384 and $avail < 512) {
+ $procs = 30;
+ } else if($avail > 512 and $avail < 684) {
+ $procs = 40;
+ } else {
+ $procs = 50;
+ }
/* generate lighttpd configuration */
system_generate_lighty_config("{$g['varetc_path']}/lighty-CaptivePortal.conf",
$key, $cert, "lighty-CaptivePortal.pid", "8000", "/usr/local/captiveportal/",
- "cert-portal.pem", "5");
+ "cert-portal.pem", $procs);
/* attempt to start lighttpd */
$res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-CaptivePortal.conf");
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 68b0a3f..dc56236 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -889,8 +889,24 @@ function rmdir_recursive($path,$follow_links=false) {
}
/*
- * safe_mkdir($path, $mode = 0755)
- * create directory if it doesn't already exist and isn't a file!
+ * get_memory()
+ * returns an array listing the amount of
+ * memory installed in the hardware
+ * [0]real and [1]available
+ */
+function get_memory() {
+ $mem = `cat /var/log/dmesg.boot | grep memory`;
+ if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
+ $real = $matches[1];
+ if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
+ $avail = $matches[1];
+ return array($real[0],$avail[0]);
+}
+
+
+/*
+ * safe_mkdir($path, $mode = 0755)
+ * create directory if it doesn't already exist and isn't a file!
*/
function safe_mkdir($path, $mode=0755) {
global $g;
OpenPOWER on IntegriCloud