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;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||
use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
|
||||
|
||||
|
@ -40,37 +41,33 @@ class BackendAvailabilityNavigationItemRenderer extends BadgeNavigationItemRende
|
|||
{
|
||||
if ($this->count === null) {
|
||||
try {
|
||||
$count = 0;
|
||||
$programStatus = $this->isCurrentlyRunning();
|
||||
$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);
|
||||
} catch (Exception $_) {
|
||||
} catch (Exception $e) {
|
||||
Logger::debug($e);
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue