Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Feb 13, 2014
1 parent bd15bb3 commit 9b55155
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 111 deletions.
2 changes: 1 addition & 1 deletion module/Application/view/layout/layout.phtml
Expand Up @@ -66,7 +66,7 @@ echo $this->doctype();
<body>

<!-- Navigation start -->
<nav class="navbar navbar-justified navbar-fixed-top" role="navigation">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">

<div class="navbar-header">
Expand Down
38 changes: 38 additions & 0 deletions module/Client/src/Client/Controller/ClientController.php
Expand Up @@ -10,6 +10,7 @@ class ClientController extends AbstractActionController

protected $clientTable;
protected $jobTable;
protected $bconsoleOutput = array();

public function indexAction()
{
Expand All @@ -28,10 +29,14 @@ public function detailsAction()
return $this->redirect()->toRoute('client');
}

$result = $this->getClientTable()->getClient($id);
$cmd = "status client=" . $result->name;

return new ViewModel(
array(
'client' => $this->getClientTable()->getClient($id),
'job' => $this->getJobTable()->getLastSuccessfulClientJob($id),
'bconsoleOutput' => $this->getBConsoleOutput($cmd),
)
);

Expand All @@ -55,5 +60,38 @@ public function getJobTable()
return $this->jobTable;
}

public function getBConsoleOutput($cmd)
{

$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "r")
);

$cwd = '/usr/sbin';
$env = array('/usr/sbin');

$process = proc_open('sudo /usr/sbin/bconsole', $descriptorspec, $pipes, $cwd, $env);

if(!is_resource($process))
throw new \Exception("proc_open error");

if(is_resource($process))
{
fwrite($pipes[0], $cmd);
fclose($pipes[0]);
while(!feof($pipes[1])) {
array_push($this->bconsoleOutput, fread($pipes[1],8192));
}
fclose($pipes[1]);
}

$return_value = proc_close($process);

return $this->bconsoleOutput;

}

}

42 changes: 33 additions & 9 deletions module/Client/view/client/client/details.phtml
Expand Up @@ -19,23 +19,26 @@ $this->headTitle($title);

<div class="panel-body">

<table class="table table-striped table-hover" style="font-size: 9pt;">

<tr><td>Client</td><td><?php echo $this->escapeHtml($client->clientid); ?></td></tr>
<tr><td>Name</td><td><?php echo $this->escapeHtml($client->name); ?></td></tr>
<tr><td>Version</td><td><?php echo $this->escapeHtml($client->uname); ?></td></tr>
<tr><td>Autoprune</td><td><?php echo $this->escapeHtml($client->autoprune); ?></td></tr>
<tr><td>Fileretention</td><td><?php echo $this->printRetention($client->fileretention) . " days"; ?></td></tr>
<tr><td>Jobretention</td><td><?php echo $this->printRetention($client->jobretention) . " days"; ?></td></tr>
<tr><td>Last successful backup</td><td><a href="<?php echo $this->url('job', array('action'=>'details', 'id' => $job->jobid)); ?>" title="<?php echo $job->endtime; ?>"><?php echo $this->printHumanReadableTimeperiod($job->endtime, "fuzzy")?> (Level: <?php echo $this->printJobLevel($job->level); ?>)</a></td></tr>
<table class="table table-striped table-bordered" style="font-size: 9pt;">

<tr><td><b>Client</b></td><td><?php echo $this->escapeHtml($client->clientid); ?></td></tr>
<tr><td><b>Name</b></td><td><?php echo $this->escapeHtml($client->name); ?></td></tr>
<tr><td><b>Version</b></td><td><?php echo $this->escapeHtml($client->uname); ?></td></tr>
<tr><td><b>Autoprune</b></td><td><?php echo $this->escapeHtml($client->autoprune); ?></td></tr>
<tr><td><b>Fileretention</b></td><td><?php echo $this->printRetention($client->fileretention) . " days"; ?></td></tr>
<tr><td><b>Jobretention</b></td><td><?php echo $this->printRetention($client->jobretention) . " days"; ?></td></tr>
<tr><td><b>Last successful backup</b></td><td><a href="<?php echo $this->url('job', array('action'=>'details', 'id' => $job->jobid)); ?>" title="<?php echo $job->endtime; ?>"><?php echo $this->printHumanReadableTimeperiod($job->endtime, "fuzzy")?> (Level: <?php echo $this->printJobLevel($job->level); ?>)</a></td></tr>
<tr><td><b>Online status</b></td><td></td></tr>
</table>

</div>

</div>
</div>

</div>

<!--
<div class="col-md-5">
<div class="panel panel-default">
Expand All @@ -47,6 +50,27 @@ $this->headTitle($title);
<div class="panel-body">
</div>
</div>
-->

<!-- bconsoleOutput start -->
<div class="row">

<div class="col-md-12">

<pre style="font-size: 8pt;">
<code>
<?php
foreach($this->bconsoleOutput as $row) {
echo $row ."<br />";
}
?>
</code>
</pre>

</div>

</div>
<!-- bconsoleOutput end -->

</div>

Expand Down
4 changes: 3 additions & 1 deletion module/Client/view/client/client/index.phtml
Expand Up @@ -24,18 +24,20 @@ $this->headTitle($title);
<th>Autoprune</th>
<th>Fileretention</th>
<th>Jobretention</th>
<th>Online status</th>
</tr>

<?php foreach($this->paginator as $client) : ?>

<tr>

<td><a href="<?php echo $this->url('client', array('action'=>'details', 'id' => $client->clientid)); ?>"><?php echo $this->escapeHtml($client->clientid); ?></a></td>
<td><?php echo $this->escapeHtml($client->name); ?></td>
<td><a href="<?php echo $this->url('client', array('action'=>'details', 'id' => $client->clientid)); ?>"><?php echo $this->escapeHtml($client->name); ?></a></td>
<td><?php echo $this->escapeHtml($client->uname); ?></td>
<td><?php echo $this->escapeHtml($client->autoprune); ?></td>
<td><?php echo $this->printRetention($client->fileretention) . " days"; ?></td>
<td><?php echo $this->printRetention($client->jobretention) . " days"; ?></td>
<td></td>

</tr>

Expand Down
10 changes: 9 additions & 1 deletion module/Director/src/Director/Controller/DirectorController.php
Expand Up @@ -49,7 +49,15 @@ public function messagesAction()
));
}

public function schedulerAction()
public function scheduleAction()
{
$cmd = "show schedule";
return new ViewModel(array(
'directorOutput' => $this->getBConsoleOutput($cmd),
));
}

public function schedulerstatusAction()
{
$cmd = "status scheduler";
return new ViewModel(array(
Expand Down
3 changes: 2 additions & 1 deletion module/Director/view/director/director/index.phtml
Expand Up @@ -35,7 +35,8 @@ $this->headTitle($title);
<ul class="nav nav-tabs">
<li class="active"><a href="<?php echo $this->url('director', array('action'=>'index')); ?>"><?php echo $this->translate('Status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'messages')); ?>"><?php echo $this->translate('Messages'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'scheduler')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedule')); ?>"><?php echo $this->translate('Schedule'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedulerstatus')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'version')); ?>"><?php echo $this->translate('Version'); ?></a></li>
</ul>

Expand Down
3 changes: 2 additions & 1 deletion module/Director/view/director/director/messages.phtml
Expand Up @@ -34,7 +34,8 @@ $this->headTitle($title);
<ul class="nav nav-tabs">
<li><a href="<?php echo $this->url('director', array('action'=>'index')); ?>"><?php echo $this->translate('Status'); ?></a></li>
<li class="active"><a href="<?php echo $this->url('director', array('action'=>'messages')); ?>"><?php echo $this->translate('Messages'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'scheduler')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedule')); ?>"><?php echo $this->translate('Schedule'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedulerstatus')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'version')); ?>"><?php echo $this->translate('Version'); ?></a></li>
</ul>

Expand Down
Expand Up @@ -34,7 +34,8 @@ $this->headTitle($title);
<ul class="nav nav-tabs">
<li><a href="<?php echo $this->url('director', array('action'=>'index')); ?>"><?php echo $this->translate('Status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'messages')); ?>"><?php echo $this->translate('Messages'); ?></a></li>
<li class="active"><a href="<?php echo $this->url('director', array('action'=>'scheduler')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li class="active"><a href="<?php echo $this->url('director', array('action'=>'schedule')); ?>"><?php echo $this->translate('Schedule'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedulerstatus')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'version')); ?>"><?php echo $this->translate('Version'); ?></a></li>
</ul>

Expand Down
60 changes: 60 additions & 0 deletions module/Director/view/director/director/schedulerstatus.phtml
@@ -0,0 +1,60 @@
<?php

/**
*
* Barbossa - A Web-Frontend to manage Bareos
*
* @link http://github.com/fbergkemper/barbossa for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

$title = 'Director';
$this->headTitle($title);

?>

<h3 class="text-muted"><?php echo $title; ?></h3>
<hr />

<ul class="nav nav-tabs">
<li><a href="<?php echo $this->url('director', array('action'=>'index')); ?>"><?php echo $this->translate('Status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'messages')); ?>"><?php echo $this->translate('Messages'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedule')); ?>"><?php echo $this->translate('Schedule'); ?></a></li>
<li class="active"><a href="<?php echo $this->url('director', array('action'=>'schedulerstatus')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'version')); ?>"><?php echo $this->translate('Version'); ?></a></li>
</ul>

<br />

<div class="row">

<div class="col-md-12">

<pre style="font-size: 8pt;">
<code>
<?php
foreach($this->directorOutput as $row) {
echo $row ."<br />";
}
?>
</code>
</pre>

</div>

</div>
3 changes: 2 additions & 1 deletion module/Director/view/director/director/version.phtml
Expand Up @@ -34,7 +34,8 @@ $this->headTitle($title);
<ul class="nav nav-tabs">
<li><a href="<?php echo $this->url('director', array('action'=>'index')); ?>"><?php echo $this->translate('Status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'messages')); ?>"><?php echo $this->translate('Messages'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'scheduler')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedule')); ?>"><?php echo $this->translate('Schedule'); ?></a></li>
<li><a href="<?php echo $this->url('director', array('action'=>'schedulerstatus')); ?>"><?php echo $this->translate('Scheduler status'); ?></a></li>
<li class="active"><a href="<?php echo $this->url('director', array('action'=>'version')); ?>"><?php echo $this->translate('Version'); ?></a></li>
</ul>

Expand Down
12 changes: 12 additions & 0 deletions module/Job/src/Job/Controller/JobController.php
Expand Up @@ -33,6 +33,7 @@ class JobController extends AbstractActionController
{

protected $jobTable;
protected $logTable;
protected $bconsoleOutput = array();

public function indexAction()
Expand All @@ -55,6 +56,7 @@ public function detailsAction()

return new ViewModel(array(
'job' => $this->getJobTable()->getJob($id),
'log' => $this->getLogTable()->getLogsByJob($id),
));
}

Expand Down Expand Up @@ -152,6 +154,16 @@ public function getJobTable()
return $this->jobTable;
}

public function getLogTable()
{
if(!$this->logTable)
{
$sm = $this->getServiceLocator();
$this->logTable = $sm->get('Log\Model\LogTable');
}
return $this->logTable;
}

public function getBConsoleOutput($cmd)
{
$descriptorspec = array(
Expand Down

0 comments on commit 9b55155

Please sign in to comment.