icingaweb2-module-businessp.../library/Businessprocess/ServiceNode.php

83 lines
1.9 KiB
PHP
Raw Normal View History

<?php
2014-11-30 09:56:58 -05:00
namespace Icinga\Module\Businessprocess;
2015-03-16 04:08:00 -04:00
use Icinga\Web\Url;
class ServiceNode extends MonitoredNode
{
protected $hostname;
2015-03-16 04:08:00 -04:00
protected $service;
protected $className = 'service';
public function __construct(BusinessProcess $bp, $object)
{
$this->name = $object->hostname . ';' . $object->service;
$this->hostname = $object->hostname;
$this->service = $object->service;
$this->bp = $bp;
if (isset($object->state)) {
$this->setState($object->state);
} else {
$this->setState(0)->setMissing();
}
}
2014-11-30 05:30:59 -05:00
public function renderLink($view)
{
2015-03-16 04:08:00 -04:00
if ($this->isMissing()) {
return '<span class="missing">' . $view->escape($this->getAlias()) . '</span>';
}
$params = array(
'host' => $this->getHostname(),
'service' => $this->getServiceDescription()
);
if ($this->bp->hasBackendName()) {
$params['backend'] = $this->bp->getBackendName();
}
2015-10-01 17:10:30 -04:00
$link = $view->qlink($this->getAlias(), 'monitoring/service/show', $params);
2015-10-06 16:29:06 -04:00
return $link;
2015-03-16 04:08:00 -04:00
}
2015-03-16 04:08:00 -04:00
protected function getActionIcons($view)
{
$icons = array();
if (! $this->bp->isLocked()) {
$url = Url::fromPath( 'businessprocess/node/simulate', array(
'config' => $this->bp->getName(),
'node' => $this->name
2014-11-30 05:30:59 -05:00
));
2015-03-16 04:08:00 -04:00
$icons[] = $this->actionIcon(
$view,
'magic',
$url,
'Simulation'
);
2014-11-30 05:30:59 -05:00
}
2015-03-16 04:08:00 -04:00
return $icons;
2014-11-30 05:30:59 -05:00
}
public function getHostname()
{
return $this->hostname;
}
public function getServiceDescription()
{
return $this->service;
}
public function getAlias()
{
return $this->hostname . ': ' . $this->service;
}
}