monitoring: Adjust custom navigation renderer for backend availability checks

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-04 13:49:54 +02:00
parent 881880f18f
commit a96bead01b
2 changed files with 13 additions and 8 deletions

View File

@ -221,7 +221,7 @@ $section = $this->menuSection($this->translate('System'));
$section->add($this->translate('Monitoring Health'), array( $section->add($this->translate('Monitoring Health'), array(
'url' => 'monitoring/process/info', 'url' => 'monitoring/process/info',
'priority' => 720, 'priority' => 720,
'renderer' => 'Icinga\Module\Monitoring\Web\Menu\BackendAvailabilityMenuItemRenderer' 'renderer' => 'BackendAvailabilityNavigationItemRenderer'
)); ));
/* /*

View File

@ -1,13 +1,13 @@
<?php <?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Web\Menu; namespace Icinga\Module\Monitoring\Web\Navigation\Renderer;
use Icinga\Web\Menu; use Exception;
use Icinga\Web\Menu\BadgeMenuItemRenderer; use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
class BackendAvailabilityMenuItemRenderer extends BadgeMenuItemRenderer class BackendAvailabilityNavigationItemRenderer extends BadgeNavigationItemRenderer
{ {
/** /**
* Get whether or not the monitoring backend is currently running * Get whether or not the monitoring backend is currently running
@ -43,10 +43,15 @@ class BackendAvailabilityMenuItemRenderer extends BadgeMenuItemRenderer
*/ */
public function getCount() public function getCount()
{ {
if (! $this->isCurrentlyRunning()) { try {
return 1; if ($this->isCurrentlyRunning()) {
return 0;
}
} catch (Exception $_) {
// pass
} }
return 0;
return 1;
} }
/** /**