mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-06-08 16:22:04 -04:00
Clean the scripts and resolve the comments
Clean the scripts to pass the phpcodesniffer tests and resolve the comments provided by Eric.
This commit is contained in:
parent
1a0ddfb08b
commit
efcea15ab6
16 changed files with 130 additions and 186 deletions
|
|
@ -3,55 +3,45 @@
|
|||
namespace Icinga\Module\Businessprocess\Controllers;
|
||||
|
||||
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
||||
use Icinga\Module\Businessprocess\Web\Controller;
|
||||
//use Icinga\Module\Businessprocess\Web\Controller;
|
||||
use Icinga\Module\Businessprocess\IcingaDbBackend;
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
class HostController extends Controller
|
||||
{
|
||||
use IcingadbDatabase;
|
||||
|
||||
protected $backend;
|
||||
|
||||
protected $allParams;
|
||||
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$this->allParams = $this->getAllParams();
|
||||
$hostName = $this->params->get('host');
|
||||
$icingadb = $this->params->get('icingadb');
|
||||
|
||||
$host = $this->params->getRequired('host');
|
||||
if ($icingadb) {
|
||||
$host = Host::on($this->getDb());
|
||||
$host->getSelectBase()
|
||||
->where(['host.name = ?' => $hostName]);
|
||||
IcingaDbBackend::applyMonitoringRestriction($host);
|
||||
|
||||
if (array_key_exists('backend', $this->allParams)) {
|
||||
if ($this->allParams['backend'] === '_icingadb') {
|
||||
$this->backend = $this->getDb();
|
||||
$rs = $host->columns('host.name')->first();
|
||||
|
||||
$this->params->add('name', $hostName);
|
||||
|
||||
if ($rs !== false) {
|
||||
$this->redirectNow(Url::fromPath('icingadb/host')->setParams($this->params));
|
||||
}
|
||||
$query = Host::on($this->backend);
|
||||
$query->getSelectBase()
|
||||
->where(['host.name = ?' => $host]);
|
||||
$this->applyMonitoringRestriction($query);
|
||||
|
||||
$queryHost = $query->columns('host.name')->assembleSelect();
|
||||
$queryHost = $this->backend->select($queryHost)->fetch();
|
||||
|
||||
$this->params->add('name', $host);
|
||||
|
||||
if ($queryHost !== false) {
|
||||
$this->redirectNow(Url::fromPath('icingadb/host/index')->setParams($this->params));
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->backend = Backend::createBackend($this->_getParam('backend'));
|
||||
$query = $this->backend->select()
|
||||
->from('hoststatus', array('host_name'))
|
||||
->where('host_name', $host);
|
||||
->where('host_name', $hostName);
|
||||
|
||||
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
|
||||
$this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params));
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->host = $host;
|
||||
$this->view->host = $hostName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ class NodeController extends Controller
|
|||
}
|
||||
if ($config->getBackendName() === '_icingadb') {
|
||||
IcingaDbState::apply($config);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
MonitoringState::apply($config);
|
||||
}
|
||||
$config->applySimulation($simulation);
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ class ProcessController extends Controller
|
|||
|
||||
if ($bp->getBackendName() === '_icingadb') {
|
||||
IcingaDbState::apply($bp);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
MonitoringState::apply($bp);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +92,6 @@ class ProcessController extends Controller
|
|||
|
||||
$this->setTitle($this->translate('Business Process "%s"'), $bp->getTitle());
|
||||
|
||||
|
||||
$renderer = $this->prepareRenderer($bp, $node);
|
||||
|
||||
if (! $this->showFullscreen && ($node === null || ! $renderer->rendersImportedNode())) {
|
||||
|
|
@ -177,6 +175,7 @@ class ProcessController extends Controller
|
|||
}
|
||||
$renderer->setUrl($this->url())
|
||||
->setPath($this->params->getValues('path'));
|
||||
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,58 +3,49 @@
|
|||
namespace Icinga\Module\Businessprocess\Controllers;
|
||||
|
||||
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
||||
use Icinga\Module\Businessprocess\Web\Controller;
|
||||
use Icinga\Module\Businessprocess\IcingaDbBackend;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
use IcingadbDatabase;
|
||||
|
||||
protected $backend;
|
||||
|
||||
protected $allParams;
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$this->allParams = $this->getAllParams();
|
||||
$hostName = $this->params->get('host');
|
||||
$serviceName = $this->params->get('service');
|
||||
$icingadb = $this->params->get('icingadb');
|
||||
|
||||
$host = $this->params->getRequired('host');
|
||||
$service = $this->params->getRequired('service');
|
||||
if ($icingadb) {
|
||||
$service = Service::on($this->getDb())->with('host');
|
||||
$service->getSelectBase()
|
||||
->where(['service_host.name = ?' => $hostName, 'service.name = ?' => $serviceName]);
|
||||
|
||||
if (array_key_exists('backend', $this->allParams)) {
|
||||
if ($this->allParams['backend'] === '_icingadb') {
|
||||
$this->backend = $this->getDb();
|
||||
IcingaDbBackend::applyMonitoringRestriction($service);
|
||||
|
||||
$rs = $service->columns('host.name')->first();
|
||||
|
||||
$this->params->add('name', $serviceName);
|
||||
$this->params->add('host.name', $hostName);
|
||||
|
||||
if ($rs !== false) {
|
||||
$this->redirectNow(Url::fromPath('icingadb/service')->setParams($this->params));
|
||||
}
|
||||
$query = Service::on($this->backend)->with('host');
|
||||
$query->getSelectBase()
|
||||
->where(['service_host.name = ?' => $host, 'service.name = ?' => $service]);
|
||||
$this->applyMonitoringRestriction($query);
|
||||
|
||||
$query = $query->columns('host.name')->assembleSelect();
|
||||
$query = $this->backend->select($query)->fetch();
|
||||
|
||||
$this->params->add('name', $service);
|
||||
$this->params->add('host.name', $host);
|
||||
|
||||
if ($query !== false) {
|
||||
$this->redirectNow(Url::fromPath('icingadb/service/index')->setParams($this->params));
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->backend = Backend::createBackend($this->_getParam('backend'));
|
||||
$query = $this->backend->select()
|
||||
->from('servicestatus', array('service_description'))
|
||||
->where('host_name', $host)
|
||||
->where('service_description', $service);
|
||||
->where('host_name', $hostName)
|
||||
->where('service_description', $serviceName);
|
||||
|
||||
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
|
||||
$this->redirectNow(Url::fromPath('monitoring/service/show')->setParams($this->params));
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->host = $host;
|
||||
$this->view->service = $service;
|
||||
$this->view->host = $hostName;
|
||||
$this->view->service = $serviceName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
|||
use Icinga\Module\Businessprocess\Common\EnumList;
|
||||
use Icinga\Module\Businessprocess\ImportedNode;
|
||||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||
use Icinga\Module\Businessprocess\MonitoringRestrictions;
|
||||
use Icinga\Module\Businessprocess\Storage\Storage;
|
||||
use Icinga\Module\Businessprocess\Web\Form\QuickForm;
|
||||
use Icinga\Module\Businessprocess\Web\Form\Validator\NoDuplicateChildrenValidator;
|
||||
|
|
@ -18,11 +17,9 @@ use Icinga\Web\Session\SessionNamespace;
|
|||
|
||||
class AddNodeForm extends QuickForm
|
||||
{
|
||||
use MonitoringRestrictions;
|
||||
|
||||
use EnumList;
|
||||
|
||||
/** @var MonitoringBackend */
|
||||
/** @var MonitoringBackend|IcingadbDatabase */
|
||||
protected $backend;
|
||||
|
||||
/** @var Storage */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Businessprocess\Forms;
|
|||
|
||||
use Icinga\Module\Businessprocess\BpNode;
|
||||
use Icinga\Module\Businessprocess\BpConfig;
|
||||
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
||||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||
use Icinga\Module\Businessprocess\Node;
|
||||
use Icinga\Module\Businessprocess\Web\Form\QuickForm;
|
||||
|
|
@ -12,7 +13,7 @@ use Icinga\Web\Session\SessionNamespace;
|
|||
|
||||
class DeleteNodeForm extends QuickForm
|
||||
{
|
||||
/** @var MonitoringBackend */
|
||||
/** @var MonitoringBackend|IcingadbDatabase */
|
||||
protected $backend;
|
||||
|
||||
/** @var BpConfig */
|
||||
|
|
@ -79,7 +80,7 @@ class DeleteNodeForm extends QuickForm
|
|||
}
|
||||
|
||||
/**
|
||||
* @param MonitoringBackend $backend
|
||||
* @param MonitoringBackend|IcingadbDatabase $backend
|
||||
* @return $this
|
||||
*/
|
||||
public function setBackend($backend)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use Icinga\Module\Businessprocess\BpConfig;
|
|||
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
||||
use Icinga\Module\Businessprocess\Common\EnumList;
|
||||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||
use Icinga\Module\Businessprocess\MonitoringRestrictions;
|
||||
use Icinga\Module\Businessprocess\Node;
|
||||
use Icinga\Module\Businessprocess\Web\Form\QuickForm;
|
||||
use Icinga\Module\Businessprocess\Web\Form\Validator\NoDuplicateChildrenValidator;
|
||||
|
|
@ -16,13 +15,12 @@ use Icinga\Web\Session\SessionNamespace;
|
|||
|
||||
class EditNodeForm extends QuickForm
|
||||
{
|
||||
use MonitoringRestrictions;
|
||||
|
||||
use EnumList;
|
||||
|
||||
/** @var MonitoringBackend */
|
||||
/** @var MonitoringBackend|IcingadbDatabase */
|
||||
protected $backend;
|
||||
|
||||
/** @var string $backendName */
|
||||
protected $backendName;
|
||||
|
||||
/** @var BpConfig */
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class BpConfig
|
|||
|
||||
/**
|
||||
* Backend to retrieve states from
|
||||
*
|
||||
* @var MonitoringBackend|IcingadbDatabase
|
||||
*/
|
||||
protected $backend;
|
||||
|
||||
|
|
@ -293,8 +295,7 @@ class BpConfig
|
|||
if ($this->backend === null) {
|
||||
if ($this->getBackendName() === '_icingadb') {
|
||||
$this->backend = $this->getDb();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->backend = MonitoringBackend::instance(
|
||||
$this->getBackendName()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -82,4 +82,4 @@ trait EnumList
|
|||
{
|
||||
return $this->backendName === '_icingadb';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ trait IcingadbDatabase
|
|||
*/
|
||||
public function getDb()
|
||||
{
|
||||
|
||||
if ($this->db === null) {
|
||||
$config = new SqlConfig(ResourceFactory::getResourceConfig(
|
||||
AppConfig::module('icingadb')->get('icingadb', 'resource', 'icingadb')
|
||||
|
|
|
|||
|
|
@ -57,7 +57,12 @@ class HostNode extends MonitoredNode
|
|||
);
|
||||
|
||||
if ($this->getBpConfig()->hasBackendName()) {
|
||||
$params['backend'] = $this->getBpConfig()->getBackendName();
|
||||
$backendName = $this->getBpConfig()->getBackendName();
|
||||
if ($backendName === '_icingadb') {
|
||||
$params['icingadb'] = 1;
|
||||
} else {
|
||||
$params['backend'] = $this->getBpConfig()->getBackendName();
|
||||
}
|
||||
}
|
||||
|
||||
return Url::fromPath('businessprocess/host/show', $params);
|
||||
|
|
|
|||
|
|
@ -5,28 +5,28 @@ namespace Icinga\Module\Businessprocess;
|
|||
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||
use ipl\Orm\Compat\FilterProcessor;
|
||||
use ipl\Orm\Query;
|
||||
|
||||
class IcingaDbBackend
|
||||
{
|
||||
use MonitoringRestrictions;
|
||||
|
||||
use IcingadbDatabase;
|
||||
|
||||
/** @var BpConfig */
|
||||
protected $config;
|
||||
|
||||
protected $backend;
|
||||
/** @var IcingadbDatabase */
|
||||
protected $conn;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->backend = $this->getDb();
|
||||
$this->conn = $this->getDb();
|
||||
}
|
||||
|
||||
public function fetchHosts()
|
||||
{
|
||||
|
||||
$hosts = Host::on($this->getDb())
|
||||
$hosts = Host::on($this->conn)
|
||||
->orderBy('host.name');
|
||||
|
||||
$this->applyMonitoringRestriction($hosts);
|
||||
|
|
@ -36,18 +36,14 @@ class IcingaDbBackend
|
|||
|
||||
public function fetchServices($host)
|
||||
{
|
||||
$query = Service::on($this->backend)
|
||||
$services = Service::on($this->conn)
|
||||
->with('host');
|
||||
|
||||
$query->getSelectBase()
|
||||
$services->getSelectBase()
|
||||
->where(['service_host.name = ?' => $host])
|
||||
->orderBy('service.name');
|
||||
|
||||
$this->applyMonitoringRestriction($query);
|
||||
|
||||
$queryServices = $query->assembleSelect();
|
||||
$services = $this->backend->select($queryServices)->fetchAll();
|
||||
var_dump($services);
|
||||
$this->applyMonitoringRestriction($services);
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
|
@ -66,13 +62,13 @@ class IcingaDbBackend
|
|||
}
|
||||
}
|
||||
|
||||
protected function applyMonitoringRestriction(Query $query)
|
||||
public static function applyMonitoringRestriction(Query $query)
|
||||
{
|
||||
FilterProcessor::apply(
|
||||
$this->getRestriction('monitoring/filter/objects'),
|
||||
$restriction = FilterProcessor::apply(
|
||||
MonitoringRestrictions::getRestriction('monitoring/filter/objects'),
|
||||
$query
|
||||
);
|
||||
|
||||
return $this;
|
||||
return $restriction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use Icinga\Data\Filter\Filter;
|
|||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\QueryException;
|
||||
|
||||
trait MonitoringRestrictions
|
||||
class MonitoringRestrictions
|
||||
{
|
||||
/**
|
||||
* Return a filter for the given restriction
|
||||
|
|
@ -17,7 +17,7 @@ trait MonitoringRestrictions
|
|||
* @return Filter|null Filter object or null if the authenticated user is not restricted
|
||||
* @throws ConfigurationError If the restriction contains invalid filter columns
|
||||
*/
|
||||
protected function getRestriction($name)
|
||||
public static function getRestriction($name)
|
||||
{
|
||||
// Borrowed from Icinga\Module\Monitoring\Controller
|
||||
$restriction = Filter::matchAny();
|
||||
|
|
|
|||
|
|
@ -76,7 +76,12 @@ class ServiceNode extends MonitoredNode
|
|||
);
|
||||
|
||||
if ($this->getBpConfig()->hasBackendName()) {
|
||||
$params['backend'] = $this->getBpConfig()->getBackendName();
|
||||
$backendName = $this->getBpConfig()->getBackendName();
|
||||
if ($backendName === '_icingadb') {
|
||||
$params['icingadb'] = 1;
|
||||
} else {
|
||||
$params['backend'] = $this->getBpConfig()->getBackendName();
|
||||
}
|
||||
}
|
||||
|
||||
return Url::fromPath('businessprocess/service/show', $params);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ use Icinga\Module\Businessprocess\ServiceNode;
|
|||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
|
||||
ini_set("xdebug.var_display_max_children", -1);
|
||||
ini_set("xdebug.var_display_max_data", -1);
|
||||
ini_set("xdebug.var_display_max_depth", -1);
|
||||
|
||||
class IcingaDbState extends IcingaDbBackend
|
||||
{
|
||||
/** @var BpConfig */
|
||||
|
|
@ -54,57 +50,62 @@ class IcingaDbState extends IcingaDbBackend
|
|||
{
|
||||
$config = $this->config;
|
||||
|
||||
Benchmark::measure('Retrieving states for business process ' . $config->getName());
|
||||
$backend = $this->backend;
|
||||
Benchmark::measure('Retrieving states for business process ' . $config->getName());;
|
||||
|
||||
$hosts = $config->listInvolvedHostNames();
|
||||
if (empty($hosts)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$queryHost = Host::on($backend)->with('state');
|
||||
$queryHost = Host::on($this->backend)->with('state');
|
||||
|
||||
$queryHost->getSelectBase()
|
||||
->where(['host.name IN (?)' => $hosts]);
|
||||
|
||||
$columns = $queryHost->assembleSelect()->getColumns();
|
||||
$resetHostCols = [];
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
$tmpKey = str_replace('.','_',$column);
|
||||
$resetHostCols[] = $tmpKey;
|
||||
}
|
||||
// $resetHostCols = [];
|
||||
// foreach ($columns as $column) {
|
||||
// $tmpKey = str_replace('.', '_', $column);
|
||||
// $resetHostCols[] = $tmpKey;
|
||||
// }
|
||||
$this->applyMonitoringRestriction($queryHost);
|
||||
|
||||
// /** @var Host $host */
|
||||
$hostList = $queryHost->assembleSelect();
|
||||
$hostList = $backend->select($hostList)->fetchAll();
|
||||
|
||||
foreach ($hostList as $idx => $hst)
|
||||
{
|
||||
$hst = get_object_vars($hst);
|
||||
$hostColVals = array_values($hst);
|
||||
$hst = array_combine($resetHostCols, $hostColVals);
|
||||
$hostList[$idx] = $hst;
|
||||
if($hst['host_state_state_type'] === 'hard') {
|
||||
$hostStateCol = 'host_state_hard_state';
|
||||
} else {
|
||||
$hostStateCol = 'host_state_soft_state';
|
||||
}
|
||||
// $hostList = $queryHost->assembleSelect();
|
||||
// $hostList = $backend->select($hostList)->fetchAll();
|
||||
//
|
||||
// foreach ($hostList as $idx => $hst) {
|
||||
// $hst = get_object_vars($hst);
|
||||
// $hostColVals = array_values($hst);
|
||||
// $hst = array_combine($resetHostCols, $hostColVals);
|
||||
// $hostList[$idx] = $hst;
|
||||
// if ($hst['host_state_state_type'] === 'hard') {
|
||||
// $hostStateCol = 'host_state_hard_state';
|
||||
// } else {
|
||||
// $hostStateCol = 'host_state_soft_state';
|
||||
// }
|
||||
// }
|
||||
if ($this->config->usesHardStates()) {
|
||||
$stateCol = 'state.hard_state';
|
||||
} else {
|
||||
$stateCol = 'state.soft_state';
|
||||
}
|
||||
|
||||
$hostStatusCols = array(
|
||||
'hostname' => 'host_name',
|
||||
'last_state_change' => 'host_state_last_state_change',
|
||||
'in_downtime' => 'host_state_in_downtime',
|
||||
'ack' => 'host_state_is_acknowledged',
|
||||
'state' => $hostStateCol,
|
||||
'display_name' =>'host_display_name'
|
||||
'hostname' => 'host.name',
|
||||
'last_state_change' => 'state.last_state_change',
|
||||
'in_downtime' => 'state.in_downtime',
|
||||
'ack' => 'state.is_acknowledged',
|
||||
'state' => $stateCol,
|
||||
'display_name' =>'host.display_name'
|
||||
);
|
||||
$hostStatus = $this->selectArrayCols($hostList,$hostStatusCols);
|
||||
|
||||
$queryHost = $queryHost->columns($hostStatusCols)->assembleSelect();
|
||||
|
||||
$hostStatus = $this->backend->select($queryHost)->fetchAll();
|
||||
|
||||
Benchmark::measure('Retrieved states for ' . count($hostStatus) . ' hosts in ' . $config->getName());
|
||||
|
||||
$queryService = Service::on($backend)->with([
|
||||
$queryService = Service::on($this->backend)->with([
|
||||
'state',
|
||||
'host',
|
||||
'host.state'
|
||||
|
|
@ -112,43 +113,22 @@ class IcingaDbState extends IcingaDbBackend
|
|||
$queryService->getSelectBase()
|
||||
->where(['service_host.name IN (?)' => $hosts]);
|
||||
|
||||
$columns = $queryService->assembleSelect()->getColumns();
|
||||
$resetServiceCols = [];
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
$tmpKey = str_replace('.','_',$column);
|
||||
$resetServiceCols[] = $tmpKey;
|
||||
}
|
||||
$this->applyMonitoringRestriction($queryService);
|
||||
|
||||
$serviceList = $queryService->assembleSelect();
|
||||
|
||||
$serviceList = $backend->select($serviceList)->fetchAll();
|
||||
|
||||
foreach ($serviceList as $idx => $srvc)
|
||||
{
|
||||
$srvc = get_object_vars($srvc);
|
||||
$serviceColVals = array_values($srvc);
|
||||
$srvc = array_combine($resetServiceCols, $serviceColVals);
|
||||
$serviceList[$idx] = $srvc;
|
||||
if($srvc['service_state_state_type'] === 'hard') {
|
||||
$serviceStateCol = 'service_state_hard_state';
|
||||
} else {
|
||||
$serviceStateCol = 'service_state_soft_state';
|
||||
}
|
||||
}
|
||||
|
||||
$serviceStatusCols = array(
|
||||
'hostname' => 'service_host_name',
|
||||
'service' => 'service_name',
|
||||
'last_state_change' => 'service_state_last_state_change',
|
||||
'in_downtime' => 'service_state_in_downtime',
|
||||
'ack' => 'service_host_state_is_acknowledged',
|
||||
'state' => $serviceStateCol,
|
||||
'display_name' => 'service_display_name',
|
||||
'host_display_name' => 'service_host_display_name'
|
||||
'hostname' => 'host.name',
|
||||
'service' => 'service.name',
|
||||
'last_state_change' => 'state.last_state_change',
|
||||
'in_downtime' => 'state.in_downtime',
|
||||
'ack' => 'host.state.is_acknowledged',
|
||||
'state' => $stateCol,
|
||||
'display_name' => 'service.display_name',
|
||||
'host_display_name' => 'host.display_name'
|
||||
);
|
||||
$serviceStatus = $this->selectArrayCols($serviceList,$serviceStatusCols);
|
||||
|
||||
$queryService = $queryService->columns($serviceStatusCols)->assembleSelect();
|
||||
|
||||
$serviceStatus = $this->backend->select($queryService)->fetchAll();
|
||||
|
||||
Benchmark::measure('Retrieved states for ' . count($serviceStatus) . ' services in ' . $config->getName());
|
||||
|
||||
|
|
@ -171,22 +151,6 @@ class IcingaDbState extends IcingaDbBackend
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function selectArrayCols ($array, $cols)
|
||||
{
|
||||
$selectArrayCols = [];
|
||||
foreach ($array as $idx => $subArray)
|
||||
{
|
||||
$tmpArray = [];
|
||||
foreach ($cols as $colKey => $colVal)
|
||||
{
|
||||
$tmpArray[$colKey] = $subArray[$colVal];
|
||||
}
|
||||
$selectArrayCols[$idx] = (object) $tmpArray;
|
||||
}
|
||||
|
||||
return $selectArrayCols;
|
||||
}
|
||||
|
||||
protected function handleDbRow($row, BpConfig $config)
|
||||
{
|
||||
$key = $row->hostname;
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ class Dashboard extends BaseHtmlElement
|
|||
$bp = $storage->loadProcess($name);
|
||||
if ($bp->getBackendName() === '_icingadb') {
|
||||
IcingaDbState::apply($bp);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
MonitoringState::apply($bp);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue