mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
Handle not readable monitoring config files more intelligent
This commit is contained in:
parent
91b1a649a7
commit
5c3df3db15
@ -44,6 +44,8 @@ use Icinga\Module\Monitoring\Form\Config\Backend\CreateBackendForm;
|
|||||||
use Icinga\Module\Monitoring\Form\Config\Instance\EditInstanceForm;
|
use Icinga\Module\Monitoring\Form\Config\Instance\EditInstanceForm;
|
||||||
use Icinga\Module\Monitoring\Form\Config\Instance\CreateInstanceForm;
|
use Icinga\Module\Monitoring\Form\Config\Instance\CreateInstanceForm;
|
||||||
|
|
||||||
|
use Icinga\Exception\NotReadableError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration controller for editing monitoring resources
|
* Configuration controller for editing monitoring resources
|
||||||
*/
|
*/
|
||||||
@ -71,17 +73,17 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$this->view->messageBox = new AlertMessageBox(true);
|
$this->view->messageBox = new AlertMessageBox(true);
|
||||||
$monitoring_backends = IcingaConfig::module('monitoring', 'backends');
|
foreach (array('backends', 'instances') as $element) {
|
||||||
$monitoring_instances = IcingaConfig::module('monitoring', 'instances');
|
try {
|
||||||
if ($monitoring_backends === null) {
|
$elementConfig = IcingaConfig::module('monitoring', $element);
|
||||||
$this->view->backends = array();
|
if ($elementConfig === null) {
|
||||||
} else {
|
$this->view->{$element} = array();
|
||||||
$this->view->backends = $monitoring_backends->toArray();
|
} else {
|
||||||
}
|
$this->view->{$element} = $elementConfig->toArray();
|
||||||
if ($monitoring_instances === null) {
|
}
|
||||||
$this->view->instances = array();
|
} catch (NotReadableError $e) {
|
||||||
} else {
|
$this->view->{$element} = $e;
|
||||||
$this->view->instances = $monitoring_instances->toArray();
|
}
|
||||||
}
|
}
|
||||||
$this->render('index');
|
$this->render('index');
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,41 @@
|
|||||||
<?php use Icinga\Web\Url; ?>
|
<?php
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
|
$fileNotReadable = array();
|
||||||
|
foreach (array('backends', 'instances') as $element) {
|
||||||
|
if (is_object($this->{$element}) &&
|
||||||
|
get_class($this->{$element}) === 'Icinga\Exception\NotReadableError') {
|
||||||
|
$fileNotReadable[$element] = $this->{$element}->getMessage();
|
||||||
|
} else {
|
||||||
|
$fileNotReadable[$element] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content" data-base-target="_next">
|
<div class="content" data-base-target="_next">
|
||||||
<h1>Monitoring Backends</h1>
|
<?php if ($fileNotReadable['backends'] === false): ?>
|
||||||
|
<h1>Monitoring Backends</h1>
|
||||||
|
|
||||||
<?php if (isset($this->messageBox)): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<?= $this->messageBox->render() ?>
|
<?= $this->messageBox->render() ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
|
<a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
|
||||||
<?= $this->icon('create.png'); ?> Create New Monitoring Backend
|
<?= $this->icon('create.png'); ?> Create New Monitoring Backend
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="action">
|
<table class="action">
|
||||||
<thead>
|
<thead>
|
||||||
<th>Monitoring Backend</th>
|
<th>Monitoring Backend</th>
|
||||||
<th style="width: 5em">Remove</th>
|
<th style="width: 5em">Remove</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($this->backends as $backendName => $config): ?>
|
<?php foreach ($this->backends as $backendName => $config): ?>
|
||||||
<?php
|
<?php
|
||||||
$removeUrl = Url::fromPath('/monitoring/config/removebackend', array('backend' => $backendName));
|
$removeUrl = Url::fromPath('/monitoring/config/removebackend', array('backend' => $backendName));
|
||||||
@ -37,38 +51,49 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="fileNotReadable">
|
||||||
|
<?= $this->escape($fileNotReadable['backends']) ?>
|
||||||
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<h1>Monitoring Instances</h1>
|
<?php if ($fileNotReadable['instances'] === false): ?>
|
||||||
|
<h1>Monitoring Instances</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="<?= Url::fromPath('/monitoring/config/createinstance')->getAbsoluteUrl();?>">
|
<a href="<?= Url::fromPath('/monitoring/config/createinstance')->getAbsoluteUrl();?>">
|
||||||
<?= $this->icon('create.png'); ?> Create New Instance
|
<?= $this->icon('create.png'); ?> Create New Instance
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="action">
|
<table class="action">
|
||||||
<thead>
|
<thead>
|
||||||
<th>Instance</th>
|
<th>Instance</th>
|
||||||
<th style="width: 5em">Remove</th>
|
<th style="width: 5em">Remove</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($this->instances as $instanceName => $config): ?>
|
<?php foreach ($this->instances as $instanceName => $config): ?>
|
||||||
<?php
|
<?php
|
||||||
$removeUrl = Url::fromPath('/monitoring/config/removeinstance', array('instance' => $instanceName));
|
$removeUrl = Url::fromPath('/monitoring/config/removeinstance', array('instance' => $instanceName));
|
||||||
$editUrl = Url::fromPath('/monitoring/config/editinstance', array('instance' => $instanceName));
|
$editUrl = Url::fromPath('/monitoring/config/editinstance', array('instance' => $instanceName));
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= $editUrl; ?>"><?= $this->icon('edit.png'); ?> <?= $this->escape($instanceName); ?></a>
|
<a href="<?= $editUrl; ?>"><?= $this->icon('edit.png'); ?> <?= $this->escape($instanceName); ?></a>
|
||||||
<small>(Type: <?= isset($config['host']) ? 'Remote' : 'Local'; ?>)</small>
|
<small>(Type: <?= isset($config['host']) ? 'Remote' : 'Local'; ?>)</small>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= $removeUrl; ?>"><?= $this->icon('remove.png'); ?></a>
|
<a href="<?= $removeUrl; ?>"><?= $this->icon('remove.png'); ?></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="fileNotReadable">
|
||||||
|
<?= $this->escape($fileNotReadable['instances']) ?>
|
||||||
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -278,3 +278,9 @@ html {
|
|||||||
margin-right: 2%;
|
margin-right: 2%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fileNotReadable {
|
||||||
|
padding: 0.5em;
|
||||||
|
background-color: @colorCritical;
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user