summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
authorSimon Rettberg2022-11-15 17:21:05 +0100
committerSimon Rettberg2022-11-15 17:21:05 +0100
commit5db4480e30bbdaba680dfde36b2fdc258b17844c (patch)
treea25c38cd6edb9f217c4b27418f3f129357c3a501 /modules-available/statistics
parent[inc/Dictionary] Add locale-aware number formatting method (diff)
downloadslx-admin-5db4480e30bbdaba680dfde36b2fdc258b17844c.tar.gz
slx-admin-5db4480e30bbdaba680dfde36b2fdc258b17844c.tar.xz
slx-admin-5db4480e30bbdaba680dfde36b2fdc258b17844c.zip
[statistics] Add NIC Speed to client list, switch to Dictionary::number()
Diffstat (limited to 'modules-available/statistics')
-rw-r--r--modules-available/statistics/pages/list.inc.php20
-rw-r--r--modules-available/statistics/templates/clientlist.html17
2 files changed, 30 insertions, 7 deletions
diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php
index ce686d56..db5f262a 100644
--- a/modules-available/statistics/pages/list.inc.php
+++ b/modules-available/statistics/pages/list.inc.php
@@ -54,6 +54,13 @@ class SubPage
AND mxx.disconnecttime = 0 AND mxx.machineuuid IN (:ids))
GROUP BY mxx.machineuuid",
['type' => HardwareInfo::HDD, 'ids' => $uuids]);
+ $machineNicSpeed = Database::queryKeyValueList("SELECT mxx.machineuuid, Max(mxhp.`numeric`) AS num
+ FROM statistic_hw s
+ INNER JOIN machine_x_hw AS mxx ON (s.hwid = mxx.hwid AND s.hwtype = :type
+ AND mxx.disconnecttime = 0 AND mxx.machineuuid IN (:ids))
+ INNER JOIN machine_x_hw_prop mxhp ON (mxx.machinehwid = mxhp.machinehwid AND mxhp.prop = :prop)
+ GROUP BY mxx.machineuuid",
+ ['type' => HardwareInfo::MAINBOARD, 'prop' => 'nic-speed', 'ids' => $uuids]);
$machineWithConfigOverrides = Database::queryKeyValueList("SELECT machineuuid, Count(machineuuid) AS num
FROM setting_machine WHERE machineuuid IN (:ids) GROUP BY machineuuid", ['ids' => $uuids]);
// TODO: Cannot disable checkbox for those where user has no permission, since we got multiple actions now
@@ -76,9 +83,9 @@ class SubPage
$row['lastseen_int'] = $row['lastseen'];
$row['lastseen'] = Util::prettyTime($row['lastseen']);
//$row['lastboot'] = Util::prettyTime($row['lastboot']);
- $row['gbram'] = round(ceil($row['mbram'] / 512) / 2, 1); // Trial and error until we got "expected" rounding..
- $row['gbtmp'] = round($row['id44mb'] / 1024);
- $row['gbpersist'] = round($row['id45mb'] / 1024);
+ $row['gbram'] = Dictionary::number(ceil($row['mbram'] / 512) / 2, 1); // Trial and error until we got "expected" rounding..
+ $row['gbtmp'] = Dictionary::number($row['id44mb'] / 1024);
+ $row['gbpersist'] = Dictionary::number($row['id45mb'] / 1024);
$octets = explode('.', $row['clientip']);
if (count($octets) === 4) {
$row['subnet'] = "$octets[0].$octets[1].$octets[2]";
@@ -100,6 +107,13 @@ class SubPage
// If we have ID44 space in our main table, we most likely got an HDD, so fake a count of 1
$row['hddcount'] = 1;
}
+ if (!isset($machineNicSpeed[$row['machineuuid']])) {
+ $row['nic-speed'] = 0;
+ $row['nic-speed_s'] = '???';
+ } else {
+ $row['nic-speed'] = $machineNicSpeed[$row['machineuuid']];
+ $row['nic-speed_s'] = Dictionary::number($machineNicSpeed[$row['machineuuid']]);
+ }
if (isset($row['data']) && !$row['data']) {
$row['nohdd'] = true;
}
diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html
index b33eafa3..714fdfc0 100644
--- a/modules-available/statistics/templates/clientlist.html
+++ b/modules-available/statistics/templates/clientlist.html
@@ -13,6 +13,11 @@
<td></td>
<td></td>
<td class="text-right">
+ <button type="button" class="btn btn-default btn-xs" onclick="popupFilter('nicspeed')">
+ <span class="glyphicon glyphicon-filter"></span>
+ </button>
+ </td>
+ <td class="text-right">
<button type="button" class="btn btn-default btn-xs" onclick="popupFilter('lastseen')">
<span class="glyphicon glyphicon-filter"></span>
</button>
@@ -53,6 +58,7 @@
{{lang_machine}}
</th>
<th data-sort="ipv4">{{lang_address}}</th>
+ <th data-sort="int" class="text-right">{{lang_nicSpeed}}</th>
<th data-sort="int" class="text-right">{{lang_lastSeen}}</th>
<th data-sort="string">{{lang_kvmSupport}}</th>
<th data-sort="int" class="text-right">{{lang_gbRam}}</th>
@@ -123,14 +129,17 @@
{{/currentuser}}
</td>
<td data-sort-value="{{clientip}}">
- <b><a href="?do=Statistics&amp;show=list&amp;filters=clientip={{subnet}}/24">{{subnet}}.</a>{{lastoctet}}</b>
+ <b><a href="?do=statistics&amp;show=list&amp;filters=clientip={{subnet}}/24">{{subnet}}.</a>{{lastoctet}}</b>
<div class="mac text-nowrap">{{macaddr}}</div>
<div class="hidden ip">{{clientip}}</div>
</td>
+ <td data-sort-value="{{nic-speed}}" class="text-right">
+ {{nic-speed_s}}&thinsp;MBit/s
+ </td>
<td data-sort-value="{{lastseen_int}}" class="text-right text-nowrap">{{lastseen}}</td>
<td class="{{kvmclass}}">{{kvmstate}}</td>
- <td data-sort-value="{{gbram}}" class="text-right {{ramclass}}">{{gbram}}&thinsp;GiB</td>
- <td data-sort-value="{{gbtmp}}" class="text-right {{hddclass}}">
+ <td data-sort-value="{{mbram}}" class="text-right {{ramclass}}">{{gbram}}&thinsp;GiB</td>
+ <td data-sort-value="{{id44mb}}" class="text-right {{hddclass}}">
{{gbtmp}}&thinsp;GiB
{{#badsectors}}<div><span data-toggle="tooltip" title="{{lang_reallocatedSectors}}" data-placement="left">
<span class="glyphicon glyphicon-exclamation-sign"></span>
@@ -146,7 +155,7 @@
</span>
</div>{{/hddcount}}
</td>
- <td data-sort-value="{{gbpersist}}" class="text-right">
+ <td data-sort-value="{{id45mb}}" class="text-right">
{{gbpersist}}&thinsp;GiB
</td>
<td data-sort-value="{{realcores}}">{{lang_realCores}}: {{realcores}}<div class="small">{{cpumodel}}</div></td>