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

76 lines
1.6 KiB
PHP
Raw Normal View History

<?php
2014-11-30 09:56:58 -05:00
namespace Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\Html;
2015-03-16 08:11:39 -04:00
class HostNode extends MonitoredNode
{
protected $sortStateToStateMap = array(
2015-10-05 10:38:45 -04:00
4 => self::ICINGA_DOWN,
3 => self::ICINGA_UNREACHABLE,
1 => self::ICINGA_PENDING,
0 => self::ICINGA_UP
);
protected $stateToSortStateMap = array(
2015-10-05 10:38:45 -04:00
self::ICINGA_PENDING => 1,
self::ICINGA_UNREACHABLE => 3,
self::ICINGA_DOWN => 4,
self::ICINGA_UP => 0,
);
protected $stateNames = array(
2015-10-05 10:38:45 -04:00
'UP',
'DOWN',
'UNREACHABLE',
99 => 'PENDING'
);
protected $hostname;
protected $className = 'host';
2019-01-22 05:21:40 -05:00
protected $icon = 'host';
public function __construct($object)
{
$this->name = $object->hostname . ';Hoststatus';
$this->hostname = $object->hostname;
if (isset($object->state)) {
$this->setState($object->state);
} else {
$this->setState(0)->setMissing();
}
}
public function getAlias()
2014-11-30 05:30:59 -05:00
{
return $this->getHostname();
2015-03-16 08:11:39 -04:00
}
public function getHostname()
{
return $this->hostname;
}
public function getUrl()
{
$params = array(
'host' => $this->getHostname(),
);
if ($this->getBpConfig()->hasBackendName()) {
$params['backend'] = $this->getBpConfig()->getBackendName();
}
2017-12-04 12:05:07 -05:00
return Url::fromPath('businessprocess/host/show', $params);
}
public function getLink()
{
return Html::tag('a', ['href' => $this->getUrl()], $this->hostname);
}
}