summaryrefslogtreecommitdiffstats
path: root/modules/systemstatus.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-06-05 20:41:32 +0200
committerSimon Rettberg2014-06-05 20:41:32 +0200
commitda5ae919f868d1da90548d7cbafec55a06d2a62b (patch)
tree9af9d1933f03c518875d672cdc1ac87dd13273ad /modules/systemstatus.inc.php
parentAdd functions to add script includes to the beginning or end of the document ... (diff)
downloadslx-admin-da5ae919f868d1da90548d7cbafec55a06d2a62b.tar.gz
slx-admin-da5ae919f868d1da90548d7cbafec55a06d2a62b.tar.xz
slx-admin-da5ae919f868d1da90548d7cbafec55a06d2a62b.zip
Started "System Status" page
Diffstat (limited to 'modules/systemstatus.inc.php')
-rw-r--r--modules/systemstatus.inc.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/systemstatus.inc.php b/modules/systemstatus.inc.php
new file mode 100644
index 00000000..c6d45812
--- /dev/null
+++ b/modules/systemstatus.inc.php
@@ -0,0 +1,75 @@
+<?php
+
+class Page_SystemStatus extends Page
+{
+
+ protected function doPreprocess()
+ {
+ User::load();
+
+ if (!User::isLoggedIn()) {
+ Util::redirect('?do=Main');
+ }
+ }
+
+ protected function doRender()
+ {
+ Render::addScriptTop('custom');
+ Render::addScriptBottom('circles.min');
+ Render::addTemplate('systemstatus/_page');
+ }
+
+ protected function doAjax()
+ {
+ User::load();
+
+ if (!User::isLoggedIn())
+ return;
+
+ $action = 'ajax' . Request::any('action');
+ if (method_exists($this, $action))
+ $this->$action();
+ else
+ echo "Action $action not known in " . get_class();
+ }
+
+ protected function ajaxDiskStat()
+ {
+ $task = Taskmanager::submit('DiskStat');
+ $task = Taskmanager::waitComplete($task);
+
+ if (!isset($task['data']['list']) || empty($task['data']['list'])) {
+ Taskmanager::addErrorMessage($task);
+ Message::renderList();
+ return;
+ }
+ $store = Property::getVmStoreUrl();
+ $storeUsage = false;
+ $systemUsage = false;
+ if ($store !== false) {
+ if ($store === '<local>')
+ $storePoint = '/';
+ else
+ $storePoint = '/srv/openslx/nfs';
+ foreach ($task['data']['list'] as $entry) {
+ if ($entry['mountPoint'] === $storePoint)
+ $storeUsage = array(
+ 'percent' => $entry['usedPercent'],
+ 'size' => Util::readableFileSize ($entry['sizeKb'] * 1024),
+ 'color' => dechex(round(($entry['usedPercent'] / 100) * 15)) . dechex(round(((100 - $entry['usedPercent']) / 100) * 15)) . '4'
+ );
+ if ($entry['mountPoint'] === '/')
+ $systemUsage = array(
+ 'percent' => $entry['usedPercent'],
+ 'size' => Util::readableFileSize ($entry['sizeKb'] * 1024),
+ 'color' => dechex(round(($entry['usedPercent'] / 100) * 15)) . dechex(round(((100 - $entry['usedPercent']) / 100) * 15)) . '4'
+ );
+ }
+ }
+ echo Render::parse('systemstatus/diskstat', array(
+ 'store' => $storeUsage,
+ 'system' => $systemUsage
+ ));
+ }
+
+}