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;
|
2020-04-30 09:55:49 -04:00
|
|
|
use Icinga\Module\Businessprocess\IcingaDbBackend;
|
2020-04-27 19:08:24 -04:00
|
|
|
use Icinga\Module\Icingadb\Model\Service;
|
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 ServiceController 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');
|
|
|
|
|
$serviceName = $this->params->shift('service');
|
|
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
$query = Service::on($this->getDb())->with('host');
|
|
|
|
|
IcingaDbBackend::applyIcingaDbRestrictions($query);
|
2017-12-04 12:05:07 -05:00
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
$query->getSelectBase()
|
|
|
|
|
->where(['service.name = ?' => $serviceName])
|
|
|
|
|
->where(['service_host.name = ?' => $hostName]);
|
2020-04-27 19:08:24 -04:00
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
$service = $query->first();
|
2020-04-27 19:08:24 -04:00
|
|
|
|
2020-04-30 09:55:49 -04:00
|
|
|
$this->params->add('name', $serviceName);
|
|
|
|
|
$this->params->add('host.name', $hostName);
|
2020-04-27 19:08:24 -04:00
|
|
|
|
2021-11-17 04:10:00 -05:00
|
|
|
if ($service !== false) {
|
2020-04-30 09:55:49 -04:00
|
|
|
$this->redirectNow(Url::fromPath('icingadb/service')->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');
|
|
|
|
|
$serviceName = $this->params->get('service');
|
|
|
|
|
|
2020-04-27 19:08:24 -04:00
|
|
|
$query = $this->backend->select()
|
|
|
|
|
->from('servicestatus', array('service_description'))
|
2020-04-30 09:55:49 -04:00
|
|
|
->where('host_name', $hostName)
|
|
|
|
|
->where('service_description', $serviceName);
|
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/service/show')->setParams($this->params));
|
|
|
|
|
}
|
2017-12-04 12:05:07 -05:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 09:55:49 -04:00
|
|
|
$this->view->host = $hostName;
|
|
|
|
|
$this->view->service = $serviceName;
|
2017-12-04 12:05:07 -05:00
|
|
|
}
|
|
|
|
|
}
|