summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-11-21 16:07:54 -0500
committerScott Ullrich <sullrich@pfsense.org>2009-11-21 16:08:36 -0500
commit483e6de8423236fd6af30de585caa72a507758f1 (patch)
treeeb889e0d2978c3975304a54e2cd7ac4606d73a98 /etc/inc/util.inc
parente2d90eacaa1d352dbf19d7b9c05b1bc0ee1dc942 (diff)
downloadpfsense-483e6de8423236fd6af30de585caa72a507758f1.zip
pfsense-483e6de8423236fd6af30de585caa72a507758f1.tar.gz
Rework includes/require. This saves about 4 megabytes.
Simplify get_memory(). Tested on mips/i386
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc45
1 files changed, 13 insertions, 32 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 3706279..3d8cd43 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -885,37 +885,18 @@ function make_dirs($path, $mode = 0755) {
* [0]real and [1]available
*/
function get_memory() {
- if(file_exists("/var/log/dmesg.boot")) {
- $mem = `cat /var/log/dmesg.boot | grep memory`;
- $matches = "";
- if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
- $real = $matches[1];
- if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
- $avail = $matches[1];
- if(!$real && !$avail) {
- $real = trim(`sysctl hw.physmem | cut -d' ' -f2`);
- $avail = trim(`sysctl hw.realmem | cut -d' ' -f2`);
- $real_mem = $real / 1024;
- $avail_mem = $avail / 1024;
- return array($real_mem,$avail_mem);
- }
- return array($real[0],$avail[0]);
- } else {
- $mem = `dmesg -a`;
- $matches = "";
- if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
- $real = $matches[1];
- if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
- $avail = $matches[1];
- if(!$real && !$avail) {
- $real = trim(`sysctl hw.physmem | cut -d' ' -f2`);
- $avail = trim(`sysctl hw.realmem | cut -d' ' -f2`);
- $real_mem = $real / 1024;
- $avail_mem = $avail / 1024;
- return array($real_mem,$avail_mem);
- }
- return array($real[0],$avail[0]);
- }
+ $matches = "";
+ if(file_exists("/var/log/dmesg.boot"))
+ $mem = `cat /var/log/dmesg.boot | grep memory`;
+ else
+ $mem = `dmesg -a | grep memory`;
+ if (preg_match_all("/avail memory.* \((.*)MB\)/", $mem, $matches))
+ return array($matches[1][0], $matches[1][0]);
+ if(!$real && !$avail) {
+ $real = trim(`sysctl hw.physmem | cut -d' ' -f2`);
+ $avail = trim(`sysctl hw.realmem | cut -d' ' -f2`);
+ return array(($real/1024),($avail/1024));
+ }
}
function mute_kernel_msgs() {
@@ -1039,4 +1020,4 @@ function msort($array, $id="id", $sort_ascending=true) {
}
}
-?>
+?> \ No newline at end of file
OpenPOWER on IntegriCloud