diff options
-rw-r--r-- | etc/inc/util.inc | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 858d663..ffe635a 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -1453,19 +1453,11 @@ function set_sysctl($values) { * [0]real and [1]available */ function get_memory() { - $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`); - /* convert from bytes to megabytes */ - return array(($real/1048576),($avail/1048576)); - } + + $real = trim(`sysctl -n hw.physmem`, " \n"); + $avail = trim(`sysctl hw.realmem`, " \n"); + /* convert from bytes to megabytes */ + return array(($real/1048576),($avail/1048576)); } function mute_kernel_msgs() { |