mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 00:34:03 +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) {
|
||||||
|
$this->view->{$element} = array();
|
||||||
} else {
|
} else {
|
||||||
$this->view->backends = $monitoring_backends->toArray();
|
$this->view->{$element} = $elementConfig->toArray();
|
||||||
|
}
|
||||||
|
} catch (NotReadableError $e) {
|
||||||
|
$this->view->{$element} = $e;
|
||||||
}
|
}
|
||||||
if ($monitoring_instances === null) {
|
|
||||||
$this->view->instances = array();
|
|
||||||
} else {
|
|
||||||
$this->view->instances = $monitoring_instances->toArray();
|
|
||||||
}
|
}
|
||||||
$this->render('index');
|
$this->render('index');
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
<?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">
|
||||||
|
<?php if ($fileNotReadable['backends'] === false): ?>
|
||||||
<h1>Monitoring Backends</h1>
|
<h1>Monitoring Backends</h1>
|
||||||
|
|
||||||
<?php if (isset($this->messageBox)): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
@ -39,7 +53,13 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="fileNotReadable">
|
||||||
|
<?= $this->escape($fileNotReadable['backends']) ?>
|
||||||
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if ($fileNotReadable['instances'] === false): ?>
|
||||||
<h1>Monitoring Instances</h1>
|
<h1>Monitoring Instances</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -71,4 +91,9 @@
|
|||||||
<?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