mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Don't hide errors in the BackendAvailabilityNavigationItemRenderer
If an exception occurs when fetching the dataview, we will now log the exception and display a badge in state unknown.
This commit is contained in:
parent
439d78a982
commit
a9f3f99049
@ -4,6 +4,7 @@
|
|||||||
namespace Icinga\Module\Monitoring\Web\Navigation\Renderer;
|
namespace Icinga\Module\Monitoring\Web\Navigation\Renderer;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||||
use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
|
use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
|
||||||
|
|
||||||
@ -40,37 +41,33 @@ class BackendAvailabilityNavigationItemRenderer extends BadgeNavigationItemRende
|
|||||||
{
|
{
|
||||||
if ($this->count === null) {
|
if ($this->count === null) {
|
||||||
try {
|
try {
|
||||||
$count = 0;
|
|
||||||
$programStatus = $this->isCurrentlyRunning();
|
$programStatus = $this->isCurrentlyRunning();
|
||||||
$titles = array();
|
} catch (Exception $e) {
|
||||||
if (! (bool) $programStatus->notifications_enabled) {
|
Logger::debug($e);
|
||||||
$count = 1;
|
|
||||||
$this->state = static::STATE_WARNING;
|
|
||||||
$titles[] = mt('monitoring', 'Notifications are disabled');
|
|
||||||
}
|
|
||||||
if (! (bool) $programStatus->is_currently_running) {
|
|
||||||
$count = 1;
|
|
||||||
$this->state = static::STATE_CRITICAL;
|
|
||||||
array_unshift($titles, sprintf(
|
|
||||||
mt('monitoring', 'Monitoring backend %s is not running'),
|
|
||||||
MonitoringBackend::instance()->getName()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
$this->count = $count;
|
|
||||||
$this->title = implode('. ', $titles);
|
|
||||||
} catch (Exception $_) {
|
|
||||||
$this->count = 1;
|
$this->count = 1;
|
||||||
|
$this->state = static::STATE_UNKNOWN;
|
||||||
|
$this->title = $e->getMessage();
|
||||||
|
return $this->count;
|
||||||
}
|
}
|
||||||
|
$count = 0;
|
||||||
|
$titles = array();
|
||||||
|
if (! (bool) $programStatus->notifications_enabled) {
|
||||||
|
$count = 1;
|
||||||
|
$this->state = static::STATE_WARNING;
|
||||||
|
$titles[] = mt('monitoring', 'Notifications are disabled');
|
||||||
|
}
|
||||||
|
if (! (bool) $programStatus->is_currently_running) {
|
||||||
|
$count = 1;
|
||||||
|
$this->state = static::STATE_CRITICAL;
|
||||||
|
array_unshift($titles, sprintf(
|
||||||
|
mt('monitoring', 'Monitoring backend %s is not running'),
|
||||||
|
MonitoringBackend::instance()->getName()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$this->count = $count;
|
||||||
|
$this->title = implode('. ', $titles);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->count;
|
return $this->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getState()
|
|
||||||
{
|
|
||||||
return $this->state;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user