From 0746d3c815fa5dffe8ed766043cb996e5e2ce581 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Mon, 20 Nov 2017 14:30:31 +0100 Subject: [statistics&syslog] Changed ip to machine-uuid for filtering. Fixed a bug where the client-log was losing the specific client when a filter was added. --- modules-available/statistics/page.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules-available/statistics/page.inc.php') diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 479f3089..f8b40405 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -920,7 +920,7 @@ class Page_Statistics extends Page } } Render::addTemplate('syslog', array( - 'clientip' => $client['clientip'], + 'machineuuid' => $client['machineuuid'], 'list' => $log, )); } -- cgit v1.2.3-55-g7522 From ec10851584b4be86add55b571e56c79afe97975f Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 23 Nov 2017 13:00:55 +0100 Subject: [statistics] Filter 'state' was missing in the client statistics filter --- modules-available/statistics/page.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules-available/statistics/page.inc.php') diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index f8b40405..575c5c19 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -106,6 +106,12 @@ class Page_Statistics extends Page 'op' => Page_Statistics::$op_nominal, 'type' => 'string', 'column' => true + ], + 'state' => [ + 'op' => Page_Statistics::$op_nominal, + 'type' => 'enum', + 'column' => true, + 'values' => ['occupied', 'on'] ] ]; if (Module::isAvailable('locations')) { @@ -211,7 +217,6 @@ class Page_Statistics extends Page $sortColumn = Request::any('sortColumn'); $sortDirection = Request::any('sortDirection'); $filters = Filter::parseQuery($this->query); - $filterSet = new FilterSet($filters); $filterSet->setSort($sortColumn, $sortDirection); -- cgit v1.2.3-55-g7522 From 23d8c6fc0c3b031aa081ee1a245f9b0792514fd3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 28 Nov 2017 16:41:33 +0100 Subject: [statistics] Introduce state column to get rid of complicated state determination This also adds support for the STANDBY state --- .../locationinfo/inc/infopanel.inc.php | 4 +- .../locationinfo/inc/locationinfo.inc.php | 12 +- .../locationinfo/templates/frontend-default.html | 4 +- .../rebootcontrol/inc/rebootqueries.inc.php | 10 +- .../runmode/templates/machine-selector.html | 15 +- modules-available/statistics/api.inc.php | 190 +++++++++++++++------ modules-available/statistics/hooks/cron.inc.php | 18 +- modules-available/statistics/inc/filter.inc.php | 20 +-- modules-available/statistics/install.inc.php | 20 ++- modules-available/statistics/page.inc.php | 30 +--- .../statistics/templates/clientlist.html | 17 +- .../statistics/templates/machine-main.html | 15 +- 12 files changed, 226 insertions(+), 129 deletions(-) (limited to 'modules-available/statistics/page.inc.php') diff --git a/modules-available/locationinfo/inc/infopanel.inc.php b/modules-available/locationinfo/inc/infopanel.inc.php index 66ee0ae7..c612e518 100644 --- a/modules-available/locationinfo/inc/infopanel.inc.php +++ b/modules-available/locationinfo/inc/infopanel.inc.php @@ -81,7 +81,7 @@ class InfoPanel } $positionCol = $withPosition ? 'm.position,' : ''; - $query = "SELECT m.locationid, m.machineuuid, $positionCol m.logintime, m.lastseen, m.lastboot FROM machine m + $query = "SELECT m.locationid, m.machineuuid, $positionCol m.logintime, m.lastseen, m.lastboot, m.state FROM machine m WHERE m.locationid IN (:idlist)"; $dbquery = Database::simpleQuery($query, array('idlist' => $idList)); @@ -107,7 +107,7 @@ class InfoPanel } } $pc['pcState'] = LocationInfo::getPcState($row); - //$pc['pcState'] = ['BROKEN', 'OFF', 'IDLE', 'OCCUPIED'][mt_rand(0,3)]; // XXX + //$pc['pcState'] = ['BROKEN', 'OFFLINE', 'IDLE', 'OCCUPIED', 'STANDBY'][mt_rand(0,4)]; // XXX // Add the array to the machines list. $array[$row['locationid']]['machines'][] = $pc; diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 830fb050..933eaf4d 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -6,7 +6,7 @@ class LocationInfo /** * Gets the pc data and returns it's state. * - * @param array $pc The pc data from the db. Array('logintime' =>, 'lastseen' =>, 'lastboot' =>) + * @param array $pc The pc data from the db. Array('state' => xx, 'lastseen' => xxx) * @return int pc state */ public static function getPcState($pc) @@ -16,16 +16,10 @@ class LocationInfo $lastboot = (int)$pc['lastboot']; $NOW = time(); - if ($NOW - $lastseen > 14 * 86400) { + if ($pc['state'] === 'OFFLINE' && $NOW - $lastseen > 21 * 86400) { return "BROKEN"; - } elseif (($NOW - $lastseen > 610) || $lastboot === 0) { - return "OFF"; - } elseif ($logintime === 0) { - return "IDLE"; - } elseif ($logintime > 0) { - return "OCCUPIED"; } - return -1; + return $pc['state']; } /** diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html index fc9c3eac..e199fc36 100755 --- a/modules-available/locationinfo/templates/frontend-default.html +++ b/modules-available/locationinfo/templates/frontend-default.html @@ -29,7 +29,7 @@ optional: -