Fix: detect memory sticks that report Size in GB

This commit is contained in:
Eric Schultz
2015-12-18 14:50:35 -08:00
parent f47f53c4ee
commit 7b894dc081
2 changed files with 2 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ foreach ($shares as $share) {
exec("awk '/^MemTotal/{print $2*1024/1.048576}' /proc/meminfo",$total);
exec("ifconfig -s|awk '/^(bond|eth|lo)/{print $1}'",$ports);
$memory_installed = exec("dmidecode -t 17 | awk -F: '/^\tSize: [0-9]+ MB$/{t+=$2} END{print t}'");
$memory_installed = exec("dmidecode -t 17 | awk -F: '/^\tSize: [0-9]+ MB$/{t+=$2} /^\tSize: [0-9]+ GB$/{t+=$2*1024} END{print t}'");
$memory_maximum = exec("dmidecode -t 16 | awk -F: '/^\tMaximum Capacity: [0-9]+ GB$/{t+=$2} END{print t}'");
// If maximum < installed then roundup maximum to the next power of 2 size of installed. E.g. 6 -> 8 or 12 -> 16
if ($memory_maximum*1024 < $memory_installed) $memory_maximum = pow(2,ceil(log($memory_installed/1024)/log(2)));

View File

@@ -136,7 +136,7 @@ echo $size;
<?
// Memory Device (16) will get us each ram chip. By matching on MB it'll filter out Flash/Bios chips
// Sum up all the Memory Devices to get the amount of system memory installed
$memory_installed = exec("dmidecode -t 17 | awk -F: '/^\tSize: [0-9]+ MB$/{t+=$2} END{print t}'");
$memory_installed = exec("dmidecode -t 17 | awk -F: '/^\tSize: [0-9]+ MB$/{t+=$2} /^\tSize: [0-9]+ GB$/{t+=$2*1024} END{print t}'");
// Physical Memory Array (16) usually one of these for a desktop-class motherboard but higher-end xeon motherboards
// might have two or more of these. The trick is to filter out any Flash/Bios types by matching on GB
// Sum up all the Physical Memory Arrays to get the motherboard's total memory capacity