From a8b0095b335780ae0bb950bc44021215d43a6b2d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 12 Feb 2018 14:17:07 +0100 Subject: [permissionmanager] Introduce "location-aware" flag for permissions This flag tells wether the permission can be restricted to certain locations in a meaningful way. This flag has to be set in the permissions.json of the according module. For example, the permission to reboot the server cannot be limited to certain locations in a meaningful way, while the view of the client log can be filtered to only show log entries for clients in specific locations. --- .../statistics/permissions/permissions.json | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/permissions/permissions.json b/modules-available/statistics/permissions/permissions.json index 97a49036..c9dca9f3 100644 --- a/modules-available/statistics/permissions/permissions.json +++ b/modules-available/statistics/permissions/permissions.json @@ -1,5 +1,11 @@ -[ - "view", - "note", - "delete" -] \ No newline at end of file +{ + "machine.delete": { + "location-aware": true + }, + "machine.note": { + "location-aware": true + }, + "machine.view": { + "location-aware": true + } +} \ No newline at end of file -- cgit v1.2.3-55-g7522 From 6d6c65db4a41c952689fa01cfbf31b424b817929 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 12 Feb 2018 18:09:08 +0100 Subject: [statistics] Rename permissions a bit --- modules-available/statistics/lang/de/permissions.json | 8 ++++---- modules-available/statistics/lang/en/permissions.json | 8 ++++---- modules-available/statistics/page.inc.php | 8 ++++---- modules-available/statistics/permissions/permissions.json | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/lang/de/permissions.json b/modules-available/statistics/lang/de/permissions.json index 15303993..7b7db89a 100644 --- a/modules-available/statistics/lang/de/permissions.json +++ b/modules-available/statistics/lang/de/permissions.json @@ -1,5 +1,5 @@ { - "view": "Client Statistiken anschauen.", - "note": "Client Notizen speichern.", - "delete": "Client löschen." -} \ No newline at end of file + "view": "Statistiken anschauen.", + "machine.note": "Anmerkungen zu einem Rechner speichern.", + "machine.delete": "Rechner löschen." +} diff --git a/modules-available/statistics/lang/en/permissions.json b/modules-available/statistics/lang/en/permissions.json index 7be32f22..01acdb8a 100644 --- a/modules-available/statistics/lang/en/permissions.json +++ b/modules-available/statistics/lang/en/permissions.json @@ -1,5 +1,5 @@ { - "view": "View client statistics.", - "note": "Save client notes.", - "delete": "Delete client." -} \ No newline at end of file + "view": "View statistics.", + "machine.note": "Save client notes.", + "machine.delete": "Delete clients." +} diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 5fe4ebfa..e89180ed 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -170,7 +170,7 @@ class Page_Statistics extends Page $uuid = Request::post('uuid', '', 'string'); $locationid = Database::queryFirst('SELECT locationid FROM machine WHERE machineuuid = :uuid', array('uuid' => $uuid))['locationid']; - if (User::hasPermission("note", $locationid)) { + if (User::hasPermission("machine.note", $locationid)) { $text = Request::post('content', '', 'string'); if (empty($text)) { $text = null; @@ -207,7 +207,7 @@ class Page_Statistics extends Page $res = Database::simpleQuery('SELECT machineuuid, locationid FROM machine WHERE machineuuid IN (:ids)', compact('ids')); $ids = array_flip($ids); $delete = []; - $allowedLocations = User::getAllowedLocations("delete"); + $allowedLocations = User::getAllowedLocations("machine.delete"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if (in_array($row['locationid'], $allowedLocations)) { unset($ids[$row['machineuuid']]); @@ -629,7 +629,7 @@ class Page_Statistics extends Page . " $join WHERE $where $sort", $args); $rows = array(); $singleMachine = 'none'; - $deleteAllowedLocations = User::getAllowedLocations("delete"); + $deleteAllowedLocations = User::getAllowedLocations("machine.delete"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ($singleMachine === 'none') { $singleMachine = $row['machineuuid']; @@ -1002,7 +1002,7 @@ class Page_Statistics extends Page )); } // Notes - $client["notesAllowed"] = User::hasPermission("note", $client["locationid"]); + $client["notesAllowed"] = User::hasPermission("machine.note", $client["locationid"]); Render::addTemplate('machine-notes', $client); } diff --git a/modules-available/statistics/permissions/permissions.json b/modules-available/statistics/permissions/permissions.json index c9dca9f3..da489998 100644 --- a/modules-available/statistics/permissions/permissions.json +++ b/modules-available/statistics/permissions/permissions.json @@ -5,7 +5,7 @@ "machine.note": { "location-aware": true }, - "machine.view": { + "view": { "location-aware": true } } \ No newline at end of file -- cgit v1.2.3-55-g7522 From aadf3feb7b8090796a4dd083c90a5bc4893c8faf Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sun, 4 Mar 2018 16:42:05 +0100 Subject: [statistics] Refine permissions, add some new ones --- modules-available/statistics/inc/filter.inc.php | 9 +- modules-available/statistics/inc/filterset.inc.php | 82 ++++++++++-- modules-available/statistics/page.inc.php | 139 ++++++++++++--------- .../statistics/pages/projectors.inc.php | 2 + .../statistics/permissions/permissions.json | 19 ++- .../statistics/templates/clientlist.html | 18 +-- .../statistics/templates/cpumodels.html | 4 +- .../statistics/templates/filterbox.html | 6 +- modules-available/statistics/templates/id44.html | 2 +- .../statistics/templates/kvmstate.html | 2 +- .../statistics/templates/machine-main.html | 12 +- .../statistics/templates/machine-notes.html | 7 +- modules-available/statistics/templates/memory.html | 2 +- .../statistics/templates/summary.html | 4 +- 14 files changed, 207 insertions(+), 101 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index f6765059..565ea5f0 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -18,7 +18,7 @@ class Filter { $this->column = trim($column); $this->operator = trim($operator); - $this->argument = trim($argument); + $this->argument = is_array($argument) ? $argument : trim($argument); } /* returns a where clause and adds needed operators to the passed array */ @@ -245,7 +245,12 @@ class LocationFilter extends Filter $recursive = (substr($this->operator, -1) === '~'); $this->operator = str_replace('~', '=', $this->operator); - settype($this->argument, 'int'); + if (is_array($this->argument)) { + if ($recursive) + Util::traceError('Cannot use ~ operator for location with array'); + } else { + settype($this->argument, 'int'); + } $neg = $this->operator === '=' ? '' : 'NOT'; if ($this->argument === 0) { return "machine.locationid IS $neg NULL"; diff --git a/modules-available/statistics/inc/filterset.inc.php b/modules-available/statistics/inc/filterset.inc.php index 25c5c8fa..774bfd18 100644 --- a/modules-available/statistics/inc/filterset.inc.php +++ b/modules-available/statistics/inc/filterset.inc.php @@ -9,6 +9,8 @@ class FilterSet private $sortDirection; private $sortColumn; + private $cache = false; + public function __construct($filters) { $this->filters = $filters; @@ -16,19 +18,28 @@ class FilterSet public function setSort($col, $direction) { - $this->sortDirection = $direction === 'DESC' ? 'DESC' : 'ASC'; + $direction = ($direction === 'DESC' ? 'DESC' : 'ASC'); - if (is_string($col) && array_key_exists($col, Page_Statistics::$columns)) { - $this->sortColumn = $col; - } else { + if (!is_string($col) || !array_key_exists($col, Page_Statistics::$columns)) { /* default sorting column is clientip */ - $this->sortColumn = 'clientip'; + $col = 'clientip'; } - + if ($col === $this->sortColumn && $direction === $this->sortDirection) + return; + $this->cache = false; + $this->sortDirection = $direction; + $this->sortColumn = $col; } public function makeFragments(&$where, &$join, &$sort, &$args) { + if ($this->cache !== false) { + $where = $this->cache['where']; + $join = $this->cache['join']; + $sort = $this->cache['sort']; + $args = $this->cache['args']; + return; + } /* generate where clause & arguments */ $where = ''; $joins = []; @@ -54,16 +65,13 @@ class FilterSet $sort = " ORDER BY " . $concreteCol . " " . $this->sortDirection . ", machineuuid ASC"; + $this->cache = compact('where', 'join', 'sort', 'args'); } public function isNoId44Filter() { - foreach ($this->filters as $filter) { - if (get_class($filter) === 'Id44Filter' && $filter->argument == 0) { - return true; - } - } - return false; + $filter = $this->hasFilter('Id44Filter'); + return $filter !== false && $filter->argument == 0; } public function getSortDirection() @@ -78,10 +86,58 @@ class FilterSet public function filterNonClients() { - if (Module::get('runmode') === false) + if (Module::get('runmode') === false || $this->hasFilter('IsClientFilter') !== false) return; + $this->cache = false; // Runmode module exists, add filter $this->filters[] = new IsClientFilter(true); } + /** + * @param string $type filter type (class name) + * @return false|Filter The filter, false if not found + */ + public function hasFilter($type) + { + foreach ($this->filters as $filter) { + if (get_class($filter) === $type) { + return $filter; + } + } + return false; + } + + /** + * Add a location filter based on the allowed permissions for the given permission. + * Returns false if the user doesn't have the given permission for any location. + * + * @param string $permission permission to use + * @return bool false if no permission for any location, true otherwise + */ + public function setAllowedLocationsFromPermission($permission) + { + $locs = User::getAllowedLocations($permission); + if (empty($locs)) + return false; + if (in_array(0, $locs)) { + if (!isset($this->filters['permissions'])) + return true; + unset($this->filters['permissions']); + } else { + $this->filters['permissions'] = new LocationFilter('=', $locs); + } + $this->cache = false; + return true; + } + + /** + * @return false|array + */ + public function getAllowedLocations() + { + if (isset($this->filters['permissions']->argument) && is_array($this->filters['permissions']->argument)) + return $this->filters['permissions']->argument; + return false; + } + } diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index e89180ed..3baac190 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -20,8 +20,7 @@ class Page_Statistics extends Page public static $columns; private $query; - - private $locationsAllowedToView; + private $show; /** * @var bool whether we have a SubPage from the pages/ subdir @@ -151,15 +150,23 @@ class Page_Statistics extends Page Util::redirect('?do=Main'); } - $this->locationsAllowedToView = User::getAllowedLocations("view"); - - - $show = Request::any('show', 'stat', 'string'); - $show = preg_replace('/[^a-z0-9_\-]/', '', $show); + $this->show = Request::any('show', false, 'string'); + if ($this->show === false) { + if (User::hasPermission('view.summary')) { + $this->show = 'summary'; + } elseif (User::hasPermission('view.list')) { + $this->show = 'list'; + } else { + Message::addError('main.no-permission'); + Util::redirect('?do=main'); + } + } else { + $this->show = preg_replace('/[^a-z0-9_\-]/', '', $this->show); + } - if (file_exists('modules/statistics/pages/' . $show . '.inc.php')) { + if (file_exists('modules/statistics/pages/' . $this->show . '.inc.php')) { - require_once 'modules/statistics/pages/' . $show . '.inc.php'; + require_once 'modules/statistics/pages/' . $this->show . '.inc.php'; $this->haveSubpage = true; SubPage::doPreprocess(); @@ -168,20 +175,23 @@ class Page_Statistics extends Page $action = Request::post('action'); if ($action === 'setnotes') { $uuid = Request::post('uuid', '', 'string'); - $locationid = Database::queryFirst('SELECT locationid FROM machine WHERE machineuuid = :uuid', - array('uuid' => $uuid))['locationid']; - if (User::hasPermission("machine.note", $locationid)) { - $text = Request::post('content', '', 'string'); - if (empty($text)) { - $text = null; - } - Database::exec('UPDATE machine SET notes = :text WHERE machineuuid = :uuid', array( - 'uuid' => $uuid, - 'text' => $text, - )); - Message::addSuccess('notes-saved'); - Util::redirect('?do=Statistics&uuid=' . $uuid); + $res = Database::queryFirst('SELECT locationid FROM machine WHERE machineuuid = :uuid', + array('uuid' => $uuid)); + if ($res === false) { + Message::addError('unknown-machine', $uuid); + Util::redirect('?do=statistics'); + } + User::assertPermission("machine.note.edit", (int)$res['locationid']); + $text = Request::post('content', null, 'string'); + if (empty($text)) { + $text = null; } + Database::exec('UPDATE machine SET notes = :text WHERE machineuuid = :uuid', array( + 'uuid' => $uuid, + 'text' => $text, + )); + Message::addSuccess('notes-saved'); + Util::redirect('?do=statistics&uuid=' . $uuid); } elseif ($action === 'delmachines') { $this->deleteMachines(); Util::redirect('?do=statistics', true); @@ -204,14 +214,20 @@ class Page_Statistics extends Page Message::addError('main.parameter-empty', 'uuid'); return; } + $allowedLocations = User::getAllowedLocations("machine.delete"); + if (empty($allowedLocations)) { + Message::addError('main.no-permission'); + Util::redirect('?do=statistics'); + } $res = Database::simpleQuery('SELECT machineuuid, locationid FROM machine WHERE machineuuid IN (:ids)', compact('ids')); $ids = array_flip($ids); $delete = []; - $allowedLocations = User::getAllowedLocations("machine.delete"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + unset($ids[$row['machineuuid']]); if (in_array($row['locationid'], $allowedLocations)) { - unset($ids[$row['machineuuid']]); $delete[] = $row['machineuuid']; + } else { + Message::addError('no-permission-location', $row['locationid']); } } if (!empty($delete)) { @@ -219,7 +235,6 @@ class Page_Statistics extends Page Message::addSuccess('deleted-n-machines', count($delete)); } if (!empty($ids)) { - // TODO: Warn permissions Message::addWarning('unknown-machine', implode(', ', array_keys($ids))); } } @@ -237,8 +252,6 @@ class Page_Statistics extends Page return; } - $show = Request::get('show', 'stat', 'string'); - /* read filter */ $this->query = Request::any('filters', false); if ($this->query === false) { @@ -251,23 +264,31 @@ class Page_Statistics extends Page $filterSet = new FilterSet($filters); $filterSet->setSort($sortColumn, $sortDirection); - if ($show == 'list') { + if (!$filterSet->setAllowedLocationsFromPermission('view.' . $this->show)) { + Message::addError('main.no-permission'); + Util::redirect('?do=statistics'); + } + + if ($this->show === 'list') { Render::openTag('div', array('class' => 'row')); $this->showFilter('list', $filterSet); Render::closeTag('div'); $this->showMachineList($filterSet); return; + } elseif ($this->show === 'summary') { + $filterSet->filterNonClients(); + Render::openTag('div', array('class' => 'row')); + $this->showFilter('summary', $filterSet); + $this->showSummary($filterSet); + $this->showMemory($filterSet); + $this->showId44($filterSet); + $this->showKvmState($filterSet); + $this->showLatestMachines($filterSet); + $this->showSystemModels($filterSet); + Render::closeTag('div'); + } else { + Message::addError('main.value-invalid', 'show', $this->show); } - $filterSet->filterNonClients(); - Render::openTag('div', array('class' => 'row')); - $this->showFilter('stat', $filterSet); - $this->showSummary($filterSet); - $this->showMemory($filterSet); - $this->showId44($filterSet); - $this->showKvmState($filterSet); - $this->showLatestMachines($filterSet); - $this->showSystemModels($filterSet); - Render::closeTag('div'); } /** @@ -295,15 +316,17 @@ class Page_Statistics extends Page $locsFlat = array(); if (Module::isAvailable('locations')) { + $allowed = $filterSet->getAllowedLocations(); foreach (Location::getLocations() as $loc) { $locsFlat['L' . $loc['locationid']] = array( 'pad' => $loc['locationpad'], 'name' => $loc['locationname'], - 'disabled' => !in_array($loc['locationid'], $this->locationsAllowedToView) + 'disabled' => $allowed !== false && !in_array($loc['locationid'], $allowed), ); } } + Permission::addGlobalTags($data['perms'], null, ['view.summary', 'view.list']); $data['locations'] = json_encode($locsFlat); Render::addTemplate('filterbox', $data); @@ -355,8 +378,6 @@ class Page_Statistics extends Page private function showSummary($filterSet) { $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $known = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE $where", $args); // If we only have one machine, redirect to machine details if ($known['val'] == 1) { @@ -417,8 +438,6 @@ class Page_Statistics extends Page global $STATS_COLORS; $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $res = Database::simpleQuery('SELECT systemmodel, Round(AVG(realcores)) AS cores, Count(*) AS `count` FROM machine' . " $join WHERE $where GROUP BY systemmodel ORDER BY `count` DESC, systemmodel ASC", $args); $lines = array(); @@ -451,8 +470,6 @@ class Page_Statistics extends Page global $STATS_COLORS, $SIZE_RAM; $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $res = Database::simpleQuery("SELECT mbram, Count(*) AS `count` FROM machine $join WHERE $where GROUP BY mbram", $args); $lines = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { @@ -498,8 +515,6 @@ class Page_Statistics extends Page private function showKvmState($filterSet) { $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $colors = array('UNKNOWN' => '#666', 'UNSUPPORTED' => '#ea5', 'DISABLED' => '#e55', 'ENABLED' => '#6d6'); $res = Database::simpleQuery("SELECT kvmstate, Count(*) AS `count` FROM machine $join WHERE $where GROUP BY kvmstate ORDER BY `count` DESC", $args); $lines = array(); @@ -523,8 +538,6 @@ class Page_Statistics extends Page global $STATS_COLORS, $SIZE_ID44; $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $res = Database::simpleQuery("SELECT id44mb, Count(*) AS `count` FROM machine $join WHERE $where GROUP BY id44mb", $args); $lines = array(); $total = 0; @@ -576,8 +589,6 @@ class Page_Statistics extends Page private function showLatestMachines($filterSet) { $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $args['cutoff'] = ceil(time() / 3600) * 3600 - 86400 * 10; $res = Database::simpleQuery("SELECT machineuuid, clientip, hostname, firstseen, mbram, kvmstate, id44mb FROM machine $join" @@ -611,8 +622,6 @@ class Page_Statistics extends Page { Module::isAvailable('js_stupidtable'); $filterSet->makeFragments($where, $join, $sort, $args); - $args['allowedLocations'] = $this->locationsAllowedToView; - $where = "locationid IN (:allowedLocations) AND ($where)"; $xtra = ''; if ($filterSet->isNoId44Filter()) { $xtra .= ', data'; @@ -630,13 +639,16 @@ class Page_Statistics extends Page $rows = array(); $singleMachine = 'none'; $deleteAllowedLocations = User::getAllowedLocations("machine.delete"); + $detailsAllowedLocations = User::getAllowedLocations("machine.view-details"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ($singleMachine === 'none') { $singleMachine = $row['machineuuid']; } else { $singleMachine = false; } - $row['deleteAllowed'] = in_array($row['locationid'], $deleteAllowedLocations); + // TODO: This only makes sense as long as there is only one action to perform on selected clients; reboot/shutdown is planned + $row['delete_disabled'] = in_array($row['locationid'], $deleteAllowedLocations) ? '' : 'disabled'; + $row['link_details'] = in_array($row['locationid'], $detailsAllowedLocations); $row['state_' . $row['state']] = true; //$row['firstseen'] = Util::prettyTime($row['firstseen']); $row['lastseen_int'] = $row['lastseen']; @@ -673,7 +685,7 @@ class Page_Statistics extends Page if ($singleMachine !== false && $singleMachine !== 'none') { Util::redirect('?do=statistics&uuid=' . $singleMachine); } - Render::addTemplate('clientlist', array( + $data = array( 'rowCount' => count($rows), 'rows' => $rows, 'query' => $this->query, @@ -684,7 +696,8 @@ class Page_Statistics extends Page 'showList' => 1, 'show' => 'list', 'redirect' => $_SERVER['QUERY_STRING'] - )); + ); + Render::addTemplate('clientlist', $data); } private function ramColorClass($mb) @@ -787,10 +800,7 @@ class Page_Statistics extends Page Message::addError('unknown-machine', $uuid); return; } - if (!in_array($client['locationid'], $this->locationsAllowedToView)) { - Message::addError('main.no-permission'); - return; - } + User::assertPermission('machine.view-details', (int)$client['locationid']); // Hack: Get raw collected data if (Request::get('raw', false)) { Header('Content-Type: text/plain; charset=utf-8'); @@ -891,6 +901,7 @@ class Page_Statistics extends Page $client['screens'][] = $row; } array_multisort($ports, SORT_ASC, $client['screens']); + Permission::addGlobalTags($client['perms'], null, ['hardware.projectors.edit', 'hardware.projectors.view']); // Throw output at user Render::addTemplate('machine-main', $client); // Sessions @@ -1002,8 +1013,10 @@ class Page_Statistics extends Page )); } // Notes - $client["notesAllowed"] = User::hasPermission("machine.note", $client["locationid"]); - Render::addTemplate('machine-notes', $client); + if (User::hasPermission('machine.note.*', (int)$client['locationid'])) { + Permission::addGlobalTags($client['perms'], (int)$client['locationid'], ['machine.note.edit']); + Render::addTemplate('machine-notes', $client); + } } private function eventToIconName($event) @@ -1026,6 +1039,8 @@ class Page_Statistics extends Page protected function doAjax() { + if (!User::load()) + return; $param = Request::any('lookup', false, 'string'); if ($param === false) { die('No lookup given'); diff --git a/modules-available/statistics/pages/projectors.inc.php b/modules-available/statistics/pages/projectors.inc.php index cde542c6..cdd0195e 100644 --- a/modules-available/statistics/pages/projectors.inc.php +++ b/modules-available/statistics/pages/projectors.inc.php @@ -13,6 +13,7 @@ class SubPage private static function handleProjector($action) { + User::assertPermission('hardware.projectors.edit'); $hwid = Request::post('hwid', false, 'int'); if ($hwid === false) { Util::traceError('Param hwid missing'); @@ -43,6 +44,7 @@ class SubPage private static function showProjectors() { + User::assertPermission('hardware.projectors.*'); $res = Database::simpleQuery('SELECT h.hwname, h.hwid FROM statistic_hw h' . " INNER JOIN statistic_hw_prop p ON (h.hwid = p.hwid AND p.prop = :projector)" . " WHERE h.hwtype = :screen ORDER BY h.hwname ASC", array( diff --git a/modules-available/statistics/permissions/permissions.json b/modules-available/statistics/permissions/permissions.json index da489998..663a8dc4 100644 --- a/modules-available/statistics/permissions/permissions.json +++ b/modules-available/statistics/permissions/permissions.json @@ -2,10 +2,25 @@ "machine.delete": { "location-aware": true }, - "machine.note": { + "machine.note.view": { "location-aware": true }, - "view": { + "machine.note.edit": { + "location-aware": true + }, + "hardware.projectors.view": { + "location-aware": false + }, + "hardware.projectors.edit": { + "location-aware": false + }, + "machine.view-details": { + "location-aware": true + }, + "view.summary": { + "location-aware": true + }, + "view.list": { "location-aware": true } } \ No newline at end of file diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html index d06eb4f7..b81515ab 100644 --- a/modules-available/statistics/templates/clientlist.html +++ b/modules-available/statistics/templates/clientlist.html @@ -49,12 +49,10 @@ {{#rows}} - {{#deleteAllowed}} -
- - -
- {{/deleteAllowed}} +
+ + +
{{#hasnotes}} {{/hasnotes}} @@ -70,7 +68,13 @@ {{#state_STANDBY}} {{/state_STANDBY}} - {{hostname}} + {{#link_details}} + + {{/link_details}} + {{hostname}} + {{#link_details}} + + {{/link_details}}
{{machineuuid}}
{{#rmmodule}}
{{lang_runMode}}: diff --git a/modules-available/statistics/templates/cpumodels.html b/modules-available/statistics/templates/cpumodels.html index d684c914..d89a5b2f 100644 --- a/modules-available/statistics/templates/cpumodels.html +++ b/modules-available/statistics/templates/cpumodels.html @@ -19,11 +19,11 @@
- {{systemmodel}} + {{systemmodel}}
- {{cores}} + {{cores}} {{count}} diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index 58b66a75..0178d7ea 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -13,7 +13,7 @@
- +
@@ -41,11 +41,11 @@
- - diff --git a/modules-available/statistics/templates/id44.html b/modules-available/statistics/templates/id44.html index d3b1ab1c..de1c71ad 100644 --- a/modules-available/statistics/templates/id44.html +++ b/modules-available/statistics/templates/id44.html @@ -17,7 +17,7 @@ {{#rows}} - {{gb}} GiB + {{gb}} GiB {{count}} diff --git a/modules-available/statistics/templates/kvmstate.html b/modules-available/statistics/templates/kvmstate.html index 3704eda0..efa3bad3 100644 --- a/modules-available/statistics/templates/kvmstate.html +++ b/modules-available/statistics/templates/kvmstate.html @@ -17,7 +17,7 @@ {{#rows}} - {{kvmstate}} + {{kvmstate}} {{count}} diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html index d8f2c521..f1021482 100644 --- a/modules-available/statistics/templates/machine-main.html +++ b/modules-available/statistics/templates/machine-main.html @@ -157,13 +157,19 @@ {{#hwname}}
{{#projector}} - {{lang_projector}} + + {{lang_projector}} + + class="btn btn-danger" {{perms.hardware.projectors.edit.disabled}}> + + {{/projector}} {{^projector}} + class="btn btn-success" {{perms.hardware.projectors.edit.disabled}}> + {{lang_projector}} + {{/projector}}
{{/hwname}} diff --git a/modules-available/statistics/templates/machine-notes.html b/modules-available/statistics/templates/machine-notes.html index 66e44da4..c352580f 100644 --- a/modules-available/statistics/templates/machine-notes.html +++ b/modules-available/statistics/templates/machine-notes.html @@ -8,9 +8,12 @@ - +
- +
diff --git a/modules-available/statistics/templates/memory.html b/modules-available/statistics/templates/memory.html index 6bc13980..cfb86062 100644 --- a/modules-available/statistics/templates/memory.html +++ b/modules-available/statistics/templates/memory.html @@ -17,7 +17,7 @@ {{#rows}} - {{gb}} GiB + {{gb}} GiB {{count}} diff --git a/modules-available/statistics/templates/summary.html b/modules-available/statistics/templates/summary.html index fe9559ed..3ede7bc5 100644 --- a/modules-available/statistics/templates/summary.html +++ b/modules-available/statistics/templates/summary.html @@ -8,8 +8,8 @@ {{/runmode}}
{{lang_knownMachines}}: {{known}}  - {{lang_onlineMachines}}: {{online}}  - {{lang_inUseMachines}}: {{used}} ({{usedpercent}}%) + {{lang_onlineMachines}}: {{online}}  + {{lang_inUseMachines}}: {{used}} ({{usedpercent}}%)
{{#badhdd}}
-- cgit v1.2.3-55-g7522 From 662315be2b5f6153fda03e8ec48ea3f8b343f68b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Mar 2018 11:05:25 +0100 Subject: Update permission translations --- modules-available/adduser/lang/de/permissions.json | 6 ++++++ modules-available/adduser/lang/en/permissions.json | 6 ++++++ modules-available/baseconfig/lang/de/permissions.json | 4 ++++ modules-available/baseconfig/lang/en/permissions.json | 4 ++++ modules-available/dnbd3/lang/de/permissions.json | 8 ++++++++ modules-available/dnbd3/lang/en/permissions.json | 8 ++++++++ modules-available/locationinfo/lang/de/permissions.json | 8 ++++++++ modules-available/locationinfo/lang/en/permissions.json | 8 ++++++++ modules-available/runmode/lang/de/permissions.json | 3 +++ modules-available/runmode/lang/en/permissions.json | 3 +++ .../serversetup-bwlp/lang/de/permissions.json | 6 +++--- modules-available/statistics/lang/de/permissions.json | 15 +++++++++++---- modules-available/statistics/lang/en/permissions.json | 15 +++++++++++---- modules-available/sysconfig/lang/de/permissions.json | 8 ++++++++ modules-available/sysconfig/lang/en/permissions.json | 8 ++++++++ modules-available/systemstatus/lang/de/permissions.json | 2 +- 16 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 modules-available/adduser/lang/de/permissions.json create mode 100644 modules-available/adduser/lang/en/permissions.json create mode 100644 modules-available/baseconfig/lang/de/permissions.json create mode 100644 modules-available/baseconfig/lang/en/permissions.json create mode 100644 modules-available/dnbd3/lang/de/permissions.json create mode 100644 modules-available/dnbd3/lang/en/permissions.json create mode 100644 modules-available/locationinfo/lang/de/permissions.json create mode 100644 modules-available/locationinfo/lang/en/permissions.json create mode 100644 modules-available/runmode/lang/de/permissions.json create mode 100644 modules-available/runmode/lang/en/permissions.json create mode 100644 modules-available/sysconfig/lang/de/permissions.json create mode 100644 modules-available/sysconfig/lang/en/permissions.json (limited to 'modules-available/statistics') diff --git a/modules-available/adduser/lang/de/permissions.json b/modules-available/adduser/lang/de/permissions.json new file mode 100644 index 00000000..636b73ff --- /dev/null +++ b/modules-available/adduser/lang/de/permissions.json @@ -0,0 +1,6 @@ +{ + "list.view": "Nutzerliste anzeigen", + "user.add": "Neuen Nutzer hinzuf\u00fcgen", + "user.edit": "Nutzer bearbeiten", + "user.remove": "Nutzer l\u00f6schen" +} \ No newline at end of file diff --git a/modules-available/adduser/lang/en/permissions.json b/modules-available/adduser/lang/en/permissions.json new file mode 100644 index 00000000..d12d100e --- /dev/null +++ b/modules-available/adduser/lang/en/permissions.json @@ -0,0 +1,6 @@ +{ + "list.view": "Show userlist", + "user.add": "Add new user", + "user.edit": "Edit user", + "user.remove": "Remove user" +} \ No newline at end of file diff --git a/modules-available/baseconfig/lang/de/permissions.json b/modules-available/baseconfig/lang/de/permissions.json new file mode 100644 index 00000000..a010cebe --- /dev/null +++ b/modules-available/baseconfig/lang/de/permissions.json @@ -0,0 +1,4 @@ +{ + "edit": "Konfigurationsvariablen bearbeiten", + "view": "Konfigurationsvariablen anzeigen" +} \ No newline at end of file diff --git a/modules-available/baseconfig/lang/en/permissions.json b/modules-available/baseconfig/lang/en/permissions.json new file mode 100644 index 00000000..9fe69752 --- /dev/null +++ b/modules-available/baseconfig/lang/en/permissions.json @@ -0,0 +1,4 @@ +{ + "edit": "Edit config variables", + "view": "Show config variables" +} \ No newline at end of file diff --git a/modules-available/dnbd3/lang/de/permissions.json b/modules-available/dnbd3/lang/de/permissions.json new file mode 100644 index 00000000..9229d6d9 --- /dev/null +++ b/modules-available/dnbd3/lang/de/permissions.json @@ -0,0 +1,8 @@ +{ + "configure.external": "Externen Proxy bearbeiten", + "configure.proxy": "Automatischen Proxy bearbeiten", + "refresh": "Serverliste aktualisieren", + "toggle-usage": "Aktivieren\/Deaktivieren", + "view.details": "Proxydetails anzeigen", + "view.list": "Proxyliste anzeigen" +} \ No newline at end of file diff --git a/modules-available/dnbd3/lang/en/permissions.json b/modules-available/dnbd3/lang/en/permissions.json new file mode 100644 index 00000000..0762af2c --- /dev/null +++ b/modules-available/dnbd3/lang/en/permissions.json @@ -0,0 +1,8 @@ +{ + "configure.external": "Edit external proxy", + "configure.proxy": "Edit automatic proxy", + "refresh": "Refresh server list", + "toggle-usage": "Activate\/Deactivate", + "view.details": "Show proxy details", + "view.list": "Show proxy list" +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/de/permissions.json b/modules-available/locationinfo/lang/de/permissions.json new file mode 100644 index 00000000..1cd78eab --- /dev/null +++ b/modules-available/locationinfo/lang/de/permissions.json @@ -0,0 +1,8 @@ +{ + "backend.check": "Backend Verbindung pr\u00fcfen", + "backend.edit": "Backend bearbeiten", + "location.edit": "Raum\/Ort Einstellungen bearbeiten", + "panel.assign-client": "Client als Infoscreen festlegen", + "panel.edit": "Panel bearbeiten", + "panel.list": "Panel anzeigen" +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/permissions.json b/modules-available/locationinfo/lang/en/permissions.json new file mode 100644 index 00000000..4b620b04 --- /dev/null +++ b/modules-available/locationinfo/lang/en/permissions.json @@ -0,0 +1,8 @@ +{ + "backend.check": "Test backend connection", + "backend.edit": "Edit backend", + "location.edit": "Edit location settings", + "panel.assign-client": "Set client as infoscreen", + "panel.edit": "Edit panel", + "panel.list": "List panels" +} \ No newline at end of file diff --git a/modules-available/runmode/lang/de/permissions.json b/modules-available/runmode/lang/de/permissions.json new file mode 100644 index 00000000..0a89e027 --- /dev/null +++ b/modules-available/runmode/lang/de/permissions.json @@ -0,0 +1,3 @@ +{ + "list-all": "Betriebsmodi anzeigen" +} \ No newline at end of file diff --git a/modules-available/runmode/lang/en/permissions.json b/modules-available/runmode/lang/en/permissions.json new file mode 100644 index 00000000..8b3a6e62 --- /dev/null +++ b/modules-available/runmode/lang/en/permissions.json @@ -0,0 +1,3 @@ +{ + "list-all": "Show runmodes" +} \ No newline at end of file diff --git a/modules-available/serversetup-bwlp/lang/de/permissions.json b/modules-available/serversetup-bwlp/lang/de/permissions.json index 673bf153..65367c51 100644 --- a/modules-available/serversetup-bwlp/lang/de/permissions.json +++ b/modules-available/serversetup-bwlp/lang/de/permissions.json @@ -1,5 +1,5 @@ { - "edit.address": "Boot-Adresse des Servers auswählen.", - "edit.menu": "Bootmenü anpassen.", - "download": "USB-Image herunteladen." + "download": "USB-Image herunterladen.", + "edit.address": "Boot-Adresse des Servers ausw\u00e4hlen.", + "edit.menu": "Bootmen\u00fc anpassen." } \ No newline at end of file diff --git a/modules-available/statistics/lang/de/permissions.json b/modules-available/statistics/lang/de/permissions.json index 7b7db89a..8579b28f 100644 --- a/modules-available/statistics/lang/de/permissions.json +++ b/modules-available/statistics/lang/de/permissions.json @@ -1,5 +1,12 @@ { - "view": "Statistiken anschauen.", - "machine.note": "Anmerkungen zu einem Rechner speichern.", - "machine.delete": "Rechner löschen." -} + "hardware.projectors.edit": "Beamerzuweisung bearbeiten", + "hardware.projectors.view": "Beamerzuweisung anzeigen", + "machine.delete": "Rechner l\u00f6schen.", + "machine.note": "Anmerkungen zu einem Rechner speichern.", + "machine.note.edit": "Anmerkungen bearbeiten", + "machine.note.view": "Anmerkungen anzeigen", + "machine.view-details": "Clientinformationen anzeigen", + "view": "Statistiken anschauen.", + "view.list": "Clientliste anzeigen", + "view.summary": "Visualisierung anzeigen" +} \ No newline at end of file diff --git a/modules-available/statistics/lang/en/permissions.json b/modules-available/statistics/lang/en/permissions.json index 01acdb8a..445f96b8 100644 --- a/modules-available/statistics/lang/en/permissions.json +++ b/modules-available/statistics/lang/en/permissions.json @@ -1,5 +1,12 @@ { - "view": "View statistics.", - "machine.note": "Save client notes.", - "machine.delete": "Delete clients." -} + "hardware.projectors.edit": "Edit beamer assignment", + "hardware.projectors.view": "Show beamer assignment", + "machine.delete": "Delete clients.", + "machine.note": "Save client notes.", + "machine.note.edit": "Edit notes", + "machine.note.view": "Show notes", + "machine.view-details": "Show client details", + "view": "View statistics.", + "view.list": "Show client list", + "view.summary": "Show visualization" +} \ No newline at end of file diff --git a/modules-available/sysconfig/lang/de/permissions.json b/modules-available/sysconfig/lang/de/permissions.json new file mode 100644 index 00000000..c32c488b --- /dev/null +++ b/modules-available/sysconfig/lang/de/permissions.json @@ -0,0 +1,8 @@ +{ + "config.assign": "Systemkonfiguration zuweisen", + "config.edit": "Systemkonfiguration bearbeiten", + "config.view-list": "Systemkonfigurationen anzeigen", + "module.download": "Konfigurationsmodul herunterladen", + "module.edit": "Konfigurationsmodul bearbeiten", + "module.view-list": "Konfigurationsmodule anzeigen" +} \ No newline at end of file diff --git a/modules-available/sysconfig/lang/en/permissions.json b/modules-available/sysconfig/lang/en/permissions.json new file mode 100644 index 00000000..14757383 --- /dev/null +++ b/modules-available/sysconfig/lang/en/permissions.json @@ -0,0 +1,8 @@ +{ + "config.assign": "Assign system configuration", + "config.edit": "Edit system configuration", + "config.view-list": "Show system configurations", + "module.download": "Download configuration module", + "module.edit": "Edit configuration module", + "module.view-list": "Show configuration modules" +} \ No newline at end of file diff --git a/modules-available/systemstatus/lang/de/permissions.json b/modules-available/systemstatus/lang/de/permissions.json index 5508beb5..a3041fbc 100644 --- a/modules-available/systemstatus/lang/de/permissions.json +++ b/modules-available/systemstatus/lang/de/permissions.json @@ -8,6 +8,6 @@ "tab.dmsdlog": "Zugriff auf bwLehrpool-Suite-Server Statusausgabe.", "tab.ldadplog": "Zugriff auf LDAP\/AD-Proxy Logs.", "tab.lighttpdlog": "Zugriff auf Webserver-Logs.", - "tab.netstat": "Zeige Aufgabe von netstat.", + "tab.netstat": "Zeige Ausgabe von netstat.", "tab.pslist": "Zeige Prozessliste." } \ No newline at end of file -- cgit v1.2.3-55-g7522 From d5166e77fbb1dc034a421da868f9539fc455e490 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Mar 2018 11:30:29 +0100 Subject: Update translations --- modules-available/locations/lang/de/template-tags.json | 4 ++-- modules-available/locations/lang/en/template-tags.json | 4 ++-- modules-available/rebootcontrol/page.inc.php | 2 +- modules-available/runmode/lang/de/messages.json | 1 + modules-available/runmode/lang/de/template-tags.json | 1 + modules-available/runmode/lang/en/messages.json | 1 + modules-available/runmode/lang/en/template-tags.json | 1 + modules-available/statistics/page.inc.php | 2 +- 8 files changed, 10 insertions(+), 6 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/locations/lang/de/template-tags.json b/modules-available/locations/lang/de/template-tags.json index 04d10d06..43142555 100644 --- a/modules-available/locations/lang/de/template-tags.json +++ b/modules-available/locations/lang/de/template-tags.json @@ -6,7 +6,7 @@ "lang_deleteChildLocations": "Untergeordnete Orte ebenfalls l\u00f6schen", "lang_deleteLocation": "Ort l\u00f6schen", "lang_deleteSubnet": "Bereich l\u00f6schen", - "lang_deleteSubnetWarning": "Alle zum L\u00f6schen markierten Subnetze werden gelöscht. Diese Aktion kann nicht r\u00fcckg\u00e4ngig gemacht werden.", + "lang_deleteSubnetWarning": "Alle zum L\u00f6schen markierten Subnetze werden gel\u00f6scht. Diese Aktion kann nicht r\u00fcckg\u00e4ngig gemacht werden.", "lang_editConfigVariables": "Konfig.-Variablen", "lang_editRoomplan": "Raumplan bearbeiten", "lang_endAddress": "Endadresse", @@ -22,10 +22,10 @@ "lang_machineLoad": "Besetzt", "lang_matchingMachines": "Enthaltene Rechner", "lang_name": "Name", - "lang_noParent": "Kein \u00fcbergeordneter Ort", "lang_overrideCount": "Angepasst", "lang_parentLocation": "\u00dcbergeordneter Ort", "lang_referencingLectures": "Veranstaltungen", + "lang_showRoomplan": "Raumplan anzeigen", "lang_startAddress": "Startadresse", "lang_subnet": "IP-Bereich", "lang_sysConfig": "Lokalisierung", diff --git a/modules-available/locations/lang/en/template-tags.json b/modules-available/locations/lang/en/template-tags.json index ddb90f83..41261726 100644 --- a/modules-available/locations/lang/en/template-tags.json +++ b/modules-available/locations/lang/en/template-tags.json @@ -22,14 +22,14 @@ "lang_machineLoad": "In use", "lang_matchingMachines": "Matching clients", "lang_name": "Name", - "lang_noParent": "No parent", "lang_overrideCount": "Overridden", "lang_parentLocation": "Parent location", "lang_referencingLectures": "Assigned Lectures", + "lang_showRoomplan": "Show room plan", "lang_startAddress": "Start address", "lang_subnet": "IP range", "lang_sysConfig": "Localization\/Integration", "lang_thisListByLocation": "Locations", "lang_thisListBySubnet": "Subnets", "lang_unassignedMachines": "Machines not matching any location" -} +} \ No newline at end of file diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php index fa7688d8..abbdb2c3 100644 --- a/modules-available/rebootcontrol/page.inc.php +++ b/modules-available/rebootcontrol/page.inc.php @@ -38,7 +38,7 @@ class Page_RebootControl extends Page // Filter ones with no permission foreach (array_keys($actualClients) as $idx) { if (!User::hasPermission('action.' . $this->action, $actualClients[$idx]['locationid'])) { - Message::addWarning('main.location-no-permission', $actualClients[$idx]['locationid']); + Message::addWarning('locations.no-permission-location', $actualClients[$idx]['locationid']); unset($actualClients[$idx]); } else { $locationId = $actualClients[$idx]['locationid']; diff --git a/modules-available/runmode/lang/de/messages.json b/modules-available/runmode/lang/de/messages.json index 911d48d4..bca70019 100644 --- a/modules-available/runmode/lang/de/messages.json +++ b/modules-available/runmode/lang/de/messages.json @@ -2,6 +2,7 @@ "cannot-edit-module": "Modul {{0}} kann nicht direkt editiert werden", "enabled-removed-save": "{{0}} Rechner gespeichert, {{1}} entfernt", "invalid-modeid": "{{1}} ist kein g\u00fcltiger Betriebsmodus f\u00fcr Modul {{0}}", + "machine-no-permission": "Keine Berechtigung f\u00fcr client {{0}}", "machine-not-found": "Rechner {{0}} nicht gefunden", "machine-not-runmode": "Rechner {{0}} hatte keinen speziellen Betriebsmodus aktiviert", "machine-removed": "Rechner {{0}} entfernt", diff --git a/modules-available/runmode/lang/de/template-tags.json b/modules-available/runmode/lang/de/template-tags.json index 6b45b82c..989e5b1d 100644 --- a/modules-available/runmode/lang/de/template-tags.json +++ b/modules-available/runmode/lang/de/template-tags.json @@ -3,6 +3,7 @@ "lang_assignMachineIntroText": "Definieren Sie hier Clients, die in einem speziellen Betriebsmodus gestartet werden sollen. Sie k\u00f6nnen Rechner anhand der UUID, IP, Hostname oder MAC-Adresse suchen.", "lang_assignRunmodeToMachine": "Betriebsmodus", "lang_confirmDelete": "Wollen Sie den Betriebsmodus f\u00fcr diesen Client entfernen?", + "lang_existingClients": "Vorhandene Clients mit diesem Betriebsmodus", "lang_isclient": "Pool-Client", "lang_machine": "Client", "lang_mode": "Modus", diff --git a/modules-available/runmode/lang/en/messages.json b/modules-available/runmode/lang/en/messages.json index 6d890428..1ca1567a 100644 --- a/modules-available/runmode/lang/en/messages.json +++ b/modules-available/runmode/lang/en/messages.json @@ -2,6 +2,7 @@ "cannot-edit-module": "Module {{0}} cannot be edited directly", "enabled-removed-save": "Saved {{0}} clients, deleted {{1}}", "invalid-modeid": "Module {{0}} doesn't provide mode {{1}}", + "machine-no-permission": "No permission for client {{0}}", "machine-not-found": "Client {{0}} not found", "machine-not-runmode": "No special mode of operation configured for client {{0}}", "machine-removed": "Removed client {{0}}", diff --git a/modules-available/runmode/lang/en/template-tags.json b/modules-available/runmode/lang/en/template-tags.json index 43fd3da5..89cf6b15 100644 --- a/modules-available/runmode/lang/en/template-tags.json +++ b/modules-available/runmode/lang/en/template-tags.json @@ -3,6 +3,7 @@ "lang_assignMachineIntroText": "Define the clients which should start a special runmode configuration. You can search for clients by UUID, IP address, host name or MAC address.", "lang_assignRunmodeToMachine": "Runmode", "lang_confirmDelete": "Do you want to delete the runmode for this client?", + "lang_existingClients": "Existing clients with this run mode", "lang_isclient": "Pool-Client", "lang_machine": "Client", "lang_mode": "Mode", diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 3baac190..60743fb6 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -227,7 +227,7 @@ class Page_Statistics extends Page if (in_array($row['locationid'], $allowedLocations)) { $delete[] = $row['machineuuid']; } else { - Message::addError('no-permission-location', $row['locationid']); + Message::addError('locations.no-permission-location', $row['locationid']); } } if (!empty($delete)) { -- cgit v1.2.3-55-g7522 From ae291442311e38aaa7c373d1660404d1ebeb17f0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Mar 2018 15:16:37 +0100 Subject: [statistics] Show ID45 partition in green, like ID44 Closes #3325 --- modules-available/statistics/inc/parser.inc.php | 26 +++++++++++++++++++--- .../statistics/templates/machine-hdds.html | 6 ++--- 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/inc/parser.inc.php b/modules-available/statistics/inc/parser.inc.php index 679055a7..b179b4a3 100644 --- a/modules-available/statistics/inc/parser.inc.php +++ b/modules-available/statistics/inc/parser.inc.php @@ -151,24 +151,44 @@ class Parser { $type = strtolower($out[4]); if ($type === '5' || $type === 'f' || $type === '85') { continue; + } elseif ($type === '44') { + $out[5] = 'OpenSLX-ID44'; + $color = '#5c1'; + } elseif ($type === '45') { + $out[5] = 'OpenSLX-ID45'; + $color = '#0d7'; + } elseif ($type === '82') { + $color = '#48f'; + } else { + $color = '#e55'; } + $partsize = round(($out[3] - $out[2]) * $mbrToMbFactor); $hdd['partitions'][] = array( 'id' => $out[1], 'name' => $out[1], 'size' => round($partsize / 1024, $partsize < 1024 ? 1 : 0), - 'type' => ($type === '44' ? 'OpenSLX' : $out[5]), + 'type' => $out[5], ); $hdd['json'][] = array( 'label' => $out[1], 'value' => $partsize, - 'color' => ($type === '44' ? '#4d4' : ($type === '82' ? '#48f' : '#e55')), + 'color' => $color, ); $hdd['used'] += $partsize; } elseif (isset($hdd) && $sectorToMbFactor !== 0 && preg_match(',^\s*(\d+)\s+(\d+)[\+\-]?\s+(\d+)[\+\-]?\s+\S+\s+([0-9a-f]+)\s+(.*)$,i', $line, $out)) { // --- GPT: Partition entry --- // Some partition $type = $out[5]; + if ($type === 'OpenSLX-ID44') { + $color = '#5c1'; + } elseif ($type === 'OpenSLX-ID45') { + $color = '#0d7'; + } elseif ($type === 'Linux swap') { + $color = '#48f'; + } else { + $color = '#e55'; + } $id = $hdd['devid'] . '-' . $out[1]; $partsize = round(($out[3] - $out[2]) * $sectorToMbFactor); $hdd['partitions'][] = array( @@ -180,7 +200,7 @@ class Parser { $hdd['json'][] = array( 'label' => $id, 'value' => $partsize, - 'color' => ($type === 'OpenSLX-ID44' ? '#4d4' : ($type === 'Linux swap' ? '#48f' : '#e55')), + 'color' => $color, ); $hdd['used'] += $partsize; } diff --git a/modules-available/statistics/templates/machine-hdds.html b/modules-available/statistics/templates/machine-hdds.html index fd6cf1be..b839dfca 100644 --- a/modules-available/statistics/templates/machine-hdds.html +++ b/modules-available/statistics/templates/machine-hdds.html @@ -20,7 +20,7 @@
{{lang_powerOnTime}}: {{s_PowerOnHours}} {{lang_hours}} ({{PowerOnTime}})
{{/s_PowerOnHours}}
-
+
@@ -30,14 +30,14 @@ {{#partitions}} - + {{/partitions}}
{{lang_partName}}
{{name}}{{size}} GiB{{size}} GiB {{type}}
{{lang_total}}: {{size}} GiB
-
+
'; foreach ($modules as $module) { - $files = $module->getScripts($module !== $pageModule); + $files = $module->getScripts(); foreach ($files as $file) { echo ''; } diff --git a/index.php b/index.php index 4816ef42..1ecd2109 100644 --- a/index.php +++ b/index.php @@ -79,7 +79,7 @@ abstract class Page if (self::$module === false) { Util::traceError('Invalid Module: ' . $name); } - self::$module->activate(); + self::$module->activate(null, null); self::$instance = self::$module->newPage(); } diff --git a/modules-available/adduser/config.json b/modules-available/adduser/config.json index 706412d0..110f8b67 100644 --- a/modules-available/adduser/config.json +++ b/modules-available/adduser/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/backup/config.json b/modules-available/backup/config.json index 706412d0..110f8b67 100644 --- a/modules-available/backup/config.json +++ b/modules-available/backup/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/baseconfig/config.json b/modules-available/baseconfig/config.json index e4d906e1..357a117e 100644 --- a/modules-available/baseconfig/config.json +++ b/modules-available/baseconfig/config.json @@ -1,4 +1,7 @@ { "category": "main.settings-client", - "dependencies" : ["js_selectize", "bootstrap_multiselect"] -} + "dependencies": [ + "js_selectize", + "bootstrap_multiselect" + ] +} \ No newline at end of file diff --git a/modules-available/baseconfig_bwidm/config.json b/modules-available/baseconfig_bwidm/config.json index af67a188..7e6cf06a 100644 --- a/modules-available/baseconfig_bwidm/config.json +++ b/modules-available/baseconfig_bwidm/config.json @@ -1,3 +1,5 @@ { - "dependencies": ["baseconfig"] -} + "dependencies": [ + "baseconfig" + ] +} \ No newline at end of file diff --git a/modules-available/baseconfig_bwlp/config.json b/modules-available/baseconfig_bwlp/config.json index af67a188..7e6cf06a 100644 --- a/modules-available/baseconfig_bwlp/config.json +++ b/modules-available/baseconfig_bwlp/config.json @@ -1,3 +1,5 @@ { - "dependencies": ["baseconfig"] -} + "dependencies": [ + "baseconfig" + ] +} \ No newline at end of file diff --git a/modules-available/baseconfig_partitions_cdn/config.json b/modules-available/baseconfig_partitions_cdn/config.json index a355eef3..fd4c6f4b 100644 --- a/modules-available/baseconfig_partitions_cdn/config.json +++ b/modules-available/baseconfig_partitions_cdn/config.json @@ -1,4 +1,6 @@ { - "category": "main.settings-client", - "dependencies": [ "baseconfig" ] -} + "category": "main.settings-client", + "dependencies": [ + "baseconfig" + ] +} \ No newline at end of file diff --git a/modules-available/bootstrap_datepicker/config.json b/modules-available/bootstrap_datepicker/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/bootstrap_datepicker/config.json +++ b/modules-available/bootstrap_datepicker/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/bootstrap_dialog/config.json b/modules-available/bootstrap_dialog/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/bootstrap_dialog/config.json +++ b/modules-available/bootstrap_dialog/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/bootstrap_multiselect/config.json b/modules-available/bootstrap_multiselect/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/bootstrap_multiselect/config.json +++ b/modules-available/bootstrap_multiselect/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/bootstrap_switch/config.json b/modules-available/bootstrap_switch/config.json index de4d37b4..3cf0d162 100644 --- a/modules-available/bootstrap_switch/config.json +++ b/modules-available/bootstrap_switch/config.json @@ -1,8 +1,9 @@ { - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true } \ No newline at end of file diff --git a/modules-available/bootstrap_timepicker/config.json b/modules-available/bootstrap_timepicker/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/bootstrap_timepicker/config.json +++ b/modules-available/bootstrap_timepicker/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/citymanagement/config.json b/modules-available/citymanagement/config.json index e87cbf7d..b356dfc6 100644 --- a/modules-available/citymanagement/config.json +++ b/modules-available/citymanagement/config.json @@ -1,4 +1,4 @@ { - "category":"citymanagement.cities", - "permission":"0" -} + "category": "citymanagement.cities", + "permission": "0" +} \ No newline at end of file diff --git a/modules-available/dnbd3/config.json b/modules-available/dnbd3/config.json index f84a4170..9670ded9 100644 --- a/modules-available/dnbd3/config.json +++ b/modules-available/dnbd3/config.json @@ -1,4 +1,7 @@ { - "category":"main.settings-server", - "dependencies":["locations","runmode"] -} + "category": "main.settings-server", + "dependencies": [ + "locations", + "runmode" + ] +} \ No newline at end of file diff --git a/modules-available/dozmod/config.json b/modules-available/dozmod/config.json index 706412d0..110f8b67 100644 --- a/modules-available/dozmod/config.json +++ b/modules-available/dozmod/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/eventlog/config.json b/modules-available/eventlog/config.json index 6778348d..aa23adb5 100644 --- a/modules-available/eventlog/config.json +++ b/modules-available/eventlog/config.json @@ -1,3 +1,3 @@ { - "category":"main.status" -} + "category": "main.status" +} \ No newline at end of file diff --git a/modules-available/exams/config.json b/modules-available/exams/config.json index 0780ebef..a99d1c1a 100644 --- a/modules-available/exams/config.json +++ b/modules-available/exams/config.json @@ -1,5 +1,12 @@ { - "category":"main.content", - "dependencies": [ "locations", "js_vis", "js_stupidtable", "bootstrap_datepicker", "bootstrap_timepicker", "bootstrap_multiselect"], + "category": "main.content", + "dependencies": [ + "locations", + "js_vis", + "js_stupidtable", + "bootstrap_datepicker", + "bootstrap_timepicker", + "bootstrap_multiselect" + ], "permission": "0" -} +} \ No newline at end of file diff --git a/modules-available/imgmanagement/config.json b/modules-available/imgmanagement/config.json index 6454d96f..2fbb822f 100644 --- a/modules-available/imgmanagement/config.json +++ b/modules-available/imgmanagement/config.json @@ -1,4 +1,4 @@ { - "category":"main.content", - "permission":"1" -} + "category": "main.content", + "permission": "1" +} \ No newline at end of file diff --git a/modules-available/internetaccess/config.json b/modules-available/internetaccess/config.json index 706412d0..110f8b67 100644 --- a/modules-available/internetaccess/config.json +++ b/modules-available/internetaccess/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/js_chart/config.json b/modules-available/js_chart/config.json index de4d37b4..3cf0d162 100644 --- a/modules-available/js_chart/config.json +++ b/modules-available/js_chart/config.json @@ -1,8 +1,9 @@ { - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true } \ No newline at end of file diff --git a/modules-available/js_circles/config.json b/modules-available/js_circles/config.json index de4d37b4..3cf0d162 100644 --- a/modules-available/js_circles/config.json +++ b/modules-available/js_circles/config.json @@ -1,8 +1,9 @@ { - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true } \ No newline at end of file diff --git a/modules-available/js_jqueryui/config.json b/modules-available/js_jqueryui/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/js_jqueryui/config.json +++ b/modules-available/js_jqueryui/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/js_moment/config.json b/modules-available/js_moment/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/js_moment/config.json +++ b/modules-available/js_moment/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/js_selectize/config.json b/modules-available/js_selectize/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/js_selectize/config.json +++ b/modules-available/js_selectize/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/js_stupidtable/config.json b/modules-available/js_stupidtable/config.json index cf932d7e..3cf0d162 100644 --- a/modules-available/js_stupidtable/config.json +++ b/modules-available/js_stupidtable/config.json @@ -1,8 +1,9 @@ { - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true } \ No newline at end of file diff --git a/modules-available/js_vis/config.json b/modules-available/js_vis/config.json index 3b027d31..4c870a22 100644 --- a/modules-available/js_vis/config.json +++ b/modules-available/js_vis/config.json @@ -1,9 +1,12 @@ { - "dependencies" : ["js_moment"], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [ + "js_moment" + ], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/locationinfo/config.json b/modules-available/locationinfo/config.json index 87825809..837acfcf 100644 --- a/modules-available/locationinfo/config.json +++ b/modules-available/locationinfo/config.json @@ -1,4 +1,9 @@ { - "category":"main.beta", - "dependencies": ["js_jqueryui", "bootstrap_timepicker", "locations", "bootstrap_switch"] -} + "category": "main.beta", + "dependencies": [ + "js_jqueryui", + "bootstrap_timepicker", + "locations", + "bootstrap_switch" + ] +} \ No newline at end of file diff --git a/modules-available/locations/config.json b/modules-available/locations/config.json index 706412d0..110f8b67 100644 --- a/modules-available/locations/config.json +++ b/modules-available/locations/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/main/config.json b/modules-available/main/config.json index 2c63c085..0637a088 100644 --- a/modules-available/main/config.json +++ b/modules-available/main/config.json @@ -1,2 +1 @@ -{ -} +[] \ No newline at end of file diff --git a/modules-available/minilinux/config.json b/modules-available/minilinux/config.json index 28d71577..6c7b7146 100644 --- a/modules-available/minilinux/config.json +++ b/modules-available/minilinux/config.json @@ -1,3 +1,3 @@ { - "category":"main.settings-client" -} + "category": "main.settings-client" +} \ No newline at end of file diff --git a/modules-available/news/config.json b/modules-available/news/config.json index e076ea5c..23cd1443 100644 --- a/modules-available/news/config.json +++ b/modules-available/news/config.json @@ -1,4 +1,6 @@ { - "category":"main.content", - "dependencies": [ "js_stupidtable" ] -} + "category": "main.content", + "dependencies": [ + "js_stupidtable" + ] +} \ No newline at end of file diff --git a/modules-available/permissionmanager/config.json b/modules-available/permissionmanager/config.json index d2071984..25b61de3 100644 --- a/modules-available/permissionmanager/config.json +++ b/modules-available/permissionmanager/config.json @@ -1,4 +1,8 @@ { - "category":"main.content", - "dependencies": [ "locations", "js_stupidtable", "js_selectize" ] -} + "category": "main.content", + "dependencies": [ + "locations", + "js_stupidtable", + "js_selectize" + ] +} \ No newline at end of file diff --git a/modules-available/rebootcontrol/config.json b/modules-available/rebootcontrol/config.json index d8ab5868..43d2c28f 100644 --- a/modules-available/rebootcontrol/config.json +++ b/modules-available/rebootcontrol/config.json @@ -1,4 +1,7 @@ { - "category":"main.beta", - "dependencies": [ "locations", "js_stupidtable" ] -} + "category": "main.beta", + "dependencies": [ + "locations", + "js_stupidtable" + ] +} \ No newline at end of file diff --git a/modules-available/roomplanner/config.json b/modules-available/roomplanner/config.json index 537714c3..62f38773 100644 --- a/modules-available/roomplanner/config.json +++ b/modules-available/roomplanner/config.json @@ -1,3 +1,10 @@ { - "dependencies": ["js_jqueryui", "js_selectize", "bootstrap_dialog", "statistics", "locations", "runmode"] -} + "dependencies": [ + "js_jqueryui", + "js_selectize", + "bootstrap_dialog", + "statistics", + "locations", + "runmode" + ] +} \ No newline at end of file diff --git a/modules-available/runmode/config.json b/modules-available/runmode/config.json index e3c07d48..84e044ce 100644 --- a/modules-available/runmode/config.json +++ b/modules-available/runmode/config.json @@ -1,4 +1,7 @@ { - "dependencies": [ "statistics", "js_selectize" ], - "permission":"0" -} + "dependencies": [ + "statistics", + "js_selectize" + ], + "permission": "0" +} \ No newline at end of file diff --git a/modules-available/serversetup-bwlp/config.json b/modules-available/serversetup-bwlp/config.json index 7205d70a..36268c6a 100644 --- a/modules-available/serversetup-bwlp/config.json +++ b/modules-available/serversetup-bwlp/config.json @@ -1,3 +1,3 @@ { - "category":"main.settings-server" -} + "category": "main.settings-server" +} \ No newline at end of file diff --git a/modules-available/session/config.json b/modules-available/session/config.json index 2c63c085..0637a088 100644 --- a/modules-available/session/config.json +++ b/modules-available/session/config.json @@ -1,2 +1 @@ -{ -} +[] \ No newline at end of file diff --git a/modules-available/statistics/config.json b/modules-available/statistics/config.json index 333f881a..412dc3cb 100644 --- a/modules-available/statistics/config.json +++ b/modules-available/statistics/config.json @@ -1,5 +1,9 @@ { - "category":"main.status", - "dependencies": [ "js_chart", "js_selectize", "bootstrap_datepicker"], - "permission":"0" -} + "category": "main.status", + "dependencies": [ + "js_chart", + "js_selectize", + "bootstrap_datepicker" + ], + "permission": "0" +} \ No newline at end of file diff --git a/modules-available/statistics_reporting/config.json b/modules-available/statistics_reporting/config.json index 78ca35ba..c439efa8 100644 --- a/modules-available/statistics_reporting/config.json +++ b/modules-available/statistics_reporting/config.json @@ -1,4 +1,9 @@ { "category": "main.status", - "dependencies": [ "statistics", "locations", "js_stupidtable", "js_jqueryui" ] -} + "dependencies": [ + "statistics", + "locations", + "js_stupidtable", + "js_jqueryui" + ] +} \ No newline at end of file diff --git a/modules-available/summernote/config.json b/modules-available/summernote/config.json index 5a0c7960..69bb0aa9 100644 --- a/modules-available/summernote/config.json +++ b/modules-available/summernote/config.json @@ -1,9 +1,10 @@ { - "dependencies" : [], - "css": { - "style.css": true - }, - "scripts": { - "clientscript.js": true - } -} + "dependencies": [], + "css": [ + "style.css" + ], + "scripts": [ + "clientscript.js" + ], + "client-plugin": true +} \ No newline at end of file diff --git a/modules-available/support/config.json b/modules-available/support/config.json index 706412d0..110f8b67 100644 --- a/modules-available/support/config.json +++ b/modules-available/support/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/sysconfig/config.json b/modules-available/sysconfig/config.json index 28d71577..6c7b7146 100644 --- a/modules-available/sysconfig/config.json +++ b/modules-available/sysconfig/config.json @@ -1,3 +1,3 @@ { - "category":"main.settings-client" -} + "category": "main.settings-client" +} \ No newline at end of file diff --git a/modules-available/sysconfignew/config.json b/modules-available/sysconfignew/config.json index 28d71577..6c7b7146 100644 --- a/modules-available/sysconfignew/config.json +++ b/modules-available/sysconfignew/config.json @@ -1,3 +1,3 @@ { - "category":"main.settings-client" -} + "category": "main.settings-client" +} \ No newline at end of file diff --git a/modules-available/syslog/config.json b/modules-available/syslog/config.json index 2b718a8e..691bd4df 100644 --- a/modules-available/syslog/config.json +++ b/modules-available/syslog/config.json @@ -1,4 +1,6 @@ { - "category":"main.status", - "dependencies":["js_selectize"] -} + "category": "main.status", + "dependencies": [ + "js_selectize" + ] +} \ No newline at end of file diff --git a/modules-available/systemstatus/config.json b/modules-available/systemstatus/config.json index 3c2efce7..cf774d1b 100644 --- a/modules-available/systemstatus/config.json +++ b/modules-available/systemstatus/config.json @@ -1,4 +1,6 @@ { - "category":"main.status", - "dependencies": [ "js_circles" ] -} + "category": "main.status", + "dependencies": [ + "js_circles" + ] +} \ No newline at end of file diff --git a/modules-available/translation/config.json b/modules-available/translation/config.json index 706412d0..110f8b67 100644 --- a/modules-available/translation/config.json +++ b/modules-available/translation/config.json @@ -1,3 +1,3 @@ { - "category":"main.content" -} + "category": "main.content" +} \ No newline at end of file diff --git a/modules-available/usermanagement/config.json b/modules-available/usermanagement/config.json index 9c66d6bf..428315ba 100644 --- a/modules-available/usermanagement/config.json +++ b/modules-available/usermanagement/config.json @@ -1,4 +1,4 @@ { - "category":"main.users", - "permission":"0" -} + "category": "main.users", + "permission": "0" +} \ No newline at end of file diff --git a/modules-available/vmstore/config.json b/modules-available/vmstore/config.json index 7205d70a..36268c6a 100644 --- a/modules-available/vmstore/config.json +++ b/modules-available/vmstore/config.json @@ -1,3 +1,3 @@ { - "category":"main.settings-server" -} + "category": "main.settings-server" +} \ No newline at end of file diff --git a/modules-available/webinterface/config.json b/modules-available/webinterface/config.json index 7205d70a..36268c6a 100644 --- a/modules-available/webinterface/config.json +++ b/modules-available/webinterface/config.json @@ -1,3 +1,3 @@ { - "category":"main.settings-server" -} + "category": "main.settings-server" +} \ No newline at end of file -- cgit v1.2.3-55-g7522 From 36bd71573754711a45f4ddcc03cc88dad9b8e8a1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 19 Apr 2018 14:27:14 +0200 Subject: [statistics] Fix select items in filterbox, tweak ID44 size grouping --- modules-available/statistics/page.inc.php | 2 +- modules-available/statistics/templates/filterbox.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index d493d87a..b4d3a42d 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -8,7 +8,7 @@ for ($i = 0; $i < 10; ++$i) { $STATS_COLORS[] = '#55' . sprintf('%02s%02s', dechex((($i + 1) * ($i + 1)) / .3922), dechex(abs((5 - $i) * 51))); } //$STATS_COLORS = array('#57e', '#ee8', '#5ae', '#fb7', '#6d7', '#e77', '#3af', '#666', '#e0e', '#999'); -$SIZE_ID44 = array(0, 8, 16, 24, 30, 40, 50, 60, 80, 100, 120, 150, 180, 250, 300, 350, 400, 450, 500); +$SIZE_ID44 = array(0, 8, 16, 24, 30, 40, 50, 60, 80, 100, 120, 150, 180, 250, 300, 400, 500, 1000, 2000, 4000); $SIZE_RAM = array(1, 2, 3, 4, 6, 8, 10, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 320, 480, 512, 768, 1024); class Page_Statistics extends Page diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index 0178d7ea..cd8ec24d 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -169,16 +169,16 @@ document.addEventListener("DOMContentLoaded", function () { })); }); /* also set the type of the input */ - if (columns[col]['type'] == 'date') { + if (columns[col]['type'] === 'date') { $('#argumentInput').datepicker({format : 'yyyy-mm-dd'}); $('#argumentSelect').hide(); - } else if(columns[col]['type'] == 'enum') { + } else if(columns[col]['type'] === 'enum') { $('#argumentSelect').empty(); $('#argumentInput').hide(); $('#argumentSelect').show(); columns[col]['values'].forEach(function (v) { var t = v; - var disabled = true; + var disabled = (col === 'location'); if (col === 'location' && slxLocations['L' + v]) { t = slxLocations['L' + v].pad + ' ' + slxLocations['L' + v].name; disabled = slxLocations['L' + v].disabled; -- cgit v1.2.3-55-g7522 From 09bfa9c947298ed810b91baeb27e9fae7ea091c7 Mon Sep 17 00:00:00 2001 From: Steffen Ritter Date: Wed, 6 Jun 2018 16:09:22 +0200 Subject: [statistics] Add location column in clientlist --- modules-available/statistics/page.inc.php | 1 + modules-available/statistics/templates/clientlist.html | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index b4d3a42d..abacc8d2 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -679,6 +679,7 @@ class Page_Statistics extends Page $row['modeName'] = $data['modeName']; } } + $row['locationname'] = Location::getName($row['locationid']); $rows[] = $row; } if ($singleMachine !== false && $singleMachine !== 'none') { diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html index b81515ab..18a5d10a 100644 --- a/modules-available/statistics/templates/clientlist.html +++ b/modules-available/statistics/templates/clientlist.html @@ -34,6 +34,11 @@ + + + {{lang_machine}} @@ -43,6 +48,7 @@ {{lang_gbRam}} {{lang_tmpGb}} {{lang_cpuModel}} + {{lang_location}} @@ -97,6 +103,7 @@
{{/nohdd}} {{lang_realCores}}: {{realcores}}
{{cpumodel}}
+ {{locationname}} {{/rows}} -- cgit v1.2.3-55-g7522 From 2af07ae6913aad34924f119ed0bd9a0465e74d6f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 4 Dec 2018 11:54:35 +0100 Subject: [statistics] Filter malformed screen names --- modules-available/statistics/api.inc.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index a7a636b3..8f5e9fd0 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -267,6 +267,10 @@ if ($type{0} === '~') { foreach ($screens as $port => $screen) { if (!array_key_exists('name', $screen)) continue; + // Filter bogus data + $screen['name'] = iconv('UTF-8', 'UTF-8//IGNORE', $screen['name']); + if (empty($screen['name'])) + continue; if (array_key_exists($screen['name'], $hwids)) { $hwid = $hwids[$screen['name']]; } else { -- cgit v1.2.3-55-g7522 From d42a3b1f1d30d54f89ff4830163b00364f775e83 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 21 Jan 2019 12:19:35 +0100 Subject: [statistics] Improve ID44 filter matching --- modules-available/statistics/inc/filter.inc.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index 565ea5f0..3ccea2c3 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -187,20 +187,24 @@ class Id44Filter extends Filter public function whereClause(&$args, &$joins) { global $SIZE_ID44; - $lower = floor(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, false) * 1024 - 100); - $upper = ceil(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, true) * 1024 + 100); + if ($this->operator === '=' || $this->operator === '!=') { + $lower = floor(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, false) * 1024 - 100); + $upper = ceil(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, true) * 1024 + 100); + } else { + $lower = $upper = round($this->argument * 1024); + } - if ($this->operator == '=') { + if ($this->operator === '=') { return " id44mb BETWEEN $lower AND $upper"; - } elseif ($this->operator == '!=') { + } elseif ($this->operator === '!=') { return " id44mb < $lower OR id44mb > $upper"; - } elseif ($this->operator == '<=') { - return " id44mb < $upper"; - } elseif ($this->operator == '>=') { - return " id44mb > $lower"; - } elseif ($this->operator == '<') { + } elseif ($this->operator === '<=') { + return " id44mb <= $upper"; + } elseif ($this->operator === '>=') { + return " id44mb >= $lower"; + } elseif ($this->operator === '<') { return " id44mb < $lower"; - } elseif ($this->operator == '>') { + } elseif ($this->operator === '>') { return " id44mb > $upper"; } else { error_log("unimplemented operator in Id44Filter: $this->operator"); -- cgit v1.2.3-55-g7522 From 54a516de8a49bdcdd2b95ecbfe2a365a860adaf4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 21 Jan 2019 14:49:54 +0100 Subject: [statistics] Log if client seems to have crashed Log when we reset a client's state in the cron job, as well as if we receive a poweron event even though the state in the DB is still IDLE or OCCUPIED. --- modules-available/statistics/api.inc.php | 17 +++++++++++++++++ modules-available/statistics/hooks/cron.inc.php | 13 +++++++++++++ 2 files changed, 30 insertions(+) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 8f5e9fd0..674cc48d 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -161,6 +161,11 @@ if ($type{0} === '~') { // Check for suspicious hardware changes if ($old !== false) { checkHardwareChange($old, $new); + + // Log potential crash + if ($old['state'] === 'IDLE' || $old['state'] === 'OCCUPIED') { + writeClientLog('machine-mismatch-poweron', 'Client sent poweron event, but previous known state is ' . $old['state']); + } } // Write statistics data @@ -403,6 +408,18 @@ function writeStatisticLog($type, $username, $data) )); } +function writeClientLog($type, $description) +{ + global $ip, $uuid; + Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( + 'type' => $type, + 'client' => $ip, + 'description' => $description, + 'longdesc' => '', + 'uuid' => $uuid, + )); +} + // For backwards compat, we require the . prefix if ($type{0} === '.') { diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index 4df7b0d4..f05762bc 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -23,6 +23,19 @@ function state_cleanup() // Fix online state of machines that crashed $standby = time() - 86400 * 2; // Reset standby machines after two days $on = time() - 610; // Reset others after ~10 minutes + // Query for logging + $res = Database::simpleQuery("SELECT machineuuid, clientip, state FROM machine WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) + VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( + 'type' => 'machine-mismatch-cron', + 'client' => $row['clientip'], + 'description' => 'Client timed out, last known state is ' . $row['state'], + 'longdesc' => '', + 'uuid' => $row['machineuuid'], + )); + } + // Update -- yes this is not atomic. Should be sufficient for simple warnings though. Database::exec("UPDATE machine SET state = 'OFFLINE' WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); } -- cgit v1.2.3-55-g7522 From c124192e63bd8a48ed1e7caf9542dc52505dfd22 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 24 Jan 2019 12:17:07 +0100 Subject: [statistics] Handling of standby state in statistics, log crashes Or rather, not really crashes, but log whenever a client reports a poweron event without reporting a proper shutdown first. This isn't neccessarily a crash but could also be due to power loss, hard poweroff, or network failures. --- modules-available/statistics/api.inc.php | 102 +++++++++------------ modules-available/statistics/hooks/cron.inc.php | 20 +++- modules-available/statistics/inc/parser.inc.php | 10 +- .../statistics/inc/statistics.inc.php | 17 ++++ modules-available/statistics/page.inc.php | 29 +++++- 5 files changed, 107 insertions(+), 71 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 674cc48d..813e7d54 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -123,32 +123,20 @@ if ($type{0} === '~') { } } // Maybe log old crashed session - if ($uptime < 120) { + if ($uptime < 150 && $old !== false) { // See if we have a lingering session, create statistic entry if so - if ($old !== false && $old['logintime'] !== 0) { + if ($old['state'] === 'OCCUPIED' && $old['logintime'] !== 0) { $sessionLength = $old['lastseen'] - $old['logintime']; if ($sessionLength > 30 && $sessionLength < 86400*2) { - Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' - . " VALUES (:start, '~session-length', :uuid, :clientip, '', :length)", array( - 'start' => $old['logintime'], - 'uuid' => $uuid, - 'clientip' => $ip, - 'length' => $sessionLength - )); + Statistics::logMachineState($uuid, $ip, Statistics::SESSION_LENGTH, $old['logintime'], $sessionLength); } } // Write poweroff period length to statistic table - if ($old !== false && $old['lastseen'] !== 0) { + if ($old['lastseen'] !== 0) { $lastSeen = $old['lastseen']; $offtime = ($NOW - $uptime) - $lastSeen; - if ($offtime > 300 && $offtime < 86400 * 90) { - Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' - . " VALUES (:shutdown, '~offline-length', :uuid, :clientip, '', :length)", array( - 'shutdown' => $lastSeen, - 'uuid' => $uuid, - 'clientip' => $ip, - 'length' => $offtime - )); + if ($offtime > 90 && $offtime < 86400 * 30) { + Statistics::logMachineState($uuid, $ip, $old['state'] === 'STANDBY' ? Statistics::SUSPEND_LENGTH : Statistics::OFFLINE_LENGTH, $lastSeen, $offtime); } } } @@ -173,36 +161,41 @@ if ($type{0} === '~') { } else if ($type === '~runstate') { // Usage (occupied/free) $sessionLength = 0; + $strUpdateBoottime = ''; if ($old === false) die("Unknown machine.\n"); if ($old['clientip'] !== $ip) { EventLog::warning("[runstate] IP address of client $uuid seems to have changed ({$old['clientip']} -> $ip)"); die("Address changed.\n"); } $used = Request::post('used', 0, 'integer'); - if ($old['state'] === 'OFFLINE' && $NOW - $old['lastseen'] > 600) { - $strUpdateBoottime = ' lastboot = UNIX_TIMESTAMP(), '; - } else { - $strUpdateBoottime = ''; - } - // 1) Log last session length if we didn't see the machine for a while - if ($NOW - $old['lastseen'] > 610 && $old['lastseen'] !== 0) { - // Old session timed out - might be caused by hard reboot - if ($old['logintime'] !== 0) { - if ($old['lastseen'] > $old['logintime']) { - $sessionLength = $old['lastseen'] - $old['logintime']; - } - $old['logintime'] = 0; - } - } - // Figure out what's happening - state changes $params = array( 'uuid' => $uuid, 'oldlastseen' => $old['lastseen'], 'oldstate' => $old['state'], ); + if ($old['state'] === 'OFFLINE') { + // This should never happen -- we expect a poweron event before runstate, which would set the state to IDLE + // So it might be that the poweron event got lost, or that a couple of runstate events got lost, which + // caused our cron.inc.php to time out the client and reset it to OFFLINE + if ($NOW - $old['lastseen'] > 900) { + $strUpdateBoottime = ' lastboot = UNIX_TIMESTAMP(), '; + } + // 1) Log last session length if we didn't see the machine for a while + if ($NOW - $old['lastseen'] > 900 && $old['lastseen'] !== 0) { + // Old session timed out - might be caused by hard reboot + if ($old['logintime'] !== 0) { + if ($old['lastseen'] > $old['logintime']) { + $sessionLength = $old['lastseen'] - $old['logintime']; + } + } + } + } + // Figure out what's happening - state changes if ($used === 0 && $old['state'] !== 'IDLE') { - // Is not in use, was in use before - $sessionLength = $NOW - $old['logintime']; + if ($old['state'] === 'OCCUPIED' && $sessionLength === 0) { + // Is not in use, was in use before + $sessionLength = $NOW - $old['logintime']; + } $res = Database::exec('UPDATE machine SET lastseen = UNIX_TIMESTAMP(),' . $strUpdateBoottime . " logintime = 0, currentuser = NULL, state = 'IDLE' " @@ -232,13 +225,7 @@ if ($type{0} === '~') { } // 9) Log last session length if applicable if ($mode === false && $sessionLength > 0 && $sessionLength < 86400*2 && $old['logintime'] !== 0) { - Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' - . " VALUES (:start, '~session-length', :uuid, :clientip, '', :length)", array( - 'start' => $old['logintime'], - 'uuid' => $uuid, - 'clientip' => $ip, - 'length' => $sessionLength - )); + Statistics::logMachineState($uuid, $ip, Statistics::SESSION_LENGTH, $old['logintime'], $sessionLength); } } elseif ($type === '~poweroff') { if ($old === false) die("Unknown machine.\n"); @@ -246,16 +233,10 @@ if ($type{0} === '~') { EventLog::warning("[poweroff] IP address of client $uuid seems to have changed ({$old['clientip']} -> $ip)"); die("Address changed.\n"); } - if ($mode === false && $old['logintime'] !== 0) { + if ($mode === false && $old['state'] === 'OCCUPIED' && $old['logintime'] !== 0) { $sessionLength = $old['lastseen'] - $old['logintime']; if ($sessionLength > 0 && $sessionLength < 86400*2) { - Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' - . " VALUES (:start, '~session-length', :uuid, :clientip, '', :length)", array( - 'start' => $old['logintime'], - 'uuid' => $uuid, - 'clientip' => $ip, - 'length' => $sessionLength - )); + Statistics::logMachineState($uuid, $ip, Statistics::SESSION_LENGTH, $old['logintime'], $sessionLength); } } Database::exec("UPDATE machine SET logintime = 0, lastseen = UNIX_TIMESTAMP(), state = 'OFFLINE' @@ -368,13 +349,7 @@ if ($type{0} === '~') { $lastSeen = $old['lastseen']; $duration = $NOW - $lastSeen; if ($duration > 500 && $duration < 86400 * 14) { - Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' - . " VALUES (:suspend, '~suspend-length', :uuid, :clientip, '', :length)", array( - 'suspend' => $lastSeen, - 'uuid' => $uuid, - 'clientip' => $ip, - 'length' => $duration - )); + Statistics::logMachineState($uuid, $ip, Statistics::SUSPEND_LENGTH, $lastSeen, $duration); } } } else { @@ -449,9 +424,14 @@ if ($type{0} === '.') { function checkHardwareChange($old, $new) { if ($new['mbram'] !== 0) { - if ($new['mbram'] + 1000 < $old['mbram']) { - $ram1 = round($old['mbram'] / 512) / 2; - $ram2 = round($new['mbram'] / 512) / 2; + if ($new['mbram'] < 6200) { + $ram1 = ceil($old['mbram'] / 512) / 2; + $ram2 = ceil($new['mbram'] / 512) / 2; + } else { + $ram1 = ceil($old['mbram'] / 1024); + $ram2 = ceil($new['mbram'] / 1024); + } + if ($ram1 !== $ram2) { EventLog::warning('[poweron] Client ' . $new['uuid'] . ' (' . $new['clientip'] . "): RAM decreased from {$ram1}GB to {$ram2}GB"); } if (!empty($old['cpumodel']) && !empty($new['cpumodel']) && $new['cpumodel'] !== $old['cpumodel']) { diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index f05762bc..0b8e740e 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -21,10 +21,11 @@ function logstats() function state_cleanup() { // Fix online state of machines that crashed - $standby = time() - 86400 * 2; // Reset standby machines after two days + $standby = time() - 86400 * 4; // Reset standby machines after four days $on = time() - 610; // Reset others after ~10 minutes // Query for logging - $res = Database::simpleQuery("SELECT machineuuid, clientip, state FROM machine WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); + $res = Database::simpleQuery("SELECT machineuuid, clientip, state, logintime, lastseen FROM machine + WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( @@ -34,9 +35,20 @@ function state_cleanup() 'longdesc' => '', 'uuid' => $row['machineuuid'], )); + if ($row['state'] === 'OCCUPIED') { + $length = $row['lastseen'] - $row['logintime']; + if ($length > 0 && $length < 86400 * 7) { + Statistics::logMachineState($row['machineuuid'], $row['clientip'], Statistics::SESSION_LENGTH, $row['logintime'], $length); + } + } elseif ($row['state'] === 'STANDBY') { + $length = time() - $row['lastseen']; + if ($length > 0 && $length < 86400 * 7) { + Statistics::logMachineState($row['machineuuid'], $row['clientip'], Statistics::SUSPEND_LENGTH, $row['lastseen'], $length); + } + } } - // Update -- yes this is not atomic. Should be sufficient for simple warnings though. - Database::exec("UPDATE machine SET state = 'OFFLINE' WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); + // Update -- yes this is not atomic. Should be sufficient for simple warnings and bookkeeping though. + Database::exec("UPDATE machine SET logintime = 0, state = 'OFFLINE' WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); } state_cleanup(); diff --git a/modules-available/statistics/inc/parser.inc.php b/modules-available/statistics/inc/parser.inc.php index b179b4a3..0d39079d 100644 --- a/modules-available/statistics/inc/parser.inc.php +++ b/modules-available/statistics/inc/parser.inc.php @@ -104,10 +104,12 @@ class Parser { foreach ($lines as $line) { if (preg_match('/^Disk (\S+):.* (\d+) bytes/i', $line, $out)) { // --- Beginning of MBR disk --- + unset($hdd); if ($out[2] < 10000) // sometimes vmware reports lots of 512byte disks continue; + if (substr($out[1], 0, 8) === '/dev/dm-') // Ignore device mapper + continue; // disk total size and name - unset($hdd); $mbrToMbFactor = 0; // This is != 0 for mbr $sectorToMbFactor = 0; // This is != for gpt $hdd = array( @@ -122,10 +124,12 @@ class Parser { $hdds[] = &$hdd; } elseif (preg_match('/^Disk (\S+):\s+(\d+)\s+sectors,/i', $line, $out)) { // --- Beginning of GPT disk --- + unset($hdd); if ($out[2] < 1000) // sometimes vmware reports lots of 512byte disks continue; + if (substr($out[1], 0, 8) === '/dev/dm-') // Ignore device mapper + continue; // disk total size and name - unset($hdd); $mbrToMbFactor = 0; // This is != 0 for mbr $sectorToMbFactor = 0; // This is != for gpt $hdd = array( @@ -213,7 +217,7 @@ class Parser { $hdd['size'] = round(($hdd['sectors'] * $sectorToMbFactor) / 1024); } $free = $hdd['size'] - $hdd['used']; - if ($free > 5 || ($free / $hdd['size']) > 0.1) { + if ($hdd['size'] > 0 && ($free > 5 || ($free / $hdd['size']) > 0.1)) { $hdd['partitions'][] = array( 'id' => 'free-id-' . $i, 'name' => Dictionary::translate('unused'), diff --git a/modules-available/statistics/inc/statistics.inc.php b/modules-available/statistics/inc/statistics.inc.php index 2500f16f..1f8a081a 100644 --- a/modules-available/statistics/inc/statistics.inc.php +++ b/modules-available/statistics/inc/statistics.inc.php @@ -70,4 +70,21 @@ class Statistics return $list; } + const SESSION_LENGTH = '~session-length'; + const OFFLINE_LENGTH = '~offline-length'; + const SUSPEND_LENGTH = '~suspend-length'; + + public static function logMachineState($uuid, $ip, $type, $start, $length, $username = '') + { + return Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' + . " VALUES (:start, :type, :uuid, :clientip, :username, :length)", array( + 'start' => $start, + 'type' => $type, + 'uuid' => $uuid, + 'clientip' => $ip, + 'username' => $username, + 'length' => $length, + )); + } + } diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index abacc8d2..2d86615e 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -910,16 +910,18 @@ class Page_Statistics extends Page //if ($cutoff < $client['firstseen']) $cutoff = $client['firstseen']; $scale = 100 / ($NOW - $cutoff); $res = Database::simpleQuery('SELECT dateline, typeid, data FROM statistic' - . " WHERE dateline > :cutoff AND typeid IN ('~session-length', '~offline-length') AND machineuuid = :uuid ORDER BY dateline ASC", array( + . " WHERE dateline > :cutoff AND typeid IN (:sessionLength, :offlineLength) AND machineuuid = :uuid ORDER BY dateline ASC", array( 'cutoff' => $cutoff - 86400 * 14, 'uuid' => $uuid, + 'sessionLength' => Statistics::SESSION_LENGTH, + 'offlineLength' => Statistics::OFFLINE_LENGTH, )); $spans['rows'] = array(); $spans['graph'] = ''; $last = false; $first = true; while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if (!$client['isclient'] && $row['typeid'] === '~session-length') + if (!$client['isclient'] && $row['typeid'] === Statistics::SESSION_LENGTH) continue; // Don't differentiate between session and idle for non-clients if ($first && $row['dateline'] > $cutoff && $client['lastboot'] > $cutoff) { // Special case: offline before @@ -945,9 +947,12 @@ class Page_Statistics extends Page } $row['from'] = Util::prettyTime($row['dateline']); $row['duration'] = floor($row['data'] / 86400) . 'd ' . gmdate('H:i', $row['data']); - if ($row['typeid'] === '~offline-length') { + if ($row['typeid'] === Statistics::OFFLINE_LENGTH) { $row['glyph'] = 'off'; $color = '#444'; + } elseif ($row['typeid'] === Statistics::SUSPEND_LENGTH) { + $row['glyph'] = 'pause'; + $color = '#686'; } else { $row['glyph'] = 'user'; $color = '#e77'; @@ -967,8 +972,26 @@ class Page_Statistics extends Page } if ($client['state'] === 'OCCUPIED') { $spans['graph'] .= '
 
'; + $spans['rows'][] = [ + 'from' => Util::prettyTime($client['logintime']), + 'duration' => '-', + 'glyph' => 'user', + ]; + $row['duration'] = floor($row['data'] / 86400) . 'd ' . gmdate('H:i', $row['data']); } elseif ($client['state'] === 'OFFLINE') { $spans['graph'] .= '
 
'; + $spans['rows'][] = [ + 'from' => Util::prettyTime($client['lastseen']), + 'duration' => '-', + 'glyph' => 'off', + ]; + } elseif ($client['state'] === 'STANDBY') { + $spans['graph'] .= '
 
'; + $spans['rows'][] = [ + 'from' => Util::prettyTime($client['lastseen']), + 'duration' => '-', + 'glyph' => 'pause', + ]; } $t = explode('-', date('Y-n-j-G', $cutoff)); if ($t[3] >= 8 && $t[3] <= 22) { -- cgit v1.2.3-55-g7522 From 9ae2c70073490a253ccf2fcb567d57b07811389b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 24 Jan 2019 17:31:38 +0100 Subject: [statistics] Minor refactoring (PHP >= 5.6) --- modules-available/statistics/inc/filter.inc.php | 16 ++++--- modules-available/statistics/page.inc.php | 58 ++++++++++++------------- 2 files changed, 38 insertions(+), 36 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index 3ccea2c3..46de467b 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -14,6 +14,13 @@ class Filter public $operator; public $argument; + private static $keyCounter = 0; + + public static function getNewKey($colname) + { + return $colname . '_' . (self::$keyCounter++); + } + public function __construct($column, $operator, $argument = null) { $this->column = trim($column); @@ -24,8 +31,7 @@ class Filter /* returns a where clause and adds needed operators to the passed array */ public function whereClause(&$args, &$joins) { - global $unique_key; - $key = $this->column . '_arg' . ($unique_key++); + $key = Filter::getNewKey($this->column); $addendum = ''; /* check if we have to do some parsing*/ @@ -226,8 +232,7 @@ class StateFilter extends Filter $map = [ 'on' => ['IDLE', 'OCCUPIED'], 'off' => ['OFFLINE'], 'idle' => ['IDLE'], 'occupied' => ['OCCUPIED'], 'standby' => ['STANDBY'] ]; $neg = $this->operator == '!=' ? 'NOT ' : ''; if (array_key_exists($this->argument, $map)) { - global $unique_key; - $key = $this->column . '_arg' . ($unique_key++); + $key = Filter::getNewKey($this->column); $args[$key] = $map[$this->argument]; return " machine.state $neg IN ( :$key ) "; } else { @@ -259,8 +264,7 @@ class LocationFilter extends Filter if ($this->argument === 0) { return "machine.locationid IS $neg NULL"; } else { - global $unique_key; - $key = $this->column . '_arg' . ($unique_key++); + $key = Filter::getNewKey($this->column); if ($recursive) { $args[$key] = array_keys(Location::getRecursiveFlat($this->argument)); } else { diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 2d86615e..c9a0cac5 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -1,7 +1,6 @@ =', '=', '<', '>']; + const OP_STRCMP = ['!~', '~', '=', '!=']; public static $columns; private $query; @@ -27,123 +26,120 @@ class Page_Statistics extends Page */ private $haveSubpage; - /* PHP sucks, no static, const array definitions... Or am I missing something? */ - public function initConstants() + /** + * Do this here instead of const since we need to check for available modules while building array. + */ + public static function initConstants() { - Page_Statistics::$op_nominal = ['!=', '=']; - Page_Statistics::$op_ordinal = ['!=', '<=', '>=', '=', '<', '>']; - Page_Statistics::$op_stringcmp = ['!~', '~', '=', '!=']; Page_Statistics::$columns = [ 'machineuuid' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'string', 'column' => true, ], 'macaddr' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'string', 'column' => true, ], 'firstseen' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'date', 'column' => true, ], 'lastseen' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'date', 'column' => true, ], 'logintime' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'date', 'column' => true, ], 'realcores' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'int', 'column' => true, ], 'systemmodel' => [ - 'op' => Page_Statistics::$op_stringcmp, + 'op' => Page_Statistics::OP_STRCMP, 'type' => 'string', 'column' => true, ], 'cpumodel' => [ - 'op' => Page_Statistics::$op_stringcmp, + 'op' => Page_Statistics::OP_STRCMP, 'type' => 'string', 'column' => true, ], 'hddgb' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'int', 'column' => false, 'map_sort' => 'id44mb' ], 'gbram' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'int', 'map_sort' => 'mbram', 'column' => false, ], 'kvmstate' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'enum', 'column' => true, 'values' => ['ENABLED', 'DISABLED', 'UNSUPPORTED'] ], 'badsectors' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'int', 'column' => true ], 'clientip' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'string', 'column' => true ], 'hostname' => [ - 'op' => Page_Statistics::$op_stringcmp, + 'op' => Page_Statistics::OP_STRCMP, 'type' => 'string', 'column' => true ], 'subnet' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'string', 'column' => false ], 'currentuser' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'string', 'column' => true ], 'state' => [ - 'op' => Page_Statistics::$op_nominal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'enum', 'column' => true, 'values' => ['occupied', 'on', 'off', 'idle', 'standby'] ], 'runtime' => [ - 'op' => Page_Statistics::$op_ordinal, + 'op' => Page_Statistics::OP_NOMINAL, 'type' => 'int', 'column' => true ], ]; if (Module::isAvailable('locations')) { Page_Statistics::$columns['location'] = [ - 'op' => Page_Statistics::$op_stringcmp, + 'op' => Page_Statistics::OP_STRCMP, 'type' => 'enum', 'column' => false, 'values' => array_keys(Location::getLocationsAssoc()), ]; } - /* TODO ... */ } protected function doPreprocess() { - $this->initConstants(); User::load(); if (!User::isLoggedIn()) { Message::addError('main.no-permission'); @@ -1127,3 +1123,5 @@ class Page_Statistics extends Page ), true); } } + +Page_Statistics::initConstants(); -- cgit v1.2.3-55-g7522 From 3b1df888c963d906005ff139892df06a0d1ae2b4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 28 Jan 2019 13:48:35 +0100 Subject: [statistics] Track and display memory/tmp usage of clients --- modules-available/statistics/api.inc.php | 13 ++++++-- modules-available/statistics/hooks/cron.inc.php | 9 ++++-- modules-available/statistics/install.inc.php | 17 ++++++++++ .../statistics/lang/de/template-tags.json | 4 +++ .../statistics/lang/en/template-tags.json | 4 +++ modules-available/statistics/page.inc.php | 37 ++++++++++++++++------ modules-available/statistics/style.css | 32 +++++++++++++++++++ .../statistics/templates/filterbox.html | 5 ++- .../statistics/templates/machine-main.html | 33 ++++++++++++++++--- 9 files changed, 135 insertions(+), 19 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 813e7d54..57c4cee2 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -34,7 +34,8 @@ if ($type{0} === '~') { // External mode of operation? $mode = Request::post('mode', false, 'string'); $NOW = time(); - $old = Database::queryFirst('SELECT clientip, logintime, lastseen, lastboot, state, mbram, cpumodel FROM machine WHERE machineuuid = :uuid', array('uuid' => $uuid)); + $old = Database::queryFirst('SELECT clientip, logintime, lastseen, lastboot, state, mbram, cpumodel, live_memfree, live_swapfree, live_tmpfree + FROM machine WHERE machineuuid = :uuid', array('uuid' => $uuid)); if ($old !== false) { settype($old['logintime'], 'integer'); settype($old['lastseen'], 'integer'); @@ -114,6 +115,7 @@ if ($type{0} === '~') { . ' cpumodel = :cpumodel,' . ' systemmodel = :systemmodel,' . ' id44mb = :id44mb,' + . ' live_tmpsize = 0, live_swapsize = 0, live_memsize = 0,' . ' badsectors = :badsectors,' . ' data = :data,' . ' state = :state ' @@ -152,7 +154,10 @@ if ($type{0} === '~') { // Log potential crash if ($old['state'] === 'IDLE' || $old['state'] === 'OCCUPIED') { - writeClientLog('machine-mismatch-poweron', 'Client sent poweron event, but previous known state is ' . $old['state']); + writeClientLog('machine-mismatch-poweron', 'Poweron event, but previous known state is ' . $old['state'] + . '. RAM: ' . Util::readableFileSize($old['live_memfree'], -1, 2) + . ', Swap: ' . Util::readableFileSize($old['live_swapfree'], -1, 2) + . ', ID44: ' . Util::readableFileSize($old['live_memfree'], -1, 2)); } } @@ -190,6 +195,10 @@ if ($type{0} === '~') { } } } + foreach (['memsize', 'tmpsize', 'swapsize', 'memfree', 'tmpfree', 'swapfree'] as $item) { + $strUpdateBoottime .= ' live_' . $item . ' = :_' . $item . ', '; + $params['_' . $item] = ceil(Request::post($item, 0, 'int') / 1024); + } // Figure out what's happening - state changes if ($used === 0 && $old['state'] !== 'IDLE') { if ($old['state'] === 'OCCUPIED' && $sessionLength === 0) { diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index 0b8e740e..f22d0475 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -24,14 +24,17 @@ function state_cleanup() $standby = time() - 86400 * 4; // Reset standby machines after four days $on = time() - 610; // Reset others after ~10 minutes // Query for logging - $res = Database::simpleQuery("SELECT machineuuid, clientip, state, logintime, lastseen FROM machine - WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); + $res = Database::simpleQuery("SELECT machineuuid, clientip, state, logintime, lastseen, live_memfree, live_swapfree, live_tmpfree + FROM machine WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( 'type' => 'machine-mismatch-cron', 'client' => $row['clientip'], - 'description' => 'Client timed out, last known state is ' . $row['state'], + 'description' => 'Client timed out, last known state is ' . $row['state'] + . '. RAM: ' . Util::readableFileSize($row['live_memfree'], -1, 2) + . ', Swap: ' . Util::readableFileSize($row['live_swapfree'], -1, 2) + . ', ID44: ' . Util::readableFileSize($row['live_memfree'], -1, 2), 'longdesc' => '', 'uuid' => $row['machineuuid'], )); diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php index 4e2dfcca..84e038a4 100644 --- a/modules-available/statistics/install.inc.php +++ b/modules-available/statistics/install.inc.php @@ -234,5 +234,22 @@ if (!tableHasColumn('machine', 'state')) { $res[] = UPDATE_DONE; } +// 2019-01-25: Add memory/temp stats column +if (!tableHasColumn('machine', 'live_tmpsize')) { + $ret = Database::exec("ALTER TABLE `machine` + ADD COLUMN `live_tmpsize` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `id44mb`, + ADD COLUMN `live_tmpfree` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `live_tmpsize`, + ADD COLUMN `live_swapsize` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `live_tmpfree`, + ADD COLUMN `live_swapfree` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `live_swapsize`, + ADD COLUMN `live_memsize` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `live_swapfree`, + ADD COLUMN `live_memfree` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `live_memsize`, + ADD INDEX `live_tmpfree` (`live_tmpfree`), + ADD INDEX `live_memfree` (`live_memfree`)"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding state column to machine table failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} + // Create response responseFromArray($res); diff --git a/modules-available/statistics/lang/de/template-tags.json b/modules-available/statistics/lang/de/template-tags.json index 84c4690c..2567eea1 100644 --- a/modules-available/statistics/lang/de/template-tags.json +++ b/modules-available/statistics/lang/de/template-tags.json @@ -14,6 +14,7 @@ "lang_event": "Ereignis", "lang_eventType": "Typ", "lang_firstSeen": "Erste Aktivit\u00e4t", + "lang_free": "frei", "lang_gbRam": "RAM", "lang_hardwareSummary": "Hardware", "lang_hdds": "Festplatten", @@ -40,6 +41,7 @@ "lang_machineStandby": "Im Standby", "lang_machineSummary": "Zusammenfassung", "lang_maximumAbbrev": "Max.", + "lang_memFree": "RAM frei (MB)", "lang_memoryStats": "Arbeitsspeicher", "lang_model": "Modell", "lang_modelCount": "Anzahl", @@ -82,10 +84,12 @@ "lang_subnet": "Subnetz", "lang_sureDeletePermanent": "M\u00f6chten Sie diese(n) Rechner wirklich unwiderruflich aus der Datenbank entfernen?\r\n\r\nWichtig: L\u00f6schen verhindert nicht, dass ein Rechner nach erneutem Starten von bwLehrpool wieder in die Datenbank aufgenommen wird.", "lang_sureReplaceNoUndo": "Wollen Sie die Daten ausgew\u00e4hlten Rechner \u00fcbertragen? Diese Aktion kann nicht r\u00fcckg\u00e4ngig gemacht werden.", + "lang_swapFree": "swap frei (MB)", "lang_tempPart": "Temp. Partition", "lang_tempPartStats": "Tempor\u00e4re Partition", "lang_thoseAreProjectors": "Diese Modellnamen werden als Beamer behandelt, auch wenn die EDID-Informationen des Ger\u00e4tes anderes berichten.", "lang_timebarDesc": "Visuelle Darstellung der letzten Tage. Rote Abschnitte zeigen, wann der Rechner belegt war, gr\u00fcne, wann er nicht verwendet wurde, aber eingeschaltet war. Die leicht abgedunkelten Abschnitte markieren N\u00e4chte (22 bis 8 Uhr).", + "lang_tmpFree": "ID44 frei (MB)", "lang_tmpGb": "Temp-HDD", "lang_total": "Gesamt", "lang_usageDetails": "Nutzungsdetails", diff --git a/modules-available/statistics/lang/en/template-tags.json b/modules-available/statistics/lang/en/template-tags.json index b064ee50..1d9cd4da 100644 --- a/modules-available/statistics/lang/en/template-tags.json +++ b/modules-available/statistics/lang/en/template-tags.json @@ -14,6 +14,7 @@ "lang_event": "Event", "lang_eventType": "Type", "lang_firstSeen": "First seen", + "lang_free": "free", "lang_gbRam": "RAM", "lang_hardwareSummary": "Hardware", "lang_hdds": "Hard disk drives", @@ -40,6 +41,7 @@ "lang_machineStandby": "In standby mode", "lang_machineSummary": "Summary", "lang_maximumAbbrev": "max.", + "lang_memFree": "RAM free (MB)", "lang_memoryStats": "Memory", "lang_model": "Model", "lang_modelCount": "Count", @@ -82,10 +84,12 @@ "lang_subnet": "Subnet", "lang_sureDeletePermanent": "Are your sure you want to delete the selected machine(s) from the database? This cannot be undone.\r\n\r\nNote: Deleting machines from the database does not prevent booting up bwLehrpool again, which would recreate their respective database entries.", "lang_sureReplaceNoUndo": "Are you sure you want to replace the selected machine pairs? This action cannot be undone.", + "lang_swapFree": "swap free (MB)", "lang_tempPart": "Temp. partition", "lang_tempPartStats": "Temporary partition", "lang_thoseAreProjectors": "These model names will always be treated as beamers, even if the device's EDID data says otherwise.", "lang_timebarDesc": "Visual representation of the last few days. Red parts mark periods where the client was occupied, green parts where the client was idle. Dimmed parts mark nights (10pm to 8am).", + "lang_tmpFree": "ID44 free (MB)", "lang_tmpGb": "Temp HDD", "lang_total": "Total", "lang_usageDetails": "Detailed usage", diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index c9a0cac5..a9cde6fb 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -122,8 +122,18 @@ class Page_Statistics extends Page 'column' => true, 'values' => ['occupied', 'on', 'off', 'idle', 'standby'] ], - 'runtime' => [ - 'op' => Page_Statistics::OP_NOMINAL, + 'live_swapfree' => [ + 'op' => Page_Statistics::OP_ORDINAL, + 'type' => 'int', + 'column' => true + ], + 'live_memfree' => [ + 'op' => Page_Statistics::OP_ORDINAL, + 'type' => 'int', + 'column' => true + ], + 'live_tmpfree' => [ + 'op' => Page_Statistics::OP_ORDINAL, 'type' => 'int', 'column' => true ], @@ -764,9 +774,9 @@ class Page_Statistics extends Page $row['currentsession'] = $lecture['displayname']; $row['lectureid'] = $lecture['lectureid']; } + $row['session'] = $row['currentsession']; + return; } - $row['session'] = $row['currentsession']; - return; } $res = Database::simpleQuery('SELECT dateline, username, data FROM statistic' . " WHERE clientip = :ip AND typeid = '.vmchooser-session-name'" @@ -783,14 +793,17 @@ class Page_Statistics extends Page } if ($session !== false) { $row['session'] = $session['data']; - $row['username'] = $session['username']; + if (empty($row['currentuser'])) { + $row['username'] = $session['username']; + } } } private function showMachine($uuid) { - $client = Database::queryFirst('SELECT machineuuid, locationid, macaddr, clientip, firstseen, lastseen, logintime, lastboot, state,' - . ' mbram, kvmstate, cpumodel, id44mb, data, hostname, currentuser, currentsession, notes FROM machine WHERE machineuuid = :uuid', + $client = Database::queryFirst('SELECT machineuuid, locationid, macaddr, clientip, firstseen, lastseen, logintime, lastboot, state, + mbram, live_tmpsize, live_tmpfree, live_swapsize, live_swapfree, live_memsize, live_memfree, + kvmstate, cpumodel, id44mb, data, hostname, currentuser, currentsession, notes FROM machine WHERE machineuuid = :uuid', array('uuid' => $uuid)); if ($client === false) { Message::addError('unknown-machine', $uuid); @@ -826,6 +839,7 @@ class Page_Statistics extends Page $client['state_' . $client['state']] = true; $client['firstseen_s'] = date('d.m.Y H:i', $client['firstseen']); $client['lastseen_s'] = date('d.m.Y H:i', $client['lastseen']); + $client['logintime_s'] = date('d.m.Y H:i', $client['logintime']); if ($client['lastboot'] == 0) { $client['lastboot_s'] = '-'; } else { @@ -835,9 +849,14 @@ class Page_Statistics extends Page $client['lastboot_s'] .= ' (Up ' . floor($uptime / 86400) . 'd ' . gmdate('H:i', $uptime) . ')'; } } - $client['logintime_s'] = date('d.m.Y H:i', $client['logintime']); - $client['gbram'] = round(round($client['mbram'] / 500) / 2, 1); + $client['gbram'] = round(ceil($client['mbram'] / 512) / 2, 1); $client['gbtmp'] = round($client['id44mb'] / 1024); + foreach (['tmp', 'swap', 'mem'] as $item) { + if ($client['live_' . $item . 'size'] == 0) + continue; + $client['live_' . $item . 'percent'] = round(($client['live_' . $item . 'free'] / $client['live_' . $item . 'size']) * 100, 2); + $client['live_' . $item . 'free_s'] = Util::readableFileSize($client['live_' . $item . 'free'], -1, 2); + } $client['ramclass'] = $this->ramColorClass($client['mbram']); $client['kvmclass'] = $this->kvmColorClass($client['kvmstate']); $client['hddclass'] = $this->hddColorClass($client['gbtmp']); diff --git a/modules-available/statistics/style.css b/modules-available/statistics/style.css index 1496ac87..c48275ba 100644 --- a/modules-available/statistics/style.css +++ b/modules-available/statistics/style.css @@ -8,4 +8,36 @@ border-radius: 25px; font-size: 20px; line-height: 40px; +} + +.meter { + position: relative; + border-radius: 5px; + border: 1px solid #999; + background: linear-gradient(to right, #9e6 0%, #fb8 66%, #f32 100%); + height: 1.25em; + padding: 0; + width: 100%; + overflow: hidden; +} + +.meter .bar { + position: absolute; + top: 0; + height: 100%; + right: 0; + background: #efe; + display: inline-block; + padding: 0; + margin: 0 0 0 auto; +} + +.meter .text { + position: absolute; + right: 5px; + overflow: visible; + font-size: 8pt; + white-space: nowrap; + z-index: 1000; + text-shadow: #fff 1px 1px; } \ No newline at end of file diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index cd8ec24d..07aa7320 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -101,7 +101,10 @@ var slxFilterNames = { currentuser: '{{lang_currentUser}}', subnet: '{{lang_subnet}}', runtime: '{{lang_runtimeHours}}', - hostname: '{{lang_hostname}}' + hostname: '{{lang_hostname}}', + live_swapfree: '{{lang_swapFree}}', + live_memfree: '{{lang_memFree}}', + live_tmpfree: '{{lang_tmpFree}}' }; slxLocations = {{{locations}}}; diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html index f1021482..904c780b 100644 --- a/modules-available/statistics/templates/machine-main.html +++ b/modules-available/statistics/templates/machine-main.html @@ -1,3 +1,4 @@ +{{%FILTERS}}

{{hostname}} {{#hostname}}–{{/hostname}} {{clientip}} {{#notes}}{{/notes}} @@ -117,9 +118,23 @@ {{lang_ram}} - {{gbram}} GiB - {{#maxram}}({{lang_maximumAbbrev}} {{maxram}}){{/maxram}} - {{ramtype}} +
+ {{gbram}} GiB + {{#maxram}}({{lang_maximumAbbrev}} {{maxram}}){{/maxram}} + {{ramtype}} +
+ {{#live_memsize}} +
+
{{live_memfree_s}} {{lang_free}}
+
+
+ {{/live_memsize}} + {{#live_swapsize}} +
+
{{live_swapfree_s}} {{lang_free}}
+
+
+ {{/live_swapsize}} {{#extram}} @@ -135,7 +150,17 @@ {{/extram}} {{lang_tempPart}} - {{gbtmp}} GiB + +
+ {{gbtmp}} GiB +
+ {{#live_tmpsize}} +
+
{{live_tmpfree_s}} {{lang_free}}
+
+
+ {{/live_tmpsize}} + {{lang_64bitSupport}} -- cgit v1.2.3-55-g7522 From 8c5c14eb4ad2fcaeb35d746d2183943f6dc52fb1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 28 Jan 2019 14:33:16 +0100 Subject: [statistics] Cleanup template --- modules-available/statistics/templates/machine-main.html | 1 - 1 file changed, 1 deletion(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html index 904c780b..44f03a99 100644 --- a/modules-available/statistics/templates/machine-main.html +++ b/modules-available/statistics/templates/machine-main.html @@ -1,4 +1,3 @@ -{{%FILTERS}}

{{hostname}} {{#hostname}}–{{/hostname}} {{clientip}} {{#notes}}{{/notes}} -- cgit v1.2.3-55-g7522 From 1b53e1ac441f547e4524a512eff3d6b25457f95e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 28 Jan 2019 14:38:47 +0100 Subject: [statistics] Fix copypasta --- modules-available/statistics/api.inc.php | 2 +- modules-available/statistics/hooks/cron.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 57c4cee2..280e5abc 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -157,7 +157,7 @@ if ($type{0} === '~') { writeClientLog('machine-mismatch-poweron', 'Poweron event, but previous known state is ' . $old['state'] . '. RAM: ' . Util::readableFileSize($old['live_memfree'], -1, 2) . ', Swap: ' . Util::readableFileSize($old['live_swapfree'], -1, 2) - . ', ID44: ' . Util::readableFileSize($old['live_memfree'], -1, 2)); + . ', ID44: ' . Util::readableFileSize($old['live_tmpfree'], -1, 2)); } } diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index f22d0475..6393b2c6 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -34,7 +34,7 @@ function state_cleanup() 'description' => 'Client timed out, last known state is ' . $row['state'] . '. RAM: ' . Util::readableFileSize($row['live_memfree'], -1, 2) . ', Swap: ' . Util::readableFileSize($row['live_swapfree'], -1, 2) - . ', ID44: ' . Util::readableFileSize($row['live_memfree'], -1, 2), + . ', ID44: ' . Util::readableFileSize($row['live_tmpfree'], -1, 2), 'longdesc' => '', 'uuid' => $row['machineuuid'], )); -- cgit v1.2.3-55-g7522 From a46ab41355a1ca1a7507358c07045b0ba5ae1f59 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 19 Feb 2019 16:24:22 +0100 Subject: [statistics] Fix RAM change warning to handle increase too --- modules-available/statistics/api.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules-available/statistics') diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 280e5abc..d4b8f346 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -441,7 +441,8 @@ function checkHardwareChange($old, $new) $ram2 = ceil($new['mbram'] / 1024); } if ($ram1 !== $ram2) { - EventLog::warning('[poweron] Client ' . $new['uuid'] . ' (' . $new['clientip'] . "): RAM decreased from {$ram1}GB to {$ram2}GB"); + $word = $ram1 > $ram2 ? 'decreased' : 'increased'; + EventLog::warning('[poweron] Client ' . $new['uuid'] . ' (' . $new['clientip'] . "): RAM $word from {$ram1}GB to {$ram2}GB"); } if (!empty($old['cpumodel']) && !empty($new['cpumodel']) && $new['cpumodel'] !== $old['cpumodel']) { EventLog::warning('[poweron] Client ' . $new['uuid'] . ' (' . $new['clientip'] . "): CPU changed from '{$old['cpumodel']}' to '{$new['cpumodel']}'"); -- cgit v1.2.3-55-g7522