2014-10-20 10:26:06 -04:00
|
|
|
<?php
|
|
|
|
|
|
2014-11-30 09:56:58 -05:00
|
|
|
namespace Icinga\Module\Businessprocess;
|
2014-10-20 10:26:06 -04:00
|
|
|
|
2015-03-16 04:08:00 -04:00
|
|
|
use Icinga\Web\Url;
|
|
|
|
|
|
2016-11-22 11:57:46 -05:00
|
|
|
class ServiceNode extends MonitoredNode
|
2014-10-20 10:26:06 -04:00
|
|
|
{
|
|
|
|
|
protected $hostname;
|
2015-03-16 04:08:00 -04:00
|
|
|
|
2014-10-20 10:26:06 -04:00
|
|
|
protected $service;
|
|
|
|
|
|
2015-10-05 06:34:47 -04:00
|
|
|
protected $className = 'service';
|
|
|
|
|
|
2014-10-20 10:26:06 -04:00
|
|
|
public function __construct(BusinessProcess $bp, $object)
|
|
|
|
|
{
|
|
|
|
|
$this->name = $object->hostname . ';' . $object->service;
|
|
|
|
|
$this->hostname = $object->hostname;
|
|
|
|
|
$this->service = $object->service;
|
|
|
|
|
$this->bp = $bp;
|
2015-01-28 14:04:45 -05:00
|
|
|
if (isset($object->state)) {
|
|
|
|
|
$this->setState($object->state);
|
|
|
|
|
} else {
|
|
|
|
|
$this->setState(0)->setMissing();
|
|
|
|
|
}
|
2014-10-20 10:26:06 -04:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
2016-11-22 11:57:46 -05: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
|
|
|
}
|
|
|
|
|
|
2014-10-20 10:26:06 -04:00
|
|
|
public function getHostname()
|
|
|
|
|
{
|
|
|
|
|
return $this->hostname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getServiceDescription()
|
|
|
|
|
{
|
|
|
|
|
return $this->service;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAlias()
|
|
|
|
|
{
|
|
|
|
|
return $this->hostname . ': ' . $this->service;
|
|
|
|
|
}
|
|
|
|
|
}
|