From 50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Tue, 3 May 2016 19:03:09 +0200
Subject: WIP
---
modules/statistics/config.json | 5 -
modules/statistics/lang/de/module.json | 4 -
.../statistics/lang/de/templates/clientlist.json | 14 -
.../statistics/lang/de/templates/cpumodels.json | 6 -
modules/statistics/lang/de/templates/id44.json | 5 -
modules/statistics/lang/de/templates/kvmstate.json | 5 -
.../statistics/lang/de/templates/machine-hdds.json | 13 -
.../statistics/lang/de/templates/machine-main.json | 26 -
.../lang/de/templates/machine-notes.json | 4 -
.../lang/de/templates/machine-usage.json | 4 -
modules/statistics/lang/de/templates/memory.json | 5 -
.../statistics/lang/de/templates/newclients.json | 4 -
modules/statistics/lang/de/templates/summary.json | 6 -
modules/statistics/lang/de/templates/syslog.json | 7 -
modules/statistics/lang/en/module.json | 3 -
.../statistics/lang/en/templates/clientlist.json | 14 -
.../statistics/lang/en/templates/cpumodels.json | 6 -
modules/statistics/lang/en/templates/id44.json | 5 -
modules/statistics/lang/en/templates/kvmstate.json | 5 -
.../statistics/lang/en/templates/machine-hdds.json | 13 -
.../statistics/lang/en/templates/machine-main.json | 26 -
.../lang/en/templates/machine-notes.json | 4 -
.../lang/en/templates/machine-usage.json | 4 -
modules/statistics/lang/en/templates/memory.json | 5 -
.../statistics/lang/en/templates/newclients.json | 4 -
modules/statistics/lang/en/templates/summary.json | 6 -
modules/statistics/lang/en/templates/syslog.json | 7 -
modules/statistics/page.inc.php | 792 ---------------------
modules/statistics/templates/clientlist.html | 45 --
modules/statistics/templates/cpumodels.html | 51 --
modules/statistics/templates/id44.html | 48 --
modules/statistics/templates/kvmstate.html | 47 --
modules/statistics/templates/machine-hdds.html | 67 --
modules/statistics/templates/machine-main.html | 124 ----
modules/statistics/templates/machine-notes.html | 17 -
modules/statistics/templates/machine-usage.html | 51 --
modules/statistics/templates/memory.html | 47 --
modules/statistics/templates/newclients.html | 44 --
modules/statistics/templates/summary.html | 33 -
modules/statistics/templates/syslog.html | 43 --
40 files changed, 1619 deletions(-)
delete mode 100644 modules/statistics/config.json
delete mode 100644 modules/statistics/lang/de/module.json
delete mode 100644 modules/statistics/lang/de/templates/clientlist.json
delete mode 100644 modules/statistics/lang/de/templates/cpumodels.json
delete mode 100644 modules/statistics/lang/de/templates/id44.json
delete mode 100644 modules/statistics/lang/de/templates/kvmstate.json
delete mode 100644 modules/statistics/lang/de/templates/machine-hdds.json
delete mode 100644 modules/statistics/lang/de/templates/machine-main.json
delete mode 100644 modules/statistics/lang/de/templates/machine-notes.json
delete mode 100644 modules/statistics/lang/de/templates/machine-usage.json
delete mode 100644 modules/statistics/lang/de/templates/memory.json
delete mode 100644 modules/statistics/lang/de/templates/newclients.json
delete mode 100644 modules/statistics/lang/de/templates/summary.json
delete mode 100644 modules/statistics/lang/de/templates/syslog.json
delete mode 100644 modules/statistics/lang/en/module.json
delete mode 100644 modules/statistics/lang/en/templates/clientlist.json
delete mode 100644 modules/statistics/lang/en/templates/cpumodels.json
delete mode 100644 modules/statistics/lang/en/templates/id44.json
delete mode 100644 modules/statistics/lang/en/templates/kvmstate.json
delete mode 100644 modules/statistics/lang/en/templates/machine-hdds.json
delete mode 100644 modules/statistics/lang/en/templates/machine-main.json
delete mode 100644 modules/statistics/lang/en/templates/machine-notes.json
delete mode 100644 modules/statistics/lang/en/templates/machine-usage.json
delete mode 100644 modules/statistics/lang/en/templates/memory.json
delete mode 100644 modules/statistics/lang/en/templates/newclients.json
delete mode 100644 modules/statistics/lang/en/templates/summary.json
delete mode 100644 modules/statistics/lang/en/templates/syslog.json
delete mode 100644 modules/statistics/page.inc.php
delete mode 100644 modules/statistics/templates/clientlist.html
delete mode 100644 modules/statistics/templates/cpumodels.html
delete mode 100644 modules/statistics/templates/id44.html
delete mode 100644 modules/statistics/templates/kvmstate.html
delete mode 100644 modules/statistics/templates/machine-hdds.html
delete mode 100644 modules/statistics/templates/machine-main.html
delete mode 100644 modules/statistics/templates/machine-notes.html
delete mode 100644 modules/statistics/templates/machine-usage.html
delete mode 100644 modules/statistics/templates/memory.html
delete mode 100644 modules/statistics/templates/newclients.html
delete mode 100644 modules/statistics/templates/summary.html
delete mode 100644 modules/statistics/templates/syslog.html
(limited to 'modules/statistics')
diff --git a/modules/statistics/config.json b/modules/statistics/config.json
deleted file mode 100644
index b0123727..00000000
--- a/modules/statistics/config.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "category":"main.status",
- "enabled":"true",
- "permission":"0"
-}
diff --git a/modules/statistics/lang/de/module.json b/modules/statistics/lang/de/module.json
deleted file mode 100644
index 35a62cce..00000000
--- a/modules/statistics/lang/de/module.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "module_name": "Client-Statistiken",
- "page_title": "Client-Statistiken"
-}
diff --git a/modules/statistics/lang/de/templates/clientlist.json b/modules/statistics/lang/de/templates/clientlist.json
deleted file mode 100644
index a1022e69..00000000
--- a/modules/statistics/lang/de/templates/clientlist.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "lang_address": "Adresse",
- "lang_clientList": "Liste ausgew\u00e4hlter Rechner",
- "lang_cpuModel": "CPU",
- "lang_gbRam": "RAM",
- "lang_kvmSupport": "64\u2009Bit G\u00e4ste",
- "lang_lastSeen": "Zuletzt gesehen",
- "lang_machine": "Rechner",
- "lang_machineIdle": "Der Rechner ist eingeschaltet und wird zur Zeit nicht benutzt",
- "lang_machineOccupied": "Der Rechner ist eingeschaltet und wird benutzt",
- "lang_machineOff": "Der Rechner ist ausgeschaltet, oder hat kein bwLehrpool gebootet",
- "lang_realCores": "Kerne",
- "lang_tmpGb": "HDD-Temp"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/cpumodels.json b/modules/statistics/lang/de/templates/cpumodels.json
deleted file mode 100644
index 85cf517f..00000000
--- a/modules/statistics/lang/de/templates/cpumodels.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "lang_cpuCores": "CPU-Kerne",
- "lang_modelCount": "Anzahl",
- "lang_modelName": "Modellname",
- "lang_modelStats": "PC-Modelle"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/id44.json b/modules/statistics/lang/de/templates/id44.json
deleted file mode 100644
index e2660f20..00000000
--- a/modules/statistics/lang/de/templates/id44.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_machineCount": "Anzahl",
- "lang_partitionSize": "Gr\u00f6\u00dfe",
- "lang_tempPartStats": "Tempor\u00e4re Partition"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/kvmstate.json b/modules/statistics/lang/de/templates/kvmstate.json
deleted file mode 100644
index 3e8f1a96..00000000
--- a/modules/statistics/lang/de/templates/kvmstate.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_kvmState": "Status",
- "lang_kvmStats": "64\u2009Bit Gast-Support",
- "lang_machineCount": "Anzahl"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/machine-hdds.json b/modules/statistics/lang/de/templates/machine-hdds.json
deleted file mode 100644
index f2f26baf..00000000
--- a/modules/statistics/lang/de/templates/machine-hdds.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "lang_hdds": "Festplatten",
- "lang_hours": "Stunden",
- "lang_modelNo": "Modell",
- "lang_partName": "Name",
- "lang_partSize": "Gr\u00f6\u00dfe",
- "lang_partType": "Typ",
- "lang_pendingSectors": "Potentiell defekte Sektoren",
- "lang_powerOnTime": "Betriebszeit",
- "lang_reallocatedSectors": "Defekte Sektoren",
- "lang_serialNo": "Serien-Nr",
- "lang_total": "Gesamt"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/machine-main.json b/modules/statistics/lang/de/templates/machine-main.json
deleted file mode 100644
index 47c3e266..00000000
--- a/modules/statistics/lang/de/templates/machine-main.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "lang_64bitSupport": "64\u2009Bit Gast-Support",
- "lang_cores": "Kerne",
- "lang_cpuModel": "CPU-Modell",
- "lang_firstSeen": "Erste Aktivit\u00e4t",
- "lang_hardwareSummary": "Hardware",
- "lang_hostname": "Hostname",
- "lang_ip": "IP-Adresse",
- "lang_lastBoot": "Letzter Boot",
- "lang_lastSeen": "Letzte Aktivit\u00e4t",
- "lang_macAddr": "MAC-Adresse",
- "lang_machineIdle": "Eingeschaltet, ungenutzt",
- "lang_machineOccupied": "Eingeschaltet, in Verwendung",
- "lang_machineOccupiedBy": "In Verwendung durch",
- "lang_machineOff": "Kein bwLehrpool gestartet",
- "lang_machineSummary": "Zusammenfassung",
- "lang_maximumAbbrev": "Max.",
- "lang_model": "Modell",
- "lang_ram": "Arbeitsspeicher",
- "lang_ramSlots": "Speicher-Slots",
- "lang_sockets": "Sockel",
- "lang_tempPart": "Temp. Partition",
- "lang_usageState": "Zustand",
- "lang_uuid": "UUID",
- "lang_virtualCores": "Virtuelle Kerne"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/machine-notes.json b/modules/statistics/lang/de/templates/machine-notes.json
deleted file mode 100644
index f9df1b92..00000000
--- a/modules/statistics/lang/de/templates/machine-notes.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "lang_notes": "Anmerkungen",
- "lang_save": "Speichern"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/machine-usage.json b/modules/statistics/lang/de/templates/machine-usage.json
deleted file mode 100644
index e2c9a979..00000000
--- a/modules/statistics/lang/de/templates/machine-usage.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "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_usageDetails": "Nutzungsdetails"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/memory.json b/modules/statistics/lang/de/templates/memory.json
deleted file mode 100644
index b5fdac89..00000000
--- a/modules/statistics/lang/de/templates/memory.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_machineCount": "Anzahl",
- "lang_memoryStats": "Arbeitsspeicher",
- "lang_ramSize": "Gr\u00f6\u00dfe"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/newclients.json b/modules/statistics/lang/de/templates/newclients.json
deleted file mode 100644
index f1353389..00000000
--- a/modules/statistics/lang/de/templates/newclients.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "lang_machine": "Client",
- "lang_newMachines": "Neue Ger\u00e4te"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/summary.json b/modules/statistics/lang/de/templates/summary.json
deleted file mode 100644
index 30189871..00000000
--- a/modules/statistics/lang/de/templates/summary.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "lang_inUseMachines": "In Verwendung",
- "lang_knownMachines": "Bekannte Clients",
- "lang_onlineMachines": "Gestartete Clients",
- "lang_withBadSectors": "Clients mit potentiell defekten Festplatten (mehr als 10 defekte Sektoren)"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/de/templates/syslog.json b/modules/statistics/lang/de/templates/syslog.json
deleted file mode 100644
index 960de730..00000000
--- a/modules/statistics/lang/de/templates/syslog.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "lang_details": "Details",
- "lang_event": "Ereignis",
- "lang_logHeadline": "Logging",
- "lang_more": "Mehr",
- "lang_when": "Wann"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/module.json b/modules/statistics/lang/en/module.json
deleted file mode 100644
index b4c6db44..00000000
--- a/modules/statistics/lang/en/module.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "module_name": "Client Statistics"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/clientlist.json b/modules/statistics/lang/en/templates/clientlist.json
deleted file mode 100644
index ae692154..00000000
--- a/modules/statistics/lang/en/templates/clientlist.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "lang_address": "Address",
- "lang_clientList": "List of selected machines",
- "lang_cpuModel": "CPU",
- "lang_gbRam": "RAM",
- "lang_kvmSupport": "64\u2009Bit guests",
- "lang_lastSeen": "Last seen",
- "lang_machine": "Machine",
- "lang_machineIdle": "Machine is powered on and is not used",
- "lang_machineOccupied": "Machine is powered on and in use",
- "lang_machineOff": "Machine is powered down, or is not running bwLehrpool",
- "lang_realCores": "Cores",
- "lang_tmpGb": "HDD temp"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/cpumodels.json b/modules/statistics/lang/en/templates/cpumodels.json
deleted file mode 100644
index 864933dd..00000000
--- a/modules/statistics/lang/en/templates/cpumodels.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "lang_cpuCores": "CPU cores",
- "lang_modelCount": "Count",
- "lang_modelName": "Model name",
- "lang_modelStats": "PC models"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/id44.json b/modules/statistics/lang/en/templates/id44.json
deleted file mode 100644
index 0d0081a8..00000000
--- a/modules/statistics/lang/en/templates/id44.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_machineCount": "Count",
- "lang_partitionSize": "Size",
- "lang_tempPartStats": "Temporary partition"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/kvmstate.json b/modules/statistics/lang/en/templates/kvmstate.json
deleted file mode 100644
index b4846473..00000000
--- a/modules/statistics/lang/en/templates/kvmstate.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_kvmState": "State",
- "lang_kvmStats": "64\u2009Bit guest support",
- "lang_machineCount": "Count"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/machine-hdds.json b/modules/statistics/lang/en/templates/machine-hdds.json
deleted file mode 100644
index 8ce6801d..00000000
--- a/modules/statistics/lang/en/templates/machine-hdds.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "lang_hdds": "Hard disk drives",
- "lang_hours": "hours",
- "lang_modelNo": "Model",
- "lang_partName": "Name",
- "lang_partSize": "Size",
- "lang_partType": "Type",
- "lang_pendingSectors": "Sectors pending reallocation",
- "lang_powerOnTime": "Power on time",
- "lang_reallocatedSectors": "Bad sectors",
- "lang_serialNo": "Serial no",
- "lang_total": "Total"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/machine-main.json b/modules/statistics/lang/en/templates/machine-main.json
deleted file mode 100644
index 1addd437..00000000
--- a/modules/statistics/lang/en/templates/machine-main.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "lang_64bitSupport": "64\u2009Bit guest support",
- "lang_cores": "Cores",
- "lang_cpuModel": "CPU model",
- "lang_firstSeen": "First seen",
- "lang_hardwareSummary": "Hardware",
- "lang_hostname": "Hostname",
- "lang_ip": "IP address",
- "lang_lastBoot": "Last boot",
- "lang_lastSeen": "Last activity",
- "lang_macAddr": "MAC address",
- "lang_machineIdle": "Powered on, unused",
- "lang_machineOccupied": "Powered on, in use",
- "lang_machineOccupiedBy": "In use by",
- "lang_machineOff": "bwLehrpool not running",
- "lang_machineSummary": "Summary",
- "lang_maximumAbbrev": "max.",
- "lang_model": "Model",
- "lang_ram": "Memory",
- "lang_ramSlots": "Memory slots",
- "lang_sockets": "Sockets",
- "lang_tempPart": "Temp. partition",
- "lang_usageState": "State",
- "lang_uuid": "UUID",
- "lang_virtualCores": "Virtual cores"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/machine-notes.json b/modules/statistics/lang/en/templates/machine-notes.json
deleted file mode 100644
index 7a13f28a..00000000
--- a/modules/statistics/lang/en/templates/machine-notes.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "lang_notes": "Notes",
- "lang_save": "Save"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/machine-usage.json b/modules/statistics/lang/en/templates/machine-usage.json
deleted file mode 100644
index 398996f6..00000000
--- a/modules/statistics/lang/en/templates/machine-usage.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "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_usageDetails": "Detailed usage"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/memory.json b/modules/statistics/lang/en/templates/memory.json
deleted file mode 100644
index decdd021..00000000
--- a/modules/statistics/lang/en/templates/memory.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_machineCount": "Count",
- "lang_memoryStats": "Memory",
- "lang_ramSize": "Size"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/newclients.json b/modules/statistics/lang/en/templates/newclients.json
deleted file mode 100644
index f7e55f3f..00000000
--- a/modules/statistics/lang/en/templates/newclients.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "lang_machine": "Client",
- "lang_newMachines": "New machines"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/summary.json b/modules/statistics/lang/en/templates/summary.json
deleted file mode 100644
index b57c290f..00000000
--- a/modules/statistics/lang/en/templates/summary.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "lang_inUseMachines": "In use",
- "lang_knownMachines": "Known clients",
- "lang_onlineMachines": "Online clients",
- "lang_withBadSectors": "Clients with potentially bad HDDs (more than 10 reallocated sectors)"
-}
\ No newline at end of file
diff --git a/modules/statistics/lang/en/templates/syslog.json b/modules/statistics/lang/en/templates/syslog.json
deleted file mode 100644
index 6737ca68..00000000
--- a/modules/statistics/lang/en/templates/syslog.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "lang_details": "Details",
- "lang_event": "Event",
- "lang_logHeadline": "Logging",
- "lang_more": "More",
- "lang_when": "When"
-}
\ No newline at end of file
diff --git a/modules/statistics/page.inc.php b/modules/statistics/page.inc.php
deleted file mode 100644
index faf88521..00000000
--- a/modules/statistics/page.inc.php
+++ /dev/null
@@ -1,792 +0,0 @@
- $uuid,
- 'text' => $text
- ));
- Message::addSuccess('notes-saved');
- Util::redirect('?do=Statistics&uuid=' . $uuid);
- }
- }
-
- protected function doRender()
- {
- Render::setTitle(Dictionary::translate('lang_titleClientStatistics'));
- $uuid = Request::get('uuid', false, 'string');
- if ($uuid !== false) {
- $this->showMachine($uuid);
- return;
- }
- $filter = Request::get('filter', false, 'string');
- if ($filter !== false) {
- $argument = Request::get('argument', false, 'string');
- $this->showMachineList($filter, $argument);
- return;
- }
- Render::addScriptBottom('chart.min');
- Render::openTag('div', array('class' => 'row'));
- $this->showSummary();
- $this->showMemory();
- $this->showId44();
- $this->showKvmState();
- $this->showLatestMachines();
- $this->showSystemModels();
- Render::closeTag('div');
- }
-
- private function capChart(&$json, $cutoff, $minSlice = 0.015)
- {
- $total = 0;
- foreach ($json as $entry) {
- $total += $entry['value'];
- }
- if ($total === 0)
- return;
- $cap = ceil($total * $cutoff);
- $accounted = 0;
- $id = 0;
- foreach ($json as $entry) {
- if (($accounted >= $cap || $entry['value'] / $total < $minSlice) && $id >= 3) break;
- $id++;
- $accounted += $entry['value'];
- }
- $json = array_slice($json, 0, $id);
- if ($accounted / $total < 0.99) {
- $json[] = array(
- 'color' => '#eee',
- 'label' => 'invalid',
- 'value' => ($total - $accounted)
- );
- }
- }
-
- private function showSummary()
- {
- $cutoff = time() - 86400 * 30;
- $online = time() - 610;
- $known = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE lastseen > $cutoff");
- $on = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE lastseen > $online");
- $used = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE lastseen > $online AND logintime <> 0");
- $hdd = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE badsectors > 10 AND lastseen > $cutoff");
- if ($on['val'] != 0) {
- $usedpercent = round($used['val'] / $on['val'] * 100);
- } else {
- $usedpercent = 0;
- }
- $data = array(
- 'known' => $known['val'],
- 'online' => $on['val'],
- 'used' => $used['val'],
- 'usedpercent' => $usedpercent,
- 'badhdd' => $hdd['val']
- );
- // Graph
- $cutoff = time() - 2*86400;
- $res = Database::simpleQuery("SELECT dateline, data FROM statistic WHERE typeid = '~stats' AND dateline > $cutoff ORDER BY dateline ASC");
- $labels = array();
- $points1 = array('data' => array(), 'label' => 'Online', 'fillColor' => '#efe', 'strokeColor' => '#aea', 'pointColor' => '#7e7', 'pointStrokeColor' => '#fff', 'pointHighlightFill' => '#fff', 'pointHighlightStroke' => '#7e7');
- $points2 = array('data' => array(), 'label' => 'In use', 'fillColor' => '#fee', 'strokeColor' => '#eaa', 'pointColor' => '#e77', 'pointStrokeColor' => '#fff', 'pointHighlightFill' => '#fff', 'pointHighlightStroke' => '#e77');
- $sum = 0;
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $x = explode('#', $row['data']);
- if ($sum === 0) {
- $labels[] = date('H:i', $row['dateline']);
- } else {
- $x[1] = max($x[1], array_pop($points1['data']));
- $x[2] = max($x[2], array_pop($points2['data']));
- }
- $points1['data'][] = $x[1];
- $points2['data'][] = $x[2];
- $sum++;
- if ($sum === 12) {
- $sum = 0;
- }
- }
- $data['json'] = json_encode(array('labels' => $labels, 'datasets' => array($points1, $points2)));
- // Draw
- Render::addTemplate('summary', $data);
- }
-
- private function showSystemModels()
- {
- global $STATS_COLORS;
- $res = Database::simpleQuery("SELECT systemmodel, Round(AVG(realcores)) AS cores, Count(*) AS `count` FROM machine"
- . " GROUP BY systemmodel ORDER BY `count` DESC, systemmodel ASC");
- $lines = array();
- $json = array();
- $id = 0;
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- if (empty($row['systemmodel'])) continue;
- settype($row['count'], 'integer');
- $row['id'] = 'systemid' . $id;
- $row['urlsystemmodel'] = urlencode($row['systemmodel']);
- $lines[] = $row;
- $json[] = array(
- 'color' => $STATS_COLORS[$id % count($STATS_COLORS)],
- 'label' => 'systemid' . $id,
- 'value' => $row['count']
- );
- ++$id;
- }
- $this->capChart($json, 0.92);
- Render::addTemplate('cpumodels', array('rows' => $lines, 'json' => json_encode($json)));
- }
-
- private function showMemory()
- {
- global $STATS_COLORS, $SIZE_RAM;
- $res = Database::simpleQuery("SELECT mbram, Count(*) AS `count` FROM machine GROUP BY mbram");
- $lines = array();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $gb = ceil($row['mbram'] / 1024);
- for ($i = 1; $i < count($SIZE_RAM); ++$i) {
- if ($SIZE_RAM[$i] < $gb) continue;
- if ($SIZE_RAM[$i] - $gb >= $gb - $SIZE_RAM[$i-1]) --$i;
- $gb = $SIZE_RAM[$i];
- break;
- }
- if (isset($lines[$gb])) {
- $lines[$gb] += $row['count'];
- } else {
- $lines[$gb] = $row['count'];
- }
- }
- asort($lines);
- $data = array('rows' => array());
- $json = array();
- $id = 0;
- foreach (array_reverse($lines, true) as $k => $v) {
- $data['rows'][] = array('gb' => $k, 'count' => $v, 'class' => $this->ramColorClass($k * 1024));
- $json[] = array(
- 'color' => $STATS_COLORS[$id % count($STATS_COLORS)],
- 'label' => (string)$k,
- 'value' => $v
- );
- ++$id;
- }
- $this->capChart($json, 0.92);
- $data['json'] = json_encode($json);
- Render::addTemplate('memory', $data);
- }
-
- private function showKvmState()
- {
- $colors = array('UNKNOWN' => '#666', 'UNSUPPORTED' => '#ea5', 'DISABLED' => '#e55', 'ENABLED' => '#6d6');
- $res = Database::simpleQuery("SELECT kvmstate, Count(*) AS `count` FROM machine GROUP BY kvmstate ORDER BY `count` DESC");
- $lines = array();
- $json = array();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $lines[] = $row;
- $json[] = array(
- 'color' => isset($colors[$row['kvmstate']]) ? $colors[$row['kvmstate']] : '#000',
- 'label' => $row['kvmstate'],
- 'value' => $row['count']
- );
- }
- Render::addTemplate('kvmstate', array('rows' => $lines, 'json' => json_encode($json)));
- }
-
- private function showId44()
- {
- global $STATS_COLORS, $SIZE_ID44;
- $res = Database::simpleQuery("SELECT id44mb, Count(*) AS `count` FROM machine GROUP BY id44mb");
- $lines = array();
- $total = 0;
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $total += $row['count'];
- $gb = ceil($row['id44mb'] / 1024);
- for ($i = 1; $i < count($SIZE_ID44); ++$i) {
- if ($SIZE_ID44[$i] < $gb) continue;
- if ($SIZE_ID44[$i] - $gb >= $gb - $SIZE_ID44[$i-1]) --$i;
- $gb = $SIZE_ID44[$i];
- break;
- }
- if (isset($lines[$gb])) {
- $lines[$gb] += $row['count'];
- } else {
- $lines[$gb] = $row['count'];
- }
- }
- asort($lines);
- $data = array('rows' => array());
- $json = array();
- $id = 0;
- foreach (array_reverse($lines, true) as $k => $v) {
- $data['rows'][] = array('gb' => $k, 'count' => $v, 'class' => $this->hddColorClass($k));
- if ($k === 0) {
- $color = '#e55';
- } else {
- $color = $STATS_COLORS[$id++ % count($STATS_COLORS)];
- }
- $json[] = array(
- 'color' => $color,
- 'label' => (string)$k,
- 'value' => $v
- );
- }
- $this->capChart($json, 0.95);
- $data['json'] = json_encode($json);
- Render::addTemplate('id44', $data);
- }
-
- private function showLatestMachines()
- {
- $data = array('cutoff' => ceil(time() / 3600) * 3600 - 86400 * 7);
- $res = Database::simpleQuery("SELECT machineuuid, clientip, hostname, firstseen, mbram, kvmstate, id44mb FROM machine"
- . " WHERE firstseen > :cutoff ORDER BY firstseen DESC LIMIT 32", $data);
- $rows = array();
- $count = 0;
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- if (empty($row['hostname'])) {
- $row['hostname'] = $row['clientip'];
- }
- $row['firstseen'] = date('d.m. H:i', $row['firstseen']);
- $row['gbram'] = round(round($row['mbram'] / 500) / 2, 1); // Trial and error until we got "expected" rounding..
- $row['gbtmp'] = round($row['id44mb'] / 1024);
- $row['ramclass'] = $this->ramColorClass($row['mbram']);
- $row['kvmclass'] = $this->kvmColorClass($row['kvmstate']);
- $row['hddclass'] = $this->hddColorClass($row['gbtmp']);
- $row['kvmicon'] = $row['kvmstate'] === 'ENABLED' ? '✓' : '✗';
- if (++$count > 5) {
- $row['style'] = 'display:none';
- }
- $rows[] = $row;
- }
- Render::addTemplate('newclients', array('rows' => $rows, 'openbutton' => $count > 5));
- }
-
- private function showMachineList($filter, $argument)
- {
- global $SIZE_RAM, $SIZE_ID44;
- $join = '';
- $filters = array('cpumodel', 'realcores', 'kvmstate', 'clientip', 'macaddr', 'machineuuid', 'systemmodel');
- if (in_array($filter, $filters)) {
- // Simple filters mapping into db
- $where = " $filter = :argument";
- $args = array('argument' => $argument);
- } elseif ($filter === 'gbram') {
- // Memory by rounded GB
- $lower = floor($this->findBestValue($SIZE_RAM, $argument, false) * 1024 - 100);
- $upper = ceil($this->findBestValue($SIZE_RAM, $argument, true) * 1024 + 100);
- $where = " mbram BETWEEN $lower AND $upper";
- $args = array();
- } elseif ($filter === 'hddgb') {
- // HDD by rounded GB
- $lower = floor($this->findBestValue($SIZE_ID44, $argument, false) * 1024 - 100);
- $upper = ceil($this->findBestValue($SIZE_ID44, $argument, true) * 1024 + 100);
- $where = " id44mb BETWEEN $lower AND $upper";
- $args = array();
- } elseif ($filter === 'subnet') {
- $argument = preg_replace('/[^0-9\.:]/', '', $argument);
- $where = " clientip LIKE '$argument%'";
- $args = array();
- } elseif ($filter === 'badsectors') {
- $where = " badsectors >= :argument ";
- $args = array('argument' => $argument);
- } elseif ($filter === 'state') {
- if ( $argument === 'on') {
- $where = " lastseen + 600 > UNIX_TIMESTAMP() ";
- } elseif ($argument === 'off') {
- $where = " lastseen + 600 < UNIX_TIMESTAMP() ";
- } elseif ($argument === 'idle') {
- $where = " lastseen + 600 > UNIX_TIMESTAMP() AND logintime = 0 ";
- } elseif ($argument === 'occupied') {
- $where = " lastseen + 600 > UNIX_TIMESTAMP() AND logintime <> 0 ";
- } else {
- Message::addError('invalid-filter');
- return;
- }
- } elseif ($filter === 'location') {
- $where = "subnet.locationid = :lid OR machine.locationid = :lid";
- $join = " INNER JOIN subnet ON (INET_ATON(clientip) BETWEEN startaddr AND endaddr) ";
- $args = array('lid' => (int)$argument);
- } else {
- Message::addError('invalid-filter');
- return;
- }
- $res = Database::simpleQuery("SELECT machineuuid, macaddr, clientip, firstseen, lastseen,"
- . " logintime, lastboot, realcores, mbram, kvmstate, cpumodel, id44mb, hostname, notes IS NOT NULL AS hasnotes, badsectors FROM machine"
- . " $join WHERE $where ORDER BY lastseen DESC, clientip ASC", $args);
- $rows = array();
- $NOW = time();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- if ($NOW - $row['lastseen'] > 610) {
- $row['state_off'] = true;
- } elseif ($row['logintime'] == 0) {
- $row['state_idle'] = true;
- } else {
- $row['state_occupied'] = true;
- }
- //$row['firstseen'] = date('d.m.Y H:i', $row['firstseen']);
- $row['lastseen'] = date('d.m. H:i', $row['lastseen']);
- //$row['lastboot'] = date('d.m. H:i', $row['lastboot']);
- $row['gbram'] = round(round($row['mbram'] / 500) / 2, 1); // Trial and error until we got "expected" rounding..
- $row['gbtmp'] = round($row['id44mb'] / 1024);
- $octets = explode('.', $row['clientip']);
- if (count($octets) === 4) {
- $row['subnet'] = "$octets[0].$octets[1].$octets[2].";
- $row['lastoctet'] = $octets[3];
- }
- $row['ramclass'] = $this->ramColorClass($row['mbram']);
- $row['kvmclass'] = $this->kvmColorClass($row['kvmstate']);
- $row['hddclass'] = $this->hddColorClass($row['gbtmp']);
- if (empty($row['hostname'])) $row['hostname'] = $row['clientip'];
- $rows[] = $row;
- }
- Render::addTemplate('clientlist', array('rows' => $rows, 'filter' => $filter, 'argument' => $argument));
- }
-
- private function ramColorClass($mb)
- {
- if ($mb < 1500)
- return 'danger';
- if ($mb < 2500)
- return 'warning';
- return '';
- }
-
- private function kvmColorClass($state)
- {
- if ($state === 'DISABLED')
- return 'danger';
- if ($state === 'UNKNOWN' || $state === 'UNSUPPORTED')
- return 'warning';
- return '';
- }
-
- private function hddColorClass($gb)
- {
- if ($gb < 7)
- return 'danger';
- if ($gb < 25)
- return 'warning';
- return '';
- }
-
- private function findBestValue($array, $value, $up)
- {
- $best = 0;
- for ($i = 0; $i < count($array); ++$i) {
- if (abs($array[$i] - $value) < abs($array[$best] - $value)) {
- $best = $i;
- }
- }
- if (!$up && $best === 0) {
- return $array[0];
- }
- if ($up && $best + 1 === count($array)) {
- return $array[$best];
- }
- if ($up) {
- return ($array[$best] + $array[$best + 1]) / 2;
- }
- return ($array[$best] + $array[$best - 1]) / 2;
- }
-
- private function fillSessionInfo(&$row)
- {
- $res = Database::simpleQuery("SELECT dateline, username, data FROM statistic"
- . " WHERE clientip = :ip AND typeid = '.vmchooser-session-name'"
- . " AND dateline BETWEEN :start AND :end", array(
- 'ip' => $row['clientip'],
- 'start' => $row['logintime'] - 60,
- 'end' => $row['logintime'] + 300
- ));
- $session = false;
- while ($r = $res->fetch(PDO::FETCH_ASSOC)) {
- if ($session === false || abs($session['dateline'] - $row['logintime']) > abs($r['dateline'] - $row['logintime'])) {
- $session = $r;
- }
- }
- if ($session !== false) {
- $row['session'] = $session['data'];
- $row['username'] = $session['username'];
- }
- }
-
- private function showMachine($uuid)
- {
- $client = Database::queryFirst("SELECT machineuuid, macaddr, clientip, firstseen, lastseen, logintime, lastboot,"
- . " mbram, kvmstate, cpumodel, id44mb, data, hostname, notes FROM machine WHERE machineuuid = :uuid",
- array('uuid' => $uuid));
- // Mangle fields
- $NOW = time();
- if ($NOW - $client['lastseen'] > 610) {
- $client['state_off'] = true;
- } elseif ($client['logintime'] == 0) {
- $client['state_idle'] = true;
- } else {
- $client['state_occupied'] = true;
- $this->fillSessionInfo($client);
- }
- $client['firstseen_s'] = date('d.m.Y H:i', $client['firstseen']);
- $client['lastseen_s'] = date('d.m.Y H:i', $client['lastseen']);
- $uptime = $NOW - $client['lastboot'];
- $client['lastboot_s'] = date('d.m.Y H:i', $client['lastboot']) . ' (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['gbtmp'] = round($client['id44mb'] / 1024);
- $client['ramclass'] = $this->ramColorClass($client['mbram']);
- $client['kvmclass'] = $this->kvmColorClass($client['kvmstate']);
- $client['hddclass'] = $this->hddColorClass($client['gbtmp']);
- // Parse the giant blob of data
- $hdds = array();
- if (preg_match_all('/##### ([^#]+) #+$(.*?)^#####/ims', $client['data'] . '########', $out, PREG_SET_ORDER)) {
- foreach ($out as $section) {
- if ($section[1] === 'CPU') {
- $this->parseCpu($client, $section[2]);
- }
- if ($section[1] === 'dmidecode') {
- $this->parseDmiDecode($client, $section[2]);
- }
- if ($section[1] === 'Partition tables') {
- $this->parseHdd($hdds, $section[2]);
- }
- if (isset($hdds['hdds']) && $section[1] === 'smartctl') {
- // This currently required that the partition table section comes first...
- $this->parseSmartctl($hdds['hdds'], $section[2]);
- }
- }
- }
- unset($client['data']);
- // Throw output at user
- Render::addTemplate('machine-main', $client);
- // Sessions
- $NOW = time();
- $cutoff = $NOW - 86400 * 7;
- //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(
- 'cutoff' => $cutoff - 86400 * 14,
- 'uuid' => $uuid
- ));
- $spans['rows'] = array();
- $spans['graph'] = '';
- $last = false;
- $first = true;
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- if ($first && $row['dateline'] > $cutoff && $client['lastboot'] > $cutoff) {
- // Special case: offline before
- $spans['graph'] .= '
';
- }
- $first = false;
- if ($row['dateline'] + $row['data'] < $cutoff || $row['data'] > 864000) continue;
- if ($last !== false && abs($last['dateline'] - $row['dateline']) < 30
- && abs($last['data'] - $row['data']) < 30) continue;
- if ($last !== false && $last['dateline'] + $last['data'] > $row['dateline']) {
- $point = $last['dateline'] + $last['data'];
- $row['data'] -= ($point - $row['dateline']);
- $row['dateline'] = $point;
- }
- if ($row['dateline'] < $cutoff) {
- $row['data'] -= ($cutoff - $row['dateline']);
- $row['dateline'] = $cutoff;
- }
- $row['from'] = date('d.m. H:i', $row['dateline']);
- $row['duration'] = floor($row['data'] / 86400) . 'd ' . gmdate('H:i', $row['data']);
- if ($row['typeid'] === '~offline-length') {
- $row['glyph'] = 'off';
- $color = '#444';
- } else {
- $row['glyph'] = 'user';
- $color = '#e77';
- }
- $spans['graph'] .= '
';
- $spans['rows'][] = $row;
- $last = $row;
- }
- if ($first && $client['lastboot'] > $cutoff) {
- // Special case: offline before
- $spans['graph'] .= '
';
- }
- if (isset($client['state_occupied'])) {
- $spans['graph'] .= '
';
- } elseif (isset($client['state_off'])) {
- $spans['graph'] .= '
';
- }
- $t = explode('-', date('Y-n-j-G', $cutoff));
- if ($t[3] >= 8 && $t[3] <= 22) {
- $start = mktime(22, 0, 0, $t[1], $t[2], $t[0]);
- } else {
- $start = mktime(22, 0, 0, $t[1], $t[2] - 1, $t[0]);
- }
- for ($i = $start; $i < $NOW; $i += 86400) {
- $spans['graph'] .= '
';
- }
- if (count($spans['rows']) > 10) {
- $spans['hasrows2'] = true;
- $spans['rows2'] = array_slice($spans['rows'], ceil(count($spans['rows']) / 2));
- $spans['rows'] = array_slice($spans['rows'], 0, ceil(count($spans['rows']) / 2));
- }
- Render::addTemplate('machine-usage', $spans);
- // Any hdds?
- if (!empty($hdds['hdds'])) {
- Render::addScriptBottom('chart.min');
- Render::addTemplate('machine-hdds', $hdds);
- }
- // Client log
- $lres = Database::simpleQuery("SELECT logid, dateline, logtypeid, clientip, description, extra FROM clientlog"
- . " WHERE clientip = :clientip ORDER BY logid DESC LIMIT 25", array('clientip' => $client['clientip']));
- $today = date('d.m.Y');
- $yesterday = date('d.m.Y', time() - 86400);
- $count = 0;
- $log = array();
- while ($row = $lres->fetch(PDO::FETCH_ASSOC)) {
- if (substr($row['description'], -5) === 'on :0' && strpos($row['description'], 'root logged') === false) continue;
- $day = date('d.m.Y', $row['dateline']);
- if ($day === $today) {
- $day = Dictionary::translate('today');
- } elseif ($day === $yesterday) {
- $day = Dictionary::translate('yesterday');
- }
- $row['date'] = $day . date(' H:i', $row['dateline']);
- $row['icon'] = $this->eventToIconName($row['logtypeid']);
- $log[] = $row;
- if (++$count === 10) break;
- }
- Render::addTemplate('syslog', array(
- 'clientip' => $client['clientip'],
- 'list' => $log
- ));
- // Notes
- Render::addTemplate('machine-notes', $client);
- }
-
- private function eventToIconName($event)
- {
- switch ($event) {
- case 'session-open':
- return 'glyphicon-log-in';
- case 'session-close':
- return 'glyphicon-log-out';
- case 'partition-swap':
- return 'glyphicon-info-sign';
- case 'partition-temp':
- case 'smartctl-realloc':
- return 'glyphicon-exclamation-sign';
- default:
- return 'glyphicon-minus';
- }
- }
-
- private function parseCpu(&$row, $data)
- {
- if (0 >= preg_match_all('/^(.+):\s+(\d+)$/im', $data, $out, PREG_SET_ORDER)) return;
- foreach ($out as $entry) {
- $row[str_replace(' ', '', $entry[1])] = $entry[2];
- }
- }
-
- private function parseDmiDecode(&$row, $data)
- {
- $lines = preg_split("/[\r\n]+/", $data);
- $section = false;
- $ramOk = false;
- $ramForm = $ramType = $ramSpeed = $ramClockSpeed = false;
- foreach ($lines as $line) {
- if (empty($line)) continue;
- if ($line{0} !== "\t" && $line{0} !== ' ') {
- $section = $line;
- $ramOk = false;
- if (($ramForm || $ramType) && ($ramSpeed || $ramClockSpeed)) {
- if (isset($row['ramtype']) && !$ramClockSpeed) continue;
- $row['ramtype'] = $ramType . ' ' . $ramForm;
- if ($ramClockSpeed) $row['ramtype'] .= ', ' . $ramClockSpeed;
- elseif ($ramSpeed) $row['ramtype'] .= ', ' . $ramSpeed;
- $ramForm = false;
- $ramType = false;
- $ramClockSpeed = false;
- }
- continue;
- }
- if ($section === 'System Information' || $section === 'Base Board Information') {
- if (empty($row['pcmodel']) && preg_match('/^\s*Product Name: +(\S.+?) *$/i', $line, $out)) {
- $row['pcmodel'] = $out[1];
- }
- if (empty($row['manufacturer']) && preg_match('/^\s*Manufacturer: +(\S.+?) *$/i', $line, $out)) {
- $row['manufacturer'] = $out[1];
- }
- }
- else if ($section === 'Physical Memory Array') {
- if (!$ramOk && preg_match('/Use: System Memory/i', $line)) {
- $ramOk = true;
- }
- if ($ramOk && preg_match('/^\s*Number Of Devices: +(\S.+?) *$/i', $line, $out)) {
- $row['ramslotcount'] = $out[1];
- }
- if ($ramOk && preg_match('/^\s*Maximum Capacity: +(\S.+?)\s*$/i', $line, $out)) {
- $row['maxram'] = preg_replace('/([MGT])B/', '$1iB', $out[1]);
- }
- }
- else if ($section === 'Memory Device') {
- if (preg_match('/^\s*Size:\s*(.*?)\s*$/i', $line, $out)) {
- $row['extram'] = true;
- if (preg_match('/(\d+)\s*(\w)i?B/i', $out[1], $out)) {
- $out[2] = strtoupper($out[2]);
- if ($out[2] === 'K' || ($out[2] === 'M' && $out[1] < 500)) {
- $ramForm = $ramType = $ramSpeed = $ramClockSpeed = false;
- continue;
- }
- if ($out[2] === 'M' && $out[1] >= 1024) {
- $out[2] = 'G';
- $out[1] = floor(($out[1] + 100) / 1024);
- }
- $row['ramslot'][]['size'] = $out[1] . ' ' . strtoupper($out[2]) . 'iB';
- } else if (!isset($row['ramslot']) || (count($row['ramslot']) < 8 && (!isset($row['ramslotcount']) || $row['ramslotcount'] <= 8))) {
- $row['ramslot'][]['size'] = '_____';
- }
- }
- if (preg_match('/^\s*Form Factor:\s*(.*?)\s*$/i', $line, $out) && $out[1] !== 'Unknown') {
- $ramForm = $out[1];
- }
- if (preg_match('/^\s*Type:\s*(.*?)\s*$/i', $line, $out) && $out[1] !== 'Unknown') {
- $ramType = $out[1];
- }
- if (preg_match('/^\s*Speed:\s*(\d.*?)\s*$/i', $line, $out)) {
- $ramSpeed = $out[1];
- }
- if (preg_match('/^\s*Configured Clock Speed:\s*(\d.*?)\s*$/i', $line, $out)) {
- $ramClockSpeed = $out[1];
- }
- }
- }
- if (empty($row['ramslotcount'])) $row['ramslotcount'] = count($row['ramslot']);
- }
-
- private function parseHdd(&$row, $data)
- {
- $hdds = array();
- // Could have more than one disk - linear scan
- $lines = preg_split("/[\r\n]+/", $data);
- $dev = false;
- $i = 0;
- foreach ($lines as $line) {
- if (preg_match('/^Disk (\S+):.* (\d+) bytes/i', $line, $out)) {
- // disk total size and name
- unset($hdd);
- $unit = 0;
- $hdd = array(
- 'devid' => 'devid-' . ++$i,
- 'dev' => $out[1],
- 'size' => round($out[2] / (1024 * 1024 * 1024)),
- 'used' => 0,
- 'partitions' => array(),
- 'json' => array(),
- );
- $hdds[] = &$hdd;
- } elseif (preg_match('/^Units =.*= (\d+) bytes/i', $line, $out)) {
- // Unit for start and end
- $unit = $out[1] / (1024 * 1024); // Convert so that multiplying by unit yields MiB
- } else if (isset($hdd) && $unit !== 0 && preg_match(',^/dev/(\S+)\s+.*\s(\d+)[\+\-]?\s+(\d+)[\+\-]?\s+\d+[\+\-]?\s+([0-9a-f]+)\s+(.*)$,i', $line, $out)) {
- // Some partition
- $type = strtolower($out[4]);
- if ($type === '5' || $type === 'f' || $type === '85') continue;
- $partsize = round(($out[3] - $out[2]) * $unit);
- $hdd['partitions'][] = array(
- 'id' => $out[1],
- 'name' => $out[1],
- 'size' => round($partsize / 1024, $partsize < 1024 ? 1 : 0),
- 'type' => ($type === '44' ? 'OpenSLX' : $out[5]),
- );
- $hdd['json'][] = array(
- 'label' => $out[1],
- 'value' => $partsize,
- 'color' => ($type === '44' ? '#4d4' : ($type === '82' ? '#48f' : '#e55')),
- );
- $hdd['used'] += $partsize;
- }
- }
- unset($hdd);
- $i = 0;
- foreach ($hdds as &$hdd) {
- $hdd['used'] = round($hdd['used'] / 1024);
- $free = $hdd['size'] - $hdd['used'];
- if ($free > 5) {
- $hdd['partitions'][] = array(
- 'id' => 'free-id-' . $i,
- 'name' => Dictionary::translate('unused'),
- 'size' => $free,
- 'type' => '-',
- );
- $hdd['json'][] = array(
- 'label' => 'free-id-' . $i,
- 'value' => $free * 1024,
- 'color' => '#aaa',
- );
- ++$i;
- }
- $hdd['json'] = json_encode($hdd['json']);
- }
- unset($hdd);
- $row['hdds'] = &$hdds;
- }
-
- private function parseSmartctl(&$hdds, $data)
- {
- $lines = preg_split("/[\r\n]+/", $data);
- $i = 0;
- foreach ($lines as $line) {
- if (preg_match('/^NEXTHDD=(.+)$/', $line, $out)) {
- unset($dev);
- foreach ($hdds as &$hdd) {
- if ($hdd['dev'] === $out[1]) $dev =& $hdd;
- }
- continue;
- }
- if (!isset($dev)) continue;
- if (preg_match('/^([A-Z][^:]+):\s*(.*)$/', $line, $out)) {
- $dev['s_' . preg_replace('/\s|-|_/', '', $out[1])] = $out[2];
- } elseif (preg_match('/^\s*\d+\s+(\S+)\s+\S+\s+\d+\s+\d+\s+\d+\s+\S+\s+(\d+)(\s|$)/', $line, $out)) {
- $dev['s_' . preg_replace('/\s|-|_/', '', $out[1])] = $out[2];
- }
- }
- // Format strings
- foreach ($hdds as &$hdd) {
- if (isset($hdd['s_PowerOnHours'])) {
- $hdd['PowerOnTime'] = '';
- $val = (int)$hdd['s_PowerOnHours'];
- if ($val > 8760) {
- $hdd['PowerOnTime'] .= floor($val / 8760) . 'Y, ';
- $val %= 8760;
- }
- if ($val > 720) {
- $hdd['PowerOnTime'] .= floor($val / 720) . 'M, ';
- $val %= 720;
- }
- if ($val > 24) {
- $hdd['PowerOnTime'] .= floor($val / 24) . 'd, ';
- $val %= 24;
- }
- $hdd['PowerOnTime'] .= $val . 'h';
- }
- }
- }
-
-}
diff --git a/modules/statistics/templates/clientlist.html b/modules/statistics/templates/clientlist.html
deleted file mode 100644
index 8e8565fe..00000000
--- a/modules/statistics/templates/clientlist.html
+++ /dev/null
@@ -1,45 +0,0 @@
-{{lang_clientList}}
-{{filter}} ~= {{argument}}
-
-
-
-
- | {{lang_machine}} |
- {{lang_address}} |
- {{lang_lastSeen}} |
- {{lang_kvmSupport}} |
- {{lang_gbRam}} |
- {{lang_tmpGb}} |
- {{lang_cpuModel}} |
-
- {{#rows}}
-
- |
- {{#hasnotes}}{{/hasnotes}}
- {{#state_off}}
-
- {{/state_off}}
- {{#state_idle}}
-
- {{/state_idle}}
- {{#state_occupied}}
-
- {{/state_occupied}}
- {{hostname}}
- {{machineuuid}}
- |
- {{subnet}}{{lastoctet}} {{macaddr}} |
- {{lastseen}} |
- {{kvmstate}} |
- {{gbram}} GiB |
-
- {{gbtmp}} GiB
- {{#badsectors}}
-
- {{badsectors}}
- {{/badsectors}}
- |
- {{lang_realCores}}: {{realcores}} {{cpumodel}} |
-
- {{/rows}}
-
diff --git a/modules/statistics/templates/cpumodels.html b/modules/statistics/templates/cpumodels.html
deleted file mode 100644
index 2f24cd92..00000000
--- a/modules/statistics/templates/cpumodels.html
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
- {{lang_modelStats}}
-
-
-
-
-
-
- | {{lang_modelName}} |
- {{lang_cpuCores}} |
- {{lang_modelCount}} |
-
- {{#rows}}
-
- |
- {{systemmodel}}
- |
- {{cores}} |
- {{count}} |
-
- {{/rows}}
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/statistics/templates/id44.html b/modules/statistics/templates/id44.html
deleted file mode 100644
index 730839b1..00000000
--- a/modules/statistics/templates/id44.html
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
- {{lang_tempPartStats}}
-
-
-
-
-
-
- | {{lang_partitionSize}} |
- {{lang_machineCount}} |
-
- {{#rows}}
-
- | {{gb}} GiB |
- {{count}} |
-
- {{/rows}}
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/statistics/templates/kvmstate.html b/modules/statistics/templates/kvmstate.html
deleted file mode 100644
index 107a34f7..00000000
--- a/modules/statistics/templates/kvmstate.html
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
- {{lang_kvmStats}}
-
-
-
-
-
-
- | {{lang_kvmState}} |
- {{lang_machineCount}} |
-
- {{#rows}}
-
- | {{kvmstate}} |
- {{count}} |
-
- {{/rows}}
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/statistics/templates/machine-hdds.html b/modules/statistics/templates/machine-hdds.html
deleted file mode 100644
index fd6cf1be..00000000
--- a/modules/statistics/templates/machine-hdds.html
+++ /dev/null
@@ -1,67 +0,0 @@
-{{lang_hdds}}
-
- {{#hdds}}
-
-
-
- {{s_ModelFamily}} {{dev}}
-
-
- {{#s_DeviceModel}}
-
{{lang_modelNo}}: {{s_DeviceModel}}, {{lang_serialNo}}: {{s_SerialNumber}}
- {{/s_DeviceModel}}
- {{#s_ReallocatedSectorCt}}
-
{{lang_reallocatedSectors}}: {{s_ReallocatedSectorCt}}
- {{/s_ReallocatedSectorCt}}
- {{#s_CurrentPendingSector}}
-
{{lang_pendingSectors}}: {{s_CurrentPendingSector}}
- {{/s_CurrentPendingSector}}
- {{#s_PowerOnHours}}
-
{{lang_powerOnTime}}: {{s_PowerOnHours}} {{lang_hours}} ({{PowerOnTime}})
- {{/s_PowerOnHours}}
-
-
-
-
- | {{lang_partName}} |
- {{lang_partSize}} |
- {{lang_partType}} |
-
- {{#partitions}}
-
- | {{name}} |
- {{size}} GiB |
- {{type}} |
-
- {{/partitions}}
-
-
{{lang_total}}: {{size}} GiB
-
-
-
-
-
-
-
-
-
- {{/hdds}}
-
\ No newline at end of file
diff --git a/modules/statistics/templates/machine-main.html b/modules/statistics/templates/machine-main.html
deleted file mode 100644
index 8071416a..00000000
--- a/modules/statistics/templates/machine-main.html
+++ /dev/null
@@ -1,124 +0,0 @@
-
- {{hostname}} {{#hostname}}–{{/hostname}} {{clientip}}
- {{#notes}}{{/notes}}
-
-
-
-
-
-
- {{lang_machineSummary}}
-
-
-
-
- | {{lang_uuid}} |
- {{machineuuid}} |
-
-
- | {{lang_macAddr}} |
- {{macaddr}} |
-
-
- | {{lang_ip}} |
- {{clientip}} |
-
- {{#hostname}}
-
- | {{lang_hostname}} |
- {{hostname}} |
-
- {{/hostname}}
-
- | {{lang_firstSeen}} |
- {{firstseen_s}} |
-
-
- | {{lang_lastBoot}} |
- {{lastboot_s}} |
-
-
- | {{lang_lastSeen}} |
- {{lastseen_s}} |
-
-
- | {{lang_usageState}} |
-
- {{#state_off}}
- {{lang_machineOff}}
- {{/state_off}}
- {{#state_idle}}
- {{lang_machineIdle}}
- {{/state_idle}}
- {{#state_occupied}}
- {{#username}}
- {{lang_machineOccupiedBy}} {{username}}
- {{/username}}
- {{^username}}
- {{lang_machineOccupied}}
- {{/username}}
- {{logintime_s}}
- {{/state_occupied}}
- {{#session}}
- {{session}}
- {{/session}}
- |
-
-
-
-
-
-
-
-
- {{lang_hardwareSummary}}
-
-
-
-
- | {{lang_cpuModel}} |
-
- {{cpumodel}}
- {{#Sockets}}
-
- {{lang_sockets}}: {{Sockets}}, {{lang_cores}}: {{Realcores}}, {{lang_virtualCores}}: {{Virtualcores}}
-
- {{/Sockets}}
- |
-
-
- | {{lang_model}} |
- {{pcmodel}} ({{manufacturer}}) |
-
-
- | {{lang_ram}} |
-
- {{gbram}} GiB
- {{#maxram}}({{lang_maximumAbbrev}} {{maxram}}){{/maxram}}
- {{ramtype}}
- |
-
- {{#extram}}
-
- | {{lang_ramSlots}} |
-
- {{ramslotcount}}:
- {{#ramslot}}
- [ {{size}} ]
- {{/ramslot}}
- |
-
- {{/extram}}
-
- | {{lang_tempPart}} |
- {{gbtmp}} GiB |
-
-
- | {{lang_64bitSupport}} |
- {{kvmstate}} |
-
-
-
-
-
-
diff --git a/modules/statistics/templates/machine-notes.html b/modules/statistics/templates/machine-notes.html
deleted file mode 100644
index c4f97543..00000000
--- a/modules/statistics/templates/machine-notes.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-{{lang_notes}}
-
\ No newline at end of file
diff --git a/modules/statistics/templates/machine-usage.html b/modules/statistics/templates/machine-usage.html
deleted file mode 100644
index ffaa747b..00000000
--- a/modules/statistics/templates/machine-usage.html
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
- {{lang_usageDetails}}
-
-
-
-
-
-
- | Type |
- When |
- Length |
-
- {{#rows}}
-
- |
- {{from}} |
- {{duration}} |
-
- {{/rows}}
-
-
-
-
- {{#hasrows2}}
-
- | Type |
- When |
- Length |
-
- {{/hasrows2}}
- {{#rows2}}
-
- |
- {{from}} |
- {{duration}} |
-
- {{/rows2}}
-
-
-
-
{{{graph}}}
-
- {{lang_timebarDesc}}
-
-
-
-
-
diff --git a/modules/statistics/templates/memory.html b/modules/statistics/templates/memory.html
deleted file mode 100644
index f4d2ad24..00000000
--- a/modules/statistics/templates/memory.html
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
- {{lang_memoryStats}}
-
-
-
-
-
-
- | {{lang_ramSize}} |
- {{lang_machineCount}} |
-
- {{#rows}}
-
- | {{gb}} GiB |
- {{count}} |
-
- {{/rows}}
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/statistics/templates/newclients.html b/modules/statistics/templates/newclients.html
deleted file mode 100644
index 0d9c74df..00000000
--- a/modules/statistics/templates/newclients.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
- {{lang_newMachines}}
-
-
-
-
- | {{lang_machine}} |
- |
- 64Bit |
- RAM |
- HDD |
-
- {{#rows}}
-
- | {{hostname}} |
- {{firstseen}} |
- {{kvmicon}} |
- {{gbram}} GiB |
- {{gbtmp}} GiB |
-
- {{/rows}}
- {{#openbutton}}
-
- |
-
-
-
-
-
-
- |
-
- {{/openbutton}}
-
-
-
-
\ No newline at end of file
diff --git a/modules/statistics/templates/summary.html b/modules/statistics/templates/summary.html
deleted file mode 100644
index 5f16fd89..00000000
--- a/modules/statistics/templates/summary.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- {{#badhdd}}
-
- {{/badhdd}}
-
-
-
-
-
-
-
-
diff --git a/modules/statistics/templates/syslog.html b/modules/statistics/templates/syslog.html
deleted file mode 100644
index c82cb8ac..00000000
--- a/modules/statistics/templates/syslog.html
+++ /dev/null
@@ -1,43 +0,0 @@
-{{lang_logHeadline}}
-
-
- |
- {{lang_when}} |
- {{lang_event}} |
- {{lang_details}} |
-
-
- {{#list}}
-
- |
- {{date}} |
- {{description}} |
- {{#extra}}
- »
-
- {{/extra}} |
-
- {{/list}}
-
-
-
-
-
-
-
-
--
cgit v1.2.3-55-g7522