2017-12-04 12:05:07 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Businessprocess\Controllers;
|
|
|
|
|
|
2020-04-27 19:08:24 -04:00
|
|
|
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
2021-11-17 10:22:22 -05:00
|
|
|
use Icinga\Module\Businessprocess\IcingaDbObject;
|
2020-04-27 19:08:24 -04:00
|
|
|
use Icinga\Module\Icingadb\Model\Host;
|
2020-04-30 09:55:49 -04:00
|
|
|
use Icinga\Module\Monitoring\Controller;
|
2017-12-04 12:05:07 -05:00
|
|
|
use Icinga\Web\Url;
|
|
|
|
|
|
|
|
|
|
class HostController extends Controller
|
|
|
|
|
{
|
2020-04-27 19:08:24 -04:00
|
|
|
use IcingadbDatabase;
|
|
|
|
|
|
2017-12-04 12:05:07 -05:00
|
|
|
public function showAction()
|
|
|
|
|
{
|
2020-05-12 17:20:01 -04:00
|
|
|
$icingadb = $this->params->shift('icingadb');
|
2020-04-27 19:08:24 -04:00
|
|
|
|
2020-04-30 09:55:49 -04:00
|
|
|
if ($icingadb) {
|
2020-05-12 17:20:01 -04:00
|
|
|
$hostName = $this->params->shift('host');
|
|
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
$query = Host::on($this->getDb());
|
2021-11-17 10:22:22 -05:00
|
|
|
IcingaDbObject::applyIcingaDbRestrictions($query);
|
2021-11-17 04:10:00 -05:00
|
|
|
|
|
|
|
|
$query->getSelectBase()
|
2020-04-30 09:55:49 -04:00
|
|
|
->where(['host.name = ?' => $hostName]);
|
2017-12-04 12:05:07 -05:00
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
$host = $query->first();
|
2020-04-27 19:08:24 -04:00
|
|
|
|
2020-04-30 09:55:49 -04:00
|
|
|
$this->params->add('name', $hostName);
|
2020-04-27 19:08:24 -04:00
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
if ($host !== false) {
|
2020-04-30 09:55:49 -04:00
|
|
|
$this->redirectNow(Url::fromPath('icingadb/host')->setParams($this->params));
|
2020-04-27 19:08:24 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2020-05-12 17:20:01 -04:00
|
|
|
$hostName = $this->params->get('host');
|
|
|
|
|
|
2020-04-27 19:08:24 -04:00
|
|
|
$query = $this->backend->select()
|
|
|
|
|
->from('hoststatus', array('host_name'))
|
2020-04-30 09:55:49 -04:00
|
|
|
->where('host_name', $hostName);
|
2017-12-04 12:05:07 -05:00
|
|
|
|
2020-04-27 19:08:24 -04:00
|
|
|
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
|
|
|
|
|
$this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params));
|
|
|
|
|
}
|
2017-12-04 12:05:07 -05:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 09:55:49 -04:00
|
|
|
$this->view->host = $hostName;
|
2017-12-04 12:05:07 -05:00
|
|
|
}
|
|
|
|
|
}
|