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\CreateInstanceForm;
|
||||
|
||||
use Icinga\Exception\NotReadableError;
|
||||
|
||||
/**
|
||||
* Configuration controller for editing monitoring resources
|
||||
*/
|
||||
@ -71,17 +73,17 @@ class Monitoring_ConfigController extends BaseConfigController {
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->messageBox = new AlertMessageBox(true);
|
||||
$monitoring_backends = IcingaConfig::module('monitoring', 'backends');
|
||||
$monitoring_instances = IcingaConfig::module('monitoring', 'instances');
|
||||
if ($monitoring_backends === null) {
|
||||
$this->view->backends = array();
|
||||
foreach (array('backends', 'instances') as $element) {
|
||||
try {
|
||||
$elementConfig = IcingaConfig::module('monitoring', $element);
|
||||
if ($elementConfig === null) {
|
||||
$this->view->{$element} = array();
|
||||
} 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');
|
||||
}
|
||||
|
@ -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">
|
||||
<?= $this->tabs->render($this); ?>
|
||||
</div>
|
||||
|
||||
<div class="content" data-base-target="_next">
|
||||
<?php if ($fileNotReadable['backends'] === false): ?>
|
||||
<h1>Monitoring Backends</h1>
|
||||
|
||||
<?php if (isset($this->messageBox)): ?>
|
||||
@ -39,7 +53,13 @@
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p class="fileNotReadable">
|
||||
<?= $this->escape($fileNotReadable['backends']) ?>
|
||||
</p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($fileNotReadable['instances'] === false): ?>
|
||||
<h1>Monitoring Instances</h1>
|
||||
|
||||
<p>
|
||||
@ -71,4 +91,9 @@
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p class="fileNotReadable">
|
||||
<?= $this->escape($fileNotReadable['instances']) ?>
|
||||
</p>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
@ -278,3 +278,9 @@ html {
|
||||
margin-right: 2%;
|
||||
}
|
||||
|
||||
.fileNotReadable {
|
||||
padding: 0.5em;
|
||||
background-color: @colorCritical;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user