diff options
author | Simon Rettberg | 2015-12-04 21:13:36 +0100 |
---|---|---|
committer | Simon Rettberg | 2015-12-04 21:13:36 +0100 |
commit | 19429f6dddb1403b226432cf3118be09962a1d22 (patch) | |
tree | 0f4bcb564a4a6063023e8d9bfe759e8a3915dbf0 | |
parent | JS: Use documentLoaded event where possible (diff) | |
download | slx-admin-19429f6dddb1403b226432cf3118be09962a1d22.tar.gz slx-admin-19429f6dddb1403b226432cf3118be09962a1d22.tar.xz slx-admin-19429f6dddb1403b226432cf3118be09962a1d22.zip |
[statistics] More tweaks, add detailed memory information, show system manufacturer if known
-rw-r--r-- | lang/de/templates/statistics/machine-main.json | 3 | ||||
-rw-r--r-- | lang/en/templates/statistics/machine-main.json | 3 | ||||
-rw-r--r-- | modules/statistics.inc.php | 80 | ||||
-rw-r--r-- | templates/statistics/id44.html | 4 | ||||
-rw-r--r-- | templates/statistics/kvmstate.html | 4 | ||||
-rw-r--r-- | templates/statistics/machine-main.html | 23 | ||||
-rw-r--r-- | templates/statistics/memory.html | 4 |
7 files changed, 112 insertions, 9 deletions
diff --git a/lang/de/templates/statistics/machine-main.json b/lang/de/templates/statistics/machine-main.json index 751ff8c7..a0b2182a 100644 --- a/lang/de/templates/statistics/machine-main.json +++ b/lang/de/templates/statistics/machine-main.json @@ -10,7 +10,10 @@ "lang_lastSeen": "Letzte Aktivit\u00e4t", "lang_macAddr": "MAC-Adresse", "lang_machineSummary": "Zusammenfassung", + "lang_maximumAbbrev": "Max.", + "lang_model": "Modell", "lang_ram": "Arbeitsspeicher", + "lang_ramSlots": "Speicher-Slots", "lang_sockets": "Sockel", "lang_tempPart": "Temp. Partition", "lang_uuid": "UUID", diff --git a/lang/en/templates/statistics/machine-main.json b/lang/en/templates/statistics/machine-main.json index 2aa3b9ba..40ea72f8 100644 --- a/lang/en/templates/statistics/machine-main.json +++ b/lang/en/templates/statistics/machine-main.json @@ -10,7 +10,10 @@ "lang_lastSeen": "Last activity", "lang_macAddr": "MAC address", "lang_machineSummary": "Summary", + "lang_maximumAbbrev": "max.", + "lang_model": "Model", "lang_ram": "Memory", + "lang_ramSlots": "Memory slots", "lang_sockets": "Sockets", "lang_tempPart": "Temp. partition", "lang_uuid": "UUID", diff --git a/modules/statistics.inc.php b/modules/statistics.inc.php index c8c869b9..3e829847 100644 --- a/modules/statistics.inc.php +++ b/modules/statistics.inc.php @@ -356,11 +356,14 @@ class Page_Statistics extends Page $row['hddclass'] = $this->hddColorClass($row['gbtmp']); // Parse the giant blob of data $hdds = array(); - if (preg_match_all('/##### ([^#]+) #+$(.*?)^#####/ims', $row['data'], $out, PREG_SET_ORDER)) { + if (preg_match_all('/##### ([^#]+) #+$(.*?)^#####/ims', $row['data'] . '########', $out, PREG_SET_ORDER)) { foreach ($out as $section) { if ($section[1] === 'CPU') { $this->parseCpu($row, $section[2]); } + if ($section[1] === 'dmidecode') { + $this->parseDmiDecode($row, $section[2]); + } if ($section[1] === 'Partition tables') { $this->parseHdd($hdds, $section[2]); } @@ -384,6 +387,81 @@ class Page_Statistics extends Page } } + private function parseDmiDecode(&$row, $data) + { + $lines = preg_split("/[\r\n]+/", $data); + $section = false; + $ramOk = false; + $ramForm = $ramType = $ramSpeed = $ramClockSpeed = false; + foreach ($lines as $line) { + if ($line{0} !== "\t" && $line{0} !== ' ') { + $section = $line; + $ramOk = false; + if (($ramForm || $ramType) && ($ramSpeed || $ramClockSpeed)) { + if (isset($row['ramtype']) && !$ramClockSpeed) continue; + $row['ramtype'] = $ramType . ' ' . $ramForm; + if ($ramClockSpeed) $row['ramtype'] .= ', ' . $ramClockSpeed; + elseif ($ramSpeed) $row['ramtype'] .= ', ' . $ramSpeed; + $ramForm = false; + $ramType = false; + $ramClockSpeed = false; + } + continue; + } + if ($section === 'System Information' || $section === 'Base Board Information') { + if (empty($row['pcmodel']) && preg_match('/^\s*Product Name: +(\S.+?) *$/i', $line, $out)) { + $row['pcmodel'] = $out[1]; + } + if (empty($row['manufacturer']) && preg_match('/^\s*Manufacturer: +(\S.+?) *$/i', $line, $out)) { + $row['manufacturer'] = $out[1]; + } + } + else if ($section === 'Physical Memory Array') { + if (!$ramOk && preg_match('/Use: System Memory/i', $line)) { + $ramOk = true; + } + if ($ramOk && preg_match('/^\s*Number Of Devices: +(\S.+?) *$/i', $line, $out)) { + $row['ramslotcount'] = $out[1]; + } + if ($ramOk && preg_match('/^\s*Maximum Capacity: +(\S.+?)\s*$/i', $line, $out)) { + $row['maxram'] = preg_replace('/([MGT])B/', '$1iB', $out[1]); + } + } + else if ($section === 'Memory Device') { + if (preg_match('/^\s*Size:\s*(.*?)\s*$/i', $line, $out)) { + $row['extram'] = true; + if (preg_match('/(\d+)\s*(\w)i?B/i', $out[1], $out)) { + $out[2] = strtoupper($out[2]); + if ($out[2] === 'K' || ($out[2] === 'M' && $out[1] < 500)) { + $ramForm = $ramType = $ramSpeed = $ramClockSpeed = false; + continue; + } + if ($out[2] === 'M' && $out[1] >= 1024) { + $out[2] = 'G'; + $out[1] = floor(($out[1] + 100) / 1024); + } + $row['ramslot'][]['size'] = $out[1] . ' ' . strtoupper($out[2]) . 'iB'; + } else if (count($row['ramslot']) < 8 && (!isset($row['ramslotcount']) || $row['ramslotcount'] <= 8)) { + $row['ramslot'][]['size'] = '_____'; + } + } + if (preg_match('/^\s*Form Factor:\s*(.*?)\s*$/i', $line, $out) && $out[1] !== 'Unknown') { + $ramForm = $out[1]; + } + if (preg_match('/^\s*Type:\s*(.*?)\s*$/i', $line, $out) && $out[1] !== 'Unknown') { + $ramType = $out[1]; + } + if (preg_match('/^\s*Speed:\s*(\d.*?)\s*$/i', $line, $out)) { + $ramSpeed = $out[1]; + } + if (preg_match('/^\s*Configured Clock Speed:\s*(\d.*?)\s*$/i', $line, $out)) { + $ramClockSpeed = $out[1]; + } + } + } + if (empty($row['ramslotcount'])) $row['ramslotcount'] = count($row['ramslot']); + } + private function parseHdd(&$row, $data) { $hdds = array(); diff --git a/templates/statistics/id44.html b/templates/statistics/id44.html index d9c92c47..730839b1 100644 --- a/templates/statistics/id44.html +++ b/templates/statistics/id44.html @@ -5,7 +5,7 @@ </div> <div class="panel-body"> <div class="row"> - <div class="col-md-6"> + <div class="col-sm-6"> <table class="table table-condensed table-striped"> <tr> <th>{{lang_partitionSize}}</th> @@ -19,7 +19,7 @@ {{/rows}} </table> </div> - <div class="col-md-6"> + <div class="col-sm-6"> <canvas id="temppartchart" style="width:100%;height:250px"></canvas> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function() { diff --git a/templates/statistics/kvmstate.html b/templates/statistics/kvmstate.html index 5431990c..107a34f7 100644 --- a/templates/statistics/kvmstate.html +++ b/templates/statistics/kvmstate.html @@ -5,7 +5,7 @@ </div> <div class="panel-body"> <div class="row"> - <div class="col-md-6"> + <div class="col-sm-6"> <table class="table table-condensed table-striped"> <tr> <th>{{lang_kvmState}}</th> @@ -19,7 +19,7 @@ {{/rows}} </table> </div> - <div class="col-md-6"> + <div class="col-sm-6"> <canvas id="kvmchart" style="width:100%;height:250px"></canvas> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function() { diff --git a/templates/statistics/machine-main.html b/templates/statistics/machine-main.html index 985194bf..52e0aee8 100644 --- a/templates/statistics/machine-main.html +++ b/templates/statistics/machine-main.html @@ -63,10 +63,29 @@ {{/Sockets}} </td> </tr> + <tr> + <td>{{lang_model}}</td> + <td>{{pcmodel}} ({{manufacturer}})</td> + </tr> <tr class="{{ramclass}}"> <td>{{lang_ram}}</td> - <td>{{gbram}} GiB</td> + <td> + {{gbram}} GiB + {{#maxram}}({{lang_maximumAbbrev}} {{maxram}}){{/maxram}} + {{ramtype}} + </td> + </tr> + {{#extram}} + <tr> + <td>{{lang_ramSlots}}</td> + <td> + {{ramslotcount}}: + {{#ramslot}} + [ {{size}} ] + {{/ramslot}} + </td> </tr> + {{/extram}} <tr class="{{hddclass}}"> <td>{{lang_tempPart}}</td> <td>{{gbtmp}} GiB</td> @@ -79,4 +98,4 @@ </div> </div> </div> -</div>
\ No newline at end of file +</div> diff --git a/templates/statistics/memory.html b/templates/statistics/memory.html index 1ebfbae0..f4d2ad24 100644 --- a/templates/statistics/memory.html +++ b/templates/statistics/memory.html @@ -5,7 +5,7 @@ </div> <div class="panel-body"> <div class="row"> - <div class="col-md-6"> + <div class="col-sm-6"> <table class="table table-condensed table-striped"> <tr> <th>{{lang_ramSize}}</th> @@ -19,7 +19,7 @@ {{/rows}} </table> </div> - <div class="col-md-6"> + <div class="col-sm-6"> <canvas id="ramsizechart" style="width:100%;height:250px"></canvas> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function() { |