From 5cd73772aac7b2f487db95668191f43771bcab67 Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 16 Jan 2013 13:21:01 +0000 Subject: Use sysctl for this since its better rather than going thorugh dmesg --- etc/inc/util.inc | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'etc/inc/util.inc') 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() { -- cgit v1.1