summaryrefslogtreecommitdiffstats
path: root/modules/statistics.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2015-12-07 17:41:42 +0100
committerSimon Rettberg2015-12-07 17:41:42 +0100
commitd2202c4b1b365ad6d318352950ee3331846c6a11 (patch)
treecc801702fbcd91385139d554ccb625ef7e30a34e /modules/statistics.inc.php
parent[statistics] More tweaks, add detailed memory information, show system manufa... (diff)
downloadslx-admin-d2202c4b1b365ad6d318352950ee3331846c6a11.tar.gz
slx-admin-d2202c4b1b365ad6d318352950ee3331846c6a11.tar.xz
slx-admin-d2202c4b1b365ad6d318352950ee3331846c6a11.zip
[statistics] Show PC status (on/off/inuse)
Diffstat (limited to 'modules/statistics.inc.php')
-rw-r--r--modules/statistics.inc.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/modules/statistics.inc.php b/modules/statistics.inc.php
index 3e829847..16161d9f 100644
--- a/modules/statistics.inc.php
+++ b/modules/statistics.inc.php
@@ -273,10 +273,18 @@ class Page_Statistics extends Page
. " logintime, lastboot, realcores, mbram, kvmstate, cpumodel, id44mb, hostname, notes IS NOT NULL AS hasnotes FROM machine"
. " WHERE $where ORDER BY lastseen DESC, clientip ASC", $args);
$rows = array();
+ $NOW = time();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $row['firstseen'] = date('d.m.Y H:i', $row['firstseen']);
+ if ($NOW - $row['lastseen'] > 610) {
+ $row['state_off'] = true;
+ } elseif ($NOW - $row['logintime'] > 610) {
+ $row['state_idle'] = true;
+ } else {
+ $row['state_occupied'] = true;
+ }
+ //$row['firstseen'] = date('d.m.Y H:i', $row['firstseen']);
$row['lastseen'] = date('d.m. H:i', $row['lastseen']);
- $row['lastboot'] = date('d.m. H:i', $row['lastboot']);
+ //$row['lastboot'] = date('d.m. H:i', $row['lastboot']);
$row['gbram'] = round(round($row['mbram'] / 500) / 2, 1); // Trial and error until we got "expected" rounding..
$row['gbtmp'] = round($row['id44mb'] / 1024);
$octets = explode('.', $row['clientip']);
@@ -346,6 +354,14 @@ class Page_Statistics extends Page
. " mbram, kvmstate, cpumodel, id44mb, data, hostname, notes FROM machine WHERE machineuuid = :uuid",
array('uuid' => $uuid));
// Mangle fields
+ $NOW = time();
+ if ($NOW - $row['lastseen'] > 610) {
+ $row['state_off'] = true;
+ } elseif ($NOW - $row['logintime'] > 610) {
+ $row['state_idle'] = true;
+ } else {
+ $row['state_occupied'] = true;
+ }
$row['firstseen'] = date('d.m.Y H:i', $row['firstseen']);
$row['lastseen'] = date('d.m.Y H:i', $row['lastseen']);
$row['lastboot'] = date('d.m.Y H:i', $row['lastboot']);
@@ -394,6 +410,7 @@ class Page_Statistics extends Page
$ramOk = false;
$ramForm = $ramType = $ramSpeed = $ramClockSpeed = false;
foreach ($lines as $line) {
+ if (empty($line)) continue;
if ($line{0} !== "\t" && $line{0} !== ' ') {
$section = $line;
$ramOk = false;
@@ -441,7 +458,7 @@ class Page_Statistics extends Page
$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)) {
+ } else if (!isset($row['ramslot']) || (count($row['ramslot']) < 8 && (!isset($row['ramslotcount']) || $row['ramslotcount'] <= 8))) {
$row['ramslot'][]['size'] = '_____';
}
}