summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2015-05-21 17:17:21 +0200
committerSimon Rettberg2015-05-21 17:17:21 +0200
commit6f8338004e59f409989b7deafb62005d6c4a45bc (patch)
tree91b958b03ceed46b9fc9db25f6383fa6084b9dca
parentSupport statictics slxlog messages (Starting with '.'), those go to a special... (diff)
downloadslx-admin-6f8338004e59f409989b7deafb62005d6c4a45bc.tar.gz
slx-admin-6f8338004e59f409989b7deafb62005d6c4a45bc.tar.xz
slx-admin-6f8338004e59f409989b7deafb62005d6c4a45bc.zip
Add free disk space display and dmsd log to Status page
-rw-r--r--modules/systemstatus.inc.php32
-rw-r--r--templates/systemstatus/_page.html12
-rw-r--r--templates/systemstatus/diskstat.html6
3 files changed, 42 insertions, 8 deletions
diff --git a/modules/systemstatus.inc.php b/modules/systemstatus.inc.php
index 8bc68d66..e80179ad 100644
--- a/modules/systemstatus.inc.php
+++ b/modules/systemstatus.inc.php
@@ -2,6 +2,7 @@
class Page_SystemStatus extends Page
{
+
private $rebootTask = false;
protected function doPreprocess()
@@ -12,7 +13,7 @@ class Page_SystemStatus extends Page
Message::addError('no-permission');
Util::redirect('?do=Main');
}
-
+
if (Request::post('action') === 'reboot') {
if (Request::post('confirm') !== 'yep') {
Message::addError('reboot-unconfirmed');
@@ -74,6 +75,7 @@ class Page_SystemStatus extends Page
$storeUsage = array(
'percent' => $entry['usedPercent'],
'size' => Util::readableFileSize($entry['sizeKb'] * 1024),
+ 'free' => Util::readableFileSize($entry['freeKb'] * 1024),
'color' => $this->usageColor($entry['usedPercent'])
);
}
@@ -81,6 +83,7 @@ class Page_SystemStatus extends Page
$systemUsage = array(
'percent' => $entry['usedPercent'],
'size' => Util::readableFileSize($entry['sizeKb'] * 1024),
+ 'free' => Util::readableFileSize($entry['freeKb'] * 1024),
'color' => $this->usageColor($entry['usedPercent'])
);
}
@@ -130,7 +133,7 @@ class Page_SystemStatus extends Page
'addresses' => $task['data']['addresses']
));
}
-
+
protected function ajaxSystemInfo()
{
$cpuInfo = file_get_contents('/proc/cpuinfo');
@@ -167,16 +170,16 @@ class Page_SystemStatus extends Page
}
echo Render::parse('systemstatus/systeminfo', $data);
}
-
+
protected function ajaxServices()
{
$data = array();
-
+
$taskId = Trigger::ldadp();
if ($taskId === false)
return;
$status = Taskmanager::waitComplete($taskId, 10000);
-
+
if (Taskmanager::isFailed($status)) {
if (isset($status['data']['messages']))
$data['ldadpError'] = $status['data']['messages'];
@@ -184,10 +187,27 @@ class Page_SystemStatus extends Page
$data['ldadpError'] = 'Taskmanager error';
}
// TODO: Dozentenmodul, tftp, ...
-
+
echo Render::parse('systemstatus/services', $data);
}
+ protected function ajaxDmsdLog()
+ {
+ $fh = @fopen('/var/log/dmsd.log', 'r');
+ if ($fh === false) {
+ echo 'Error opening log file';
+ return;
+ }
+ fseek($fh, -6000, SEEK_END);
+ $data = fread($fh, 6000);
+ @fclose($fh);
+ if ($data === false) {
+ echo 'Error reading from log file';
+ return;
+ }
+ echo '<pre>', htmlspecialchars(substr($data, strpos($data, "\n") + 1)), '</pre>';
+ }
+
private function usageColor($percent)
{
if ($percent <= 50) {
diff --git a/templates/systemstatus/_page.html b/templates/systemstatus/_page.html
index d3ac1d06..22eeb7d3 100644
--- a/templates/systemstatus/_page.html
+++ b/templates/systemstatus/_page.html
@@ -76,9 +76,21 @@
</div>
+<h3>{{lang_advanced}}</h3>
+
+<div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_dmsdLog}}
+ </div>
+ <div class="panel-body" id="dmsd-log">
+ <span class="glyphicon glyphicon-refresh slx-rotation"></span>
+ </div>
+</div>
+
<script type="text/javascript">
loadContent('#diskstat', '?do=SystemStatus&action=DiskStat');
loadContent('#addresses', '?do=SystemStatus&action=AddressList');
loadContent('#systeminfo', '?do=SystemStatus&action=SystemInfo');
loadContent('#services', '?do=SystemStatus&action=Services');
+ loadContent('#dmsd-log', '?do=SystemStatus&action=DmsdLog');
</script>
diff --git a/templates/systemstatus/diskstat.html b/templates/systemstatus/diskstat.html
index 71ad7b9a..019dda1a 100644
--- a/templates/systemstatus/diskstat.html
+++ b/templates/systemstatus/diskstat.html
@@ -2,7 +2,8 @@
{{#system}}
<b>{{lang_systemPartition}}</b>
<div id="circles-system"></div>
- {{lang_capacity}}: {{size}}
+ <div>{{lang_capacity}}: {{size}}</div>
+ <div>{{lang_free}}: {{free}}</div>
{{/system}}
{{^system}}
<b>{{lan_availableMemoryError}}</b>
@@ -12,7 +13,8 @@
{{#store}}
<b>{{lang_vmStore}}</b>
<div id="circles-store"></div>
- {{lang_capacity}}: {{size}}
+ <div>{{lang_capacity}}: {{size}}</div>
+ <div>{{lang_free}}: {{free}}</div>
{{/store}}
{{^store}}
<b>{{lang_vmStoreError}}</b>