icingaweb2-module-businessp.../application/controllers/ServiceController.php

56 lines
1.8 KiB
PHP
Raw Normal View History

2017-12-04 12:05:07 -05:00
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
use Icinga\Module\Businessprocess\IcingaDbBackend;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Monitoring\Controller;
2017-12-04 12:05:07 -05:00
use Icinga\Web\Url;
class ServiceController extends Controller
{
use IcingadbDatabase;
2017-12-04 12:05:07 -05:00
public function showAction()
{
$icingadb = $this->params->shift('icingadb');
if ($icingadb) {
$hostName = $this->params->shift('host');
$serviceName = $this->params->shift('service');
$query = Service::on($this->getDb())->with('host');
IcingaDbBackend::applyIcingaDbRestrictions($query);
2017-12-04 12:05:07 -05:00
$query->getSelectBase()
->where(['service.name = ?' => $serviceName])
->where(['service_host.name = ?' => $hostName]);
$service = $query->first();
$this->params->add('name', $serviceName);
$this->params->add('host.name', $hostName);
if ($service !== false) {
$this->redirectNow(Url::fromPath('icingadb/service')->setParams($this->params));
}
} else {
$hostName = $this->params->get('host');
$serviceName = $this->params->get('service');
$query = $this->backend->select()
->from('servicestatus', array('service_description'))
->where('host_name', $hostName)
->where('service_description', $serviceName);
2017-12-04 12:05:07 -05: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
}
$this->view->host = $hostName;
$this->view->service = $serviceName;
2017-12-04 12:05:07 -05:00
}
}