From 65806fafbff49ea64b84eaff3fb2d1c6a0ff98ae Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 19 Aug 2015 11:53:00 +0200 Subject: [PATCH] MonitoredObject: Only select history entries for the respective object And fix that the default sort order is not applied. fixes #9963 --- .../library/Monitoring/DataView/DataView.php | 3 +- .../Monitoring/Object/MonitoredObject.php | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index ac4e6bc9f..69adb5839 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -496,7 +496,8 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ public function peekAhead($state = true) { - return $this->query->peekAhead($state); + $this->query->peekAhead($state); + return $this; } /** diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 5f278c92e..502a1a2d1 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -450,21 +450,29 @@ abstract class MonitoredObject implements Filterable */ public function fetchEventhistory() { - $eventHistory = $this->backend->select()->from('eventhistory', array( - 'object_type', - 'host_name', - 'host_display_name', - 'service_description', - 'service_display_name', - 'timestamp', - 'state', - 'output', - 'type' - )) + $eventHistory = $this->backend + ->select() + ->from( + 'eventhistory', + array( + 'object_type', + 'host_name', + 'host_display_name', + 'service_description', + 'service_display_name', + 'timestamp', + 'state', + 'output', + 'type' + ) + ) + ->where('object_type', $this->type) ->where('host_name', $this->host_name); + if ($this->type === self::TYPE_SERVICE) { $eventHistory->where('service_description', $this->service_description); } + $this->eventhistory = $eventHistory->applyFilter($this->getFilter()); return $this; }