mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
monitoring/ido: implement IDO version support
We want to make use of new IDO features without breaking compatibility. This is a quickfix as otherwise we would currently break everything below 1.10. Code contains a few TODOs as this needs improvement.
This commit is contained in:
parent
9fbdb65a4b
commit
31fa794440
@ -35,6 +35,8 @@ use Icinga\Application\Benchmark;
|
|||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Filter\Query\Tree;
|
use Icinga\Filter\Query\Tree;
|
||||||
use Icinga\Module\Monitoring\Filter\UrlViewFilter;
|
use Icinga\Module\Monitoring\Filter\UrlViewFilter;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Web\Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Ido Queries
|
* Base class for Ido Queries
|
||||||
@ -184,6 +186,18 @@ abstract class IdoQuery extends Query
|
|||||||
*/
|
*/
|
||||||
protected $allowCustomVars = false;
|
protected $allowCustomVars = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current IDO version. This is bullshit and needs to be moved somewhere
|
||||||
|
* else. As someone decided that we need no Backend-specific connection
|
||||||
|
* class unfortunately there is no better place right now. And as of the
|
||||||
|
* 'check_source' patch we need a quick fix immediately. So here you go.
|
||||||
|
*
|
||||||
|
* TODO: Fix this.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $idoVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true when the column is an aggregate column
|
* Return true when the column is an aggregate column
|
||||||
*
|
*
|
||||||
@ -580,4 +594,29 @@ abstract class IdoQuery extends Query
|
|||||||
$query = new $class($this->ds, $columns);
|
$query = new $class($this->ds, $columns);
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move this away, see note related to $idoVersion var
|
||||||
|
protected function getIdoVersion()
|
||||||
|
{
|
||||||
|
if (self::$idoVersion === null) {
|
||||||
|
$session = null;
|
||||||
|
if (Icinga::app()->isWeb()) {
|
||||||
|
// TODO: Once we have version per connection we should choose a
|
||||||
|
// namespace based on resource name
|
||||||
|
$session = Session::getSession()->getNamespace('monitoring/ido');
|
||||||
|
if (isset($session->version)) {
|
||||||
|
self::$idoVersion = $session->version;
|
||||||
|
return self::$idoVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::$idoVersion = $this->db->fetchOne(
|
||||||
|
$this->db->select()->from($this->prefix . 'dbversion', 'version')
|
||||||
|
);
|
||||||
|
if ($session !== null) {
|
||||||
|
$session->version = self::$idoVersion;
|
||||||
|
$session->write(); // <- WHY? I don't want to care about this!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self::$idoVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,6 +305,10 @@ class StatusQuery extends IdoQuery
|
|||||||
|
|
||||||
protected function joinBaseTables()
|
protected function joinBaseTables()
|
||||||
{
|
{
|
||||||
|
if (version_compare($this->getIdoVersion(), '1.10.0', '<')) {
|
||||||
|
$this->columnMap['hoststatus']['host_check_source'] = '(NULL)';
|
||||||
|
$this->columnMap['servicestatus']['service_check_source'] = '(NULL)';
|
||||||
|
}
|
||||||
$this->baseQuery = $this->db->select()->from(
|
$this->baseQuery = $this->db->select()->from(
|
||||||
array('ho' => $this->prefix . 'objects'),
|
array('ho' => $this->prefix . 'objects'),
|
||||||
array()
|
array()
|
||||||
|
@ -103,7 +103,7 @@ class ServiceStatus extends DataView
|
|||||||
'service_hard_state',
|
'service_hard_state',
|
||||||
'service_problem',
|
'service_problem',
|
||||||
'service_perfdata',
|
'service_perfdata',
|
||||||
'service_check_source',
|
'service_check_source',
|
||||||
'service_active_checks_enabled',
|
'service_active_checks_enabled',
|
||||||
'service_active_checks_enabled_changed',
|
'service_active_checks_enabled_changed',
|
||||||
'service_passive_checks_enabled',
|
'service_passive_checks_enabled',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user