Merge pull request #4854 from Icinga/fix/incorrect-history-time-and-date-4853
Fix incorrect history time and date
This commit is contained in:
commit
97f459b7e9
|
@ -234,7 +234,7 @@ class DbQuery extends SimpleQuery
|
||||||
$value = (int) $value;
|
$value = (int) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->timestampForSql($value);
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,18 +3,24 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host comment removal records
|
* Query for host comment removal records
|
||||||
*/
|
*/
|
||||||
class HostcommentdeletionhistoryQuery extends HostcommenthistoryQuery
|
class HostcommentdeletionhistoryQuery extends HostcommenthistoryQuery
|
||||||
{
|
{
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'hch.deletion_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('hch.deletion_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host comment history records
|
* Query for host comment history records
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +43,7 @@ class HostcommenthistoryQuery extends IdoQuery
|
||||||
'object_type' => '(\'host\')',
|
'object_type' => '(\'host\')',
|
||||||
'output' => "('[' || hch.author_name || '] ' || hch.comment_data)",
|
'output' => "('[' || hch.author_name || '] ' || hch.comment_data)",
|
||||||
'state' => '(-1)',
|
'state' => '(-1)',
|
||||||
'timestamp' => 'hch.comment_time',
|
'timestamp' => 'UNIX_TIMESTAMP(hch.comment_time)',
|
||||||
'type' => "(CASE hch.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'dt_comment' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END)"
|
'type' => "(CASE hch.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'dt_comment' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END)"
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -68,13 +71,16 @@ class HostcommenthistoryQuery extends IdoQuery
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'hch.comment_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('hch.comment_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,18 +3,24 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host downtime end history records
|
* Query for host downtime end history records
|
||||||
*/
|
*/
|
||||||
class HostdowntimeendhistoryQuery extends HostdowntimestarthistoryQuery
|
class HostdowntimeendhistoryQuery extends HostdowntimestarthistoryQuery
|
||||||
{
|
{
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'hdh.actual_end_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('hdh.actual_end_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host downtime start history records
|
* Query for host downtime start history records
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +43,7 @@ class HostdowntimestarthistoryQuery extends IdoQuery
|
||||||
'object_type' => '(\'host\')',
|
'object_type' => '(\'host\')',
|
||||||
'output' => "('[' || hdh.author_name || '] ' || hdh.comment_data)",
|
'output' => "('[' || hdh.author_name || '] ' || hdh.comment_data)",
|
||||||
'state' => '(-1)',
|
'state' => '(-1)',
|
||||||
'timestamp' => 'hdh.actual_start_time',
|
'timestamp' => 'UNIX_TIMESTAMP(hdh.actual_start_time)',
|
||||||
'type' => "('dt_start')"
|
'type' => "('dt_start')"
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -68,13 +71,16 @@ class HostdowntimestarthistoryQuery extends IdoQuery
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'hdh.actual_start_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('hdh.actual_start_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host flapping start history records
|
* Query for host flapping start history records
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +43,7 @@ class HostflappingstarthistoryQuery extends IdoQuery
|
||||||
'object_type' => '(\'host\')',
|
'object_type' => '(\'host\')',
|
||||||
'output' => '(hfh.percent_state_change || \'\')',
|
'output' => '(hfh.percent_state_change || \'\')',
|
||||||
'state' => '(-1)',
|
'state' => '(-1)',
|
||||||
'timestamp' => 'hfh.event_time',
|
'timestamp' => 'UNIX_TIMESTAMP(hfh.event_time)',
|
||||||
'type' => '(\'flapping\')'
|
'type' => '(\'flapping\')'
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -68,13 +71,16 @@ class HostflappingstarthistoryQuery extends IdoQuery
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'hfh.event_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('hfh.event_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,7 +40,7 @@ class HostnotificationQuery extends IdoQuery
|
||||||
'history' => array(
|
'history' => array(
|
||||||
'output' => null,
|
'output' => null,
|
||||||
'state' => 'hn.state',
|
'state' => 'hn.state',
|
||||||
'timestamp' => 'hn.start_time',
|
'timestamp' => 'UNIX_TIMESTAMP(hn.start_time)',
|
||||||
'type' => '
|
'type' => '
|
||||||
CASE hn.notification_reason
|
CASE hn.notification_reason
|
||||||
WHEN 1 THEN \'notification_ack\'
|
WHEN 1 THEN \'notification_ack\'
|
||||||
|
@ -63,7 +63,7 @@ class HostnotificationQuery extends IdoQuery
|
||||||
'notification_output' => 'hn.output',
|
'notification_output' => 'hn.output',
|
||||||
'notification_reason' => 'hn.notification_reason',
|
'notification_reason' => 'hn.notification_reason',
|
||||||
'notification_state' => 'hn.state',
|
'notification_state' => 'hn.state',
|
||||||
'notification_timestamp' => 'hn.start_time',
|
'notification_timestamp' => 'UNIX_TIMESTAMP(hn.start_time)',
|
||||||
'object_type' => '(\'host\')'
|
'object_type' => '(\'host\')'
|
||||||
),
|
),
|
||||||
'servicegroups' => array(
|
'servicegroups' => array(
|
||||||
|
@ -81,24 +81,24 @@ class HostnotificationQuery extends IdoQuery
|
||||||
|
|
||||||
protected function requireFilterColumns(Filter $filter)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if ($filter instanceof FilterExpression && $filter->getColumn() === 'output') {
|
if ($filter instanceof FilterExpression) {
|
||||||
$this->requireColumn($filter->getColumn());
|
switch ($filter->getColumn()) {
|
||||||
|
case 'output':
|
||||||
|
$this->requireColumn('output');
|
||||||
$filter->setColumn('hn.output');
|
$filter->setColumn('hn.output');
|
||||||
return null;
|
return null;
|
||||||
|
case 'timestamp':
|
||||||
|
case 'notification_timestamp':
|
||||||
|
$this->requireColumn($filter->getColumn());
|
||||||
|
$filter->setColumn('hn.start_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::requireFilterColumns($filter);
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTimestamp($field)
|
|
||||||
{
|
|
||||||
if (! parent::isTimestamp($field)) {
|
|
||||||
return $field === 'hn.start_time';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host state history records
|
* Query for host state history records
|
||||||
*/
|
*/
|
||||||
|
@ -73,18 +76,36 @@ class HoststatehistoryQuery extends IdoQuery
|
||||||
'object_type' => '(\'host\')',
|
'object_type' => '(\'host\')',
|
||||||
'output' => '(CASE WHEN hh.state_type = 1 THEN hh.output ELSE \'[ \' || hh.current_check_attempt || \'/\' || hh.max_check_attempts || \' ] \' || hh.output END)',
|
'output' => '(CASE WHEN hh.state_type = 1 THEN hh.output ELSE \'[ \' || hh.current_check_attempt || \'/\' || hh.max_check_attempts || \' ] \' || hh.output END)',
|
||||||
'state' => 'hh.state',
|
'state' => 'hh.state',
|
||||||
'timestamp' => 'hh.state_time',
|
'timestamp' => 'UNIX_TIMESTAMP(hh.state_time)',
|
||||||
'type' => "(CASE WHEN hh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)"
|
'type' => "(CASE WHEN hh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)"
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression) {
|
||||||
return $field === 'hh.state_time';
|
switch ($filter->getColumn()) {
|
||||||
|
case 'timestamp':
|
||||||
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('hh.state_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
|
case 'type':
|
||||||
|
if (! is_array($filter->getExpression())) {
|
||||||
|
$this->requireColumn('type');
|
||||||
|
$filter->setColumn('hh.state_type');
|
||||||
|
if (isset($this->types[$filter->getExpression()])) {
|
||||||
|
$filter->setExpression($this->types[$filter->getExpression()]);
|
||||||
|
} else {
|
||||||
|
$filter->setExpression(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ abstract class IdoQuery extends DbQuery
|
||||||
*
|
*
|
||||||
* This calls requireVirtualTable if needed
|
* This calls requireVirtualTable if needed
|
||||||
*
|
*
|
||||||
* @param $alias The alias of the column to require
|
* @param string $alias The alias of the column to require
|
||||||
*
|
*
|
||||||
* @return $this Fluent interface
|
* @return $this Fluent interface
|
||||||
* @see IdoQuery::requireVirtualTable The method initializing required joins
|
* @see IdoQuery::requireVirtualTable The method initializing required joins
|
||||||
|
|
|
@ -3,18 +3,24 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for service comment removal records
|
* Query for service comment removal records
|
||||||
*/
|
*/
|
||||||
class ServicecommentdeletionhistoryQuery extends ServicecommenthistoryQuery
|
class ServicecommentdeletionhistoryQuery extends ServicecommenthistoryQuery
|
||||||
{
|
{
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'sch.deletion_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('sch.deletion_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for service comment history records
|
* Query for service comment history records
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +47,7 @@ class ServicecommenthistoryQuery extends IdoQuery
|
||||||
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
||||||
'service_host_name' => 'so.name1',
|
'service_host_name' => 'so.name1',
|
||||||
'state' => '(-1)',
|
'state' => '(-1)',
|
||||||
'timestamp' => 'sch.comment_time',
|
'timestamp' => 'UNIX_TIMESTAMP(sch.comment_time)',
|
||||||
'type' => "(CASE sch.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'dt_comment' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END)"
|
'type' => "(CASE sch.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'dt_comment' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END)"
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -69,13 +72,16 @@ class ServicecommenthistoryQuery extends IdoQuery
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'sch.comment_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('sch.comment_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,18 +3,24 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for host downtime end history records
|
* Query for host downtime end history records
|
||||||
*/
|
*/
|
||||||
class ServicedowntimeendhistoryQuery extends ServicedowntimestarthistoryQuery
|
class ServicedowntimeendhistoryQuery extends ServicedowntimestarthistoryQuery
|
||||||
{
|
{
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'sdh.actual_end_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('sdh.actual_end_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for service downtime start history records
|
* Query for service downtime start history records
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +47,7 @@ class ServicedowntimestarthistoryQuery extends IdoQuery
|
||||||
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
||||||
'service_host_name' => 'so.name1',
|
'service_host_name' => 'so.name1',
|
||||||
'state' => '(-1)',
|
'state' => '(-1)',
|
||||||
'timestamp' => 'sdh.actual_start_time',
|
'timestamp' => 'UNIX_TIMESTAMP(sdh.actual_start_time)',
|
||||||
'type' => "('dt_start')"
|
'type' => "('dt_start')"
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -69,13 +72,16 @@ class ServicedowntimestarthistoryQuery extends IdoQuery
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'sdh.actual_start_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('sdh.actual_start_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for service flapping start history records
|
* Query for service flapping start history records
|
||||||
*/
|
*/
|
||||||
|
@ -43,7 +46,7 @@ class ServiceflappingstarthistoryQuery extends IdoQuery
|
||||||
'service_description' => 'so.name2',
|
'service_description' => 'so.name2',
|
||||||
'service_host_name' => 'so.name1',
|
'service_host_name' => 'so.name1',
|
||||||
'state' => '(-1)',
|
'state' => '(-1)',
|
||||||
'timestamp' => 'sfh.event_time',
|
'timestamp' => 'UNIX_TIMESTAMP(sfh.event_time)',
|
||||||
'type' => "('flapping')"
|
'type' => "('flapping')"
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -68,13 +71,16 @@ class ServiceflappingstarthistoryQuery extends IdoQuery
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression && $filter->getColumn() === 'timestamp') {
|
||||||
return $field === 'sfh.event_time';
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('sfh.event_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ServicenotificationQuery extends IdoQuery
|
||||||
'history' => array(
|
'history' => array(
|
||||||
'output' => null,
|
'output' => null,
|
||||||
'state' => 'sn.state',
|
'state' => 'sn.state',
|
||||||
'timestamp' => 'sn.start_time',
|
'timestamp' => 'UNIX_TIMESTAMP(sn.start_time)',
|
||||||
'type' => '
|
'type' => '
|
||||||
CASE sn.notification_reason
|
CASE sn.notification_reason
|
||||||
WHEN 1 THEN \'notification_ack\'
|
WHEN 1 THEN \'notification_ack\'
|
||||||
|
@ -63,7 +63,7 @@ class ServicenotificationQuery extends IdoQuery
|
||||||
'notification_output' => 'sn.output',
|
'notification_output' => 'sn.output',
|
||||||
'notification_reason' => 'sn.notification_reason',
|
'notification_reason' => 'sn.notification_reason',
|
||||||
'notification_state' => 'sn.state',
|
'notification_state' => 'sn.state',
|
||||||
'notification_timestamp' => 'sn.start_time',
|
'notification_timestamp' => 'UNIX_TIMESTAMP(sn.start_time)',
|
||||||
'object_type' => '(\'service\')',
|
'object_type' => '(\'service\')',
|
||||||
'service' => 'so.name2 COLLATE latin1_general_ci',
|
'service' => 'so.name2 COLLATE latin1_general_ci',
|
||||||
'service_description' => 'so.name2',
|
'service_description' => 'so.name2',
|
||||||
|
@ -81,24 +81,24 @@ class ServicenotificationQuery extends IdoQuery
|
||||||
|
|
||||||
protected function requireFilterColumns(Filter $filter)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if ($filter instanceof FilterExpression && $filter->getColumn() === 'output') {
|
if ($filter instanceof FilterExpression) {
|
||||||
$this->requireColumn($filter->getColumn());
|
switch ($filter->getColumn()) {
|
||||||
|
case 'output':
|
||||||
|
$this->requireColumn('output');
|
||||||
$filter->setColumn('sn.output');
|
$filter->setColumn('sn.output');
|
||||||
return null;
|
return null;
|
||||||
|
case 'timestamp':
|
||||||
|
case 'notification_timestamp':
|
||||||
|
$this->requireColumn($filter->getColumn());
|
||||||
|
$filter->setColumn('sn.start_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::requireFilterColumns($filter);
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTimestamp($field)
|
|
||||||
{
|
|
||||||
if (! parent::isTimestamp($field)) {
|
|
||||||
return $field === 'sn.start_time';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for service state history records
|
* Query for service state history records
|
||||||
*/
|
*/
|
||||||
|
@ -74,18 +77,36 @@ class ServicestatehistoryQuery extends IdoQuery
|
||||||
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
'service_host' => 'so.name1 COLLATE latin1_general_ci',
|
||||||
'service_host_name' => 'so.name1',
|
'service_host_name' => 'so.name1',
|
||||||
'state' => 'sh.state',
|
'state' => 'sh.state',
|
||||||
'timestamp' => 'sh.state_time',
|
'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)',
|
||||||
'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)"
|
'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)"
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function isTimestamp($field)
|
protected function requireFilterColumns(Filter $filter)
|
||||||
{
|
{
|
||||||
if (! parent::isTimestamp($field)) {
|
if ($filter instanceof FilterExpression) {
|
||||||
return $field === 'sh.state_time';
|
switch ($filter->getColumn()) {
|
||||||
|
case 'timestamp':
|
||||||
|
$this->requireColumn('timestamp');
|
||||||
|
$filter->setColumn('sh.state_time');
|
||||||
|
$filter->setExpression($this->timestampForSql($this->valueToTimestamp($filter->getExpression())));
|
||||||
|
return null;
|
||||||
|
case 'type':
|
||||||
|
if (! is_array($filter->getExpression())) {
|
||||||
|
$this->requireColumn('type');
|
||||||
|
$filter->setColumn('sh.state_type');
|
||||||
|
if (isset($this->types[$filter->getExpression()])) {
|
||||||
|
$filter->setExpression($this->types[$filter->getExpression()]);
|
||||||
|
} else {
|
||||||
|
$filter->setExpression(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::requireFilterColumns($filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue