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
|
|
|
|
2016-11-23 18:30:34 -05:00
|
|
|
use Icinga\Module\Businessprocess\Web\Url;
|
2019-01-17 07:21:46 -05:00
|
|
|
use ipl\Html\Html;
|
2015-03-16 08:11:39 -04:00
|
|
|
|
2016-11-22 11:57:46 -05:00
|
|
|
class HostNode extends MonitoredNode
|
2014-10-20 10:26:06 -04:00
|
|
|
{
|
2016-12-07 16:10:35 -05:00
|
|
|
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
|
|
|
|
|
);
|
|
|
|
|
|
2016-12-07 16:10:35 -05:00
|
|
|
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,
|
|
|
|
|
);
|
|
|
|
|
|
2016-12-07 16:10:35 -05:00
|
|
|
protected $stateNames = array(
|
2015-10-05 10:38:45 -04:00
|
|
|
'UP',
|
|
|
|
|
'DOWN',
|
|
|
|
|
'UNREACHABLE',
|
|
|
|
|
99 => 'PENDING'
|
|
|
|
|
);
|
|
|
|
|
|
2014-10-20 10:26:06 -04:00
|
|
|
protected $hostname;
|
|
|
|
|
|
2015-10-05 06:34:47 -04:00
|
|
|
protected $className = 'host';
|
|
|
|
|
|
2019-01-22 05:21:40 -05:00
|
|
|
protected $icon = 'host';
|
|
|
|
|
|
2019-02-04 02:37:36 -05:00
|
|
|
public function __construct($object)
|
2014-10-20 10:26:06 -04:00
|
|
|
{
|
2015-03-16 08:15:36 -04:00
|
|
|
$this->name = $object->hostname . ';Hoststatus';
|
2014-10-20 10:26:06 -04:00
|
|
|
$this->hostname = $object->hostname;
|
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
|
|
|
}
|
|
|
|
|
|
2016-11-27 18:18:53 -05:00
|
|
|
public function getAlias()
|
2014-11-30 05:30:59 -05:00
|
|
|
{
|
2016-11-27 18:18:53 -05:00
|
|
|
return $this->getHostname();
|
2015-03-16 08:11:39 -04:00
|
|
|
}
|
|
|
|
|
|
2014-10-20 10:26:06 -04:00
|
|
|
public function getHostname()
|
|
|
|
|
{
|
|
|
|
|
return $this->hostname;
|
|
|
|
|
}
|
2016-11-27 18:18:53 -05:00
|
|
|
|
|
|
|
|
public function getUrl()
|
|
|
|
|
{
|
|
|
|
|
$params = array(
|
|
|
|
|
'host' => $this->getHostname(),
|
|
|
|
|
);
|
|
|
|
|
|
2019-02-04 02:37:36 -05:00
|
|
|
if ($this->getBpConfig()->hasBackendName()) {
|
|
|
|
|
$params['backend'] = $this->getBpConfig()->getBackendName();
|
2016-11-27 18:18:53 -05:00
|
|
|
}
|
|
|
|
|
|
2017-12-04 12:05:07 -05:00
|
|
|
return Url::fromPath('businessprocess/host/show', $params);
|
2016-11-27 18:18:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getLink()
|
|
|
|
|
{
|
2019-01-17 07:21:46 -05:00
|
|
|
return Html::tag('a', ['href' => $this->getUrl()], $this->hostname);
|
2016-11-27 18:18:53 -05:00
|
|
|
}
|
2014-10-20 10:26:06 -04:00
|
|
|
}
|