From 5170d485a71ea32f3ec6edc23a46dcdad375fe12 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Nov 2017 12:45:35 +0100 Subject: [PATCH] Use MB as calculation unit + code enhancement --- plugins/dynamix/include/SystemInformation.php | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/plugins/dynamix/include/SystemInformation.php b/plugins/dynamix/include/SystemInformation.php index 922482a98..40d488a26 100644 --- a/plugins/dynamix/include/SystemInformation.php +++ b/plugins/dynamix/include/SystemInformation.php @@ -45,7 +45,7 @@ echo empty($var['SYS_MODEL']) ? 'N/A' : "{$var['SYS_MODEL']}";
M/B:
CPU: @@ -54,7 +54,7 @@ function write($number) { $words = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty','twenty-one','twenty-two','twenty-three','twenty-four','twenty-five','twenty-six','twenty-seven','twenty-eight','twenty-nine','thirty']; return $number<=count($words) ? $words[$number] : $number; } -$cpu = explode('#',exec("dmidecode -q -t 4|awk -F: '/^\tVersion:/{v=$2;}; /^\tCurrent Speed:/{s=$2;} END{print v\"#\"s}'")); +$cpu = explode('#',exec("dmidecode -qt4|awk -F: '/^\tVersion:/{v=\$2};/^\tCurrent Speed:/{s=\$2} END{print v\"#\"s}'")); $cpumodel = str_ireplace(["Processor","(C)","(R)","(TM)"],["","©","®","™"],$cpu[0]); if (strpos($cpumodel,'@')===false) { $cpuspeed = explode(' ',$cpu[1]); @@ -116,7 +116,7 @@ if (strpos($cpumodel,'@')===false) {
Cache:
Memory: 8 or 12 -> 16 -$star = ""; -if ($memory_maximum < $memory_installed) {$memory_maximum = pow(2,ceil(log($memory_installed)/log(2))); $star = "*";} -echo "$memory_installed GB ".($ecc_support == "None" ? "" : "$ecc_support ")."(max. installable capacity $memory_maximum GB)$star"; +/* + 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. Convert MB to GB + 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 + Extract error correction type, if none, do not include additional information in the output + If maximum < installed then roundup maximum to the next power of 2 size of installed. E.g. 6 -> 8 or 12 -> 16 +*/ +$memory_installed = exec("dmidecode -qt17|awk -F: '/^\tSize: [0-9]+ MB\$/{t+=\$2};/^\tSize: [0-9]+ GB\$/{t+=\$2*1024} END{print t}'"); +list($memory_maximum,$ecc_support) = array_map('trim',explode('#',exec("dmidecode -qt16|awk -F: '/^\tMaximum Capacity: [0-9]+ GB\$/{t+=\$2*1024};/^\tError Correction Type:/{e=\$2} END{print t\"#\"e}'"))); +if ($memory_installed >= 1024) { + $memory_installed /= 1024; + $memory_maximum /= 1024; + $unit = 'GB'; +} else $unit = 'MB'; +if ($memory_maximum < $memory_installed) {$memory_maximum = pow(2,ceil(log($memory_installed)/log(2))); $star = '*';} else $star = ''; +echo "$memory_installed $unit ".($ecc_support == "None" ? "" : "$ecc_support ")."(max. installable capacity $memory_maximum $unit)$star"; ?>
Network: