mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-12 16:34:25 +02:00
parent
c9a532a2b1
commit
163911ffd7
@ -3,41 +3,50 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Web\Menu;
|
namespace Icinga\Module\Monitoring\Web\Menu;
|
||||||
|
|
||||||
use Icinga\Web\Menu as Menu;
|
use Icinga\Web\Menu;
|
||||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
|
||||||
use Icinga\Web\Menu\MenuItemRenderer;
|
use Icinga\Web\Menu\MenuItemRenderer;
|
||||||
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||||
|
|
||||||
class BackendAvailabilityMenuItemRenderer extends MenuItemRenderer
|
class BackendAvailabilityMenuItemRenderer extends MenuItemRenderer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Checks whether the monitoring backend is running or not
|
* Get whether or not the monitoring backend is currently running
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isCurrentlyRunning()
|
protected function isCurrentlyRunning()
|
||||||
{
|
{
|
||||||
return MonitoringBackend::instance()->select()->from(
|
$programStatus = MonitoringBackend::instance()
|
||||||
|
->select()
|
||||||
|
->from(
|
||||||
'programstatus',
|
'programstatus',
|
||||||
array(
|
array('is_currently_running')
|
||||||
'is_currently_running'
|
|
||||||
)
|
)
|
||||||
)->getQuery()->fetchRow()->is_currently_running;
|
->fetchRow();
|
||||||
|
return $programStatus !== false ? (bool) $programStatus : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see MenuItemRenderer::render()
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function render(Menu $menu)
|
public function render(Menu $menu)
|
||||||
{
|
{
|
||||||
return $this->getBadge() . $this->createLink($menu);
|
return $this->getBadge() . $this->createLink($menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the problem badge HTML
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function getBadge()
|
protected function getBadge()
|
||||||
{
|
{
|
||||||
if (! (bool)$this->isCurrentlyRunning()) {
|
if (! $this->isCurrentlyRunning()) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<div title="%s" class="badge-container"><span class="badge badge-critical">%s</span></div>',
|
'<div title="%s" class="badge-container"><span class="badge badge-critical">%d</span></div>',
|
||||||
mt('monitoring', 'monitoring backend is not running'),
|
sprintf(
|
||||||
|
mt('monitoring', 'Monitoring backend %s is not running'), MonitoringBackend::instance()->getName()
|
||||||
|
),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -51,10 +60,12 @@ class BackendAvailabilityMenuItemRenderer extends MenuItemRenderer
|
|||||||
*/
|
*/
|
||||||
public function getSummary()
|
public function getSummary()
|
||||||
{
|
{
|
||||||
if (! (bool)$this->isCurrentlyRunning()) {
|
if (! $this->isCurrentlyRunning()) {
|
||||||
return array(
|
return array(
|
||||||
'problems' => 1,
|
'problems' => 1,
|
||||||
'title' => mt('monitoring', 'monitoring backend is not running')
|
'title' => sprintf(
|
||||||
|
mt('monitoring', 'Monitoring backend %s is not running'), MonitoringBackend::instance()->getName()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user