summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-07-29 12:18:36 +0200
committerSimon Rettberg2016-07-29 12:18:36 +0200
commit6abbd2bf9a0dafa93e92928a269820eaa127b12b (patch)
treed44eb55035a84f73e1795d93e2f26be6ddada0df /modules-available/statistics/page.inc.php
parent[baseconfig] Rework makeInput to prevent generating invalid tag attribs (diff)
downloadslx-admin-6abbd2bf9a0dafa93e92928a269820eaa127b12b.tar.gz
slx-admin-6abbd2bf9a0dafa93e92928a269820eaa127b12b.tar.xz
slx-admin-6abbd2bf9a0dafa93e92928a269820eaa127b12b.zip
[statistics] Make filtering more dynamic, remove hard cutoff from summary
Diffstat (limited to 'modules-available/statistics/page.inc.php')
-rw-r--r--modules-available/statistics/page.inc.php40
1 files changed, 32 insertions, 8 deletions
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index ca0ea96e..7ffe2562 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -148,7 +148,10 @@ class Page_Statistics extends Page
}
/* read filter */
- $this->query = Request::any('filters');
+ $this->query = Request::any('filters', false);
+ if ($this->query === false) {
+ $this->query = 'lastseen > ' . gmdate('Y-m-d', strtotime('-30 day'));
+ }
$sortColumn = Request::any('sortColumn');
$sortDirection = Request::any('sortDirection');
$filters = Filter::parseQuery($this->query);
@@ -174,6 +177,9 @@ class Page_Statistics extends Page
Render::closeTag('div');
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showFilter($show, $filterSet)
{
$data = array(
@@ -237,16 +243,18 @@ class Page_Statistics extends Page
}
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showSummary($filterSet)
{
$filterSet->makeFragments($where, $join, $sort, $args);
- $cutoff = time() - 86400 * 30;
$online = time() - 610;
- $known = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastseen > $cutoff AND $where", $args);
- $on = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastseen > $online AND $where", $args);
- $used = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastseen > $online AND logintime <> 0 AND $where", $args);
- $hdd = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE badsectors > 10 AND lastseen > $cutoff AND $where", $args);
+ $known = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE ($where)", $args);
+ $on = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastseen > $online AND ($where)", $args);
+ $used = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastseen > $online AND logintime <> 0 AND ($where)", $args);
+ $hdd = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE badsectors >= 10 AND ($where)", $args);
if ($on['val'] != 0) {
$usedpercent = round($used['val'] / $on['val'] * 100);
} else {
@@ -287,6 +295,9 @@ class Page_Statistics extends Page
Render::addTemplate('summary', $data);
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showSystemModels($filterSet)
{
global $STATS_COLORS;
@@ -317,6 +328,9 @@ class Page_Statistics extends Page
Render::addTemplate('cpumodels', array('rows' => $lines, 'query' => $this->query, 'json' => json_encode($json)));
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showMemory($filterSet)
{
global $STATS_COLORS, $SIZE_RAM;
@@ -362,6 +376,9 @@ class Page_Statistics extends Page
Render::addTemplate('memory', $data);
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showKvmState($filterSet)
{
$filterSet->makeFragments($where, $join, $sort, $args);
@@ -381,6 +398,9 @@ class Page_Statistics extends Page
Render::addTemplate('kvmstate', array('rows' => $lines, 'query' => $this->query,'json' => json_encode($json)));
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showId44($filterSet)
{
global $STATS_COLORS, $SIZE_ID44;
@@ -432,6 +452,9 @@ class Page_Statistics extends Page
Render::addTemplate('id44', $data);
}
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showLatestMachines($filterSet)
{
$filterSet->makeFragments($where, $join, $sort, $args);
@@ -461,7 +484,9 @@ class Page_Statistics extends Page
Render::addTemplate('newclients', array('rows' => $rows, 'openbutton' => $count > 5));
}
-
+ /**
+ * @param \FilterSet $filterSet
+ */
private function showMachineList($filterSet)
{
$filterSet->makeFragments($where, $join, $sort, $args);
@@ -504,7 +529,6 @@ class Page_Statistics extends Page
'sortDirection' => $filterSet->getSortDirection(),
'sortColumn' => $filterSet->getSortColumn(),
'columns' => json_encode(Page_Statistics::$columns),
- 'locations' => json_encode($locsFlat),
'showList' => 1,
'show' => 'list'
));