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

75 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\Html\Link;
use Icinga\Module\Businessprocess\Web\Url;
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';
2017-01-11 08:04:45 -05:00
public function __construct(BpConfig $bp, $object)
{
$this->name = $object->hostname . ';Hoststatus';
$this->hostname = $object->hostname;
$this->bp = $bp;
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->bp->hasBackendName()) {
$params['backend'] = $this->bp->getBackendName();
}
return Url::fromPath('monitoring/host/show', $params);
}
public function getLink()
{
return Link::create($this->hostname, $this->getUrl());
}
}