From e1cec6a849b7eb1ada02145cab66dc7a5107a518 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 11 Aug 2015 15:07:03 +0200 Subject: [PATCH] Drop everything related to join last comments in list views refs #8616 --- .../controllers/HostController.php | 3 - .../controllers/HostsController.php | 4 - .../controllers/ListController.php | 6 - .../controllers/ServicesController.php | 4 - .../application/views/helpers/HostFlags.php | 5 +- .../views/helpers/ServiceFlags.php | 12 +- .../Backend/Ido/Query/HoststatusQuery.php | 107 ------------- .../Backend/Ido/Query/StatusQuery.php | 149 ------------------ .../Monitoring/DataView/Hoststatus.php | 4 - .../Monitoring/DataView/Servicestatus.php | 5 - 10 files changed, 3 insertions(+), 296 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index ffc7fcdd3..1016092cf 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -98,9 +98,6 @@ class Monitoring_HostController extends MonitoredObjectController 'service_notifications_enabled', 'service_action_url', 'service_notes_url', - 'service_last_comment', - 'service_last_ack', - 'service_last_downtime', 'service_active_checks_enabled', 'service_passive_checks_enabled', 'current_check_attempt' => 'service_current_check_attempt', diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 675e639b2..9d5da9e50 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -57,9 +57,7 @@ class Monitoring_HostsController extends Controller 'host_handled', 'host_acknowledged', 'host_in_downtime', - 'host_last_ack', 'host_is_flapping', - 'host_last_comment', 'host_output', 'host_notifications_enabled', 'host_active_checks_enabled', @@ -96,9 +94,7 @@ class Monitoring_HostsController extends Controller 'host_handled', 'host_acknowledged', 'host_in_downtime', - 'host_last_ack', 'host_is_flapping', - 'host_last_comment', 'host_output', 'host_notifications_enabled', 'host_active_checks_enabled', diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e200266ad..3cbb9fca6 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -87,9 +87,6 @@ class Monitoring_ListController extends Controller 'host_notifications_enabled', 'host_action_url', 'host_notes_url', - 'host_last_comment', - 'host_last_ack', - 'host_last_downtime', 'host_active_checks_enabled', 'host_passive_checks_enabled', 'host_current_check_attempt', @@ -175,9 +172,6 @@ class Monitoring_ListController extends Controller 'service_notifications_enabled', 'service_action_url', 'service_notes_url', - 'service_last_comment', - 'service_last_ack', - 'service_last_downtime', 'service_active_checks_enabled', 'service_passive_checks_enabled', 'current_check_attempt' => 'service_current_check_attempt', diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index ba56c6144..d67880565 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -68,8 +68,6 @@ class Monitoring_ServicesController extends Controller 'service_in_downtime', 'service_is_flapping', 'service_output', - 'service_last_ack', - 'service_last_comment', 'service_notifications_enabled', 'service_active_checks_enabled', 'service_passive_checks_enabled' @@ -115,8 +113,6 @@ class Monitoring_ServicesController extends Controller 'service_acknowledged', 'service_in_downtime', 'service_is_flapping', - 'service_last_comment', - 'service_last_ack', 'service_notifications_enabled', 'service_active_checks_enabled', 'service_passive_checks_enabled' diff --git a/modules/monitoring/application/views/helpers/HostFlags.php b/modules/monitoring/application/views/helpers/HostFlags.php index 97e6fbf3d..6e416691f 100644 --- a/modules/monitoring/application/views/helpers/HostFlags.php +++ b/modules/monitoring/application/views/helpers/HostFlags.php @@ -31,9 +31,6 @@ class Zend_View_Helper_HostFlags extends Zend_View_Helper_Abstract $icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled')); } } - if (isset($host->host_last_comment) && $host->host_last_comment !== null) { - $icons[] = $this->view->icon('comment', $this->view->translate('Last Comment: ') . $host->host_last_comment); - } return $icons; } -} \ No newline at end of file +} diff --git a/modules/monitoring/application/views/helpers/ServiceFlags.php b/modules/monitoring/application/views/helpers/ServiceFlags.php index 7e71bebda..91b245cb2 100644 --- a/modules/monitoring/application/views/helpers/ServiceFlags.php +++ b/modules/monitoring/application/views/helpers/ServiceFlags.php @@ -9,12 +9,10 @@ class Zend_View_Helper_ServiceFlags extends Zend_View_Helper_Abstract $icons[] = $this->view->icon('attention-alt', $this->view->translate('Unhandled')); } if ($service->service_acknowledged && !$service->service_in_downtime) { - $icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged') . ( - $service->service_last_ack ? ': ' . $service->service_last_ack : '' - )); + $icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged')); } if ($service->service_is_flapping) { - $icons[] = $this->view->icon('flapping', $this->view->translate('Flapping')) ; + $icons[] = $this->view->icon('flapping', $this->view->translate('Flapping')); } if (!$service->service_notifications_enabled) { $icons[] = $this->view->icon('bell-off-empty', $this->view->translate('Notifications Disabled')); @@ -22,12 +20,6 @@ class Zend_View_Helper_ServiceFlags extends Zend_View_Helper_Abstract if ($service->service_in_downtime) { $icons[] = $this->view->icon('plug', $this->view->translate('In Downtime')); } - if (isset($service->service_last_comment) && $service->service_last_comment !== null) { - $icons[] = $this->view->icon( - 'comment', - $this->view->translate('Last Comment: ') . $service->service_last_comment - ); - } if (!$service->service_active_checks_enabled) { if (!$service->service_passive_checks_enabled) { $icons[] = $this->view->icon('eye-off', $this->view->translate('Active And Passive Checks Disabled')); diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index a7b237851..968d5607e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -131,18 +131,6 @@ class HoststatusQuery extends IdoQuery 'host_status_update_time' => 'hs.status_update_time', 'host_unhandled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) = 0 THEN 1 ELSE 0 END' ), - 'lasthostackcomment' => array( - 'host_last_ack' => 'hlac.last_ack_data' - ), - 'lasthostcomment' => array( - 'host_last_comment' => 'hlc.last_comment_data' - ), - 'lasthostdowntimecomment' => array( - 'host_last_downtime' => 'hldc.last_downtime_data' - ), - 'lasthostflappingcomment' => array( - 'host_last_flapping' => 'hlfc.last_flapping_data' - ), 'servicegroups' => array( 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', 'servicegroup_name' => 'sgo.name1', @@ -155,37 +143,6 @@ class HoststatusQuery extends IdoQuery ) ); - /** - * Create a sub query to join comments into status query - * - * @param int $entryType - * @param string $alias - * - * @return Zend_Db_Expr - */ - protected function createLastCommentSubQuery($entryType, $alias) - { - $sql = <<select->joinLeft( - array('hlac' => $this->createLastCommentSubQuery(4, 'last_ack_data')), - 'hlac.object_id = ho.object_id', - array() - ); - } - - /** - * Join last host comment - */ - protected function joinLasthostcomment() - { - $this->select->joinLeft( - array('hlc' => $this->createLastCommentSubQuery(1, 'last_comment_data')), - 'hlc.object_id = ho.object_id', - array() - ); - } - - /** - * Join last host downtime comment - */ - protected function joinLasthostdowntimeComment() - { - $this->select->joinLeft( - array('hldc' => $this->createLastCommentSubQuery(2, 'last_downtime_data')), - 'hldc.object_id = ho.object_id', - array() - ); - } - - /** - * Join last host flapping comment - */ - protected function joinLasthostflappingcomment() - { - $this->select->joinLeft( - array('hlfc' => $this->createLastCommentSubQuery(3, 'last_flapping_data')), - 'hlfc.object_id = ho.object_id', - array() - ); - } - /** * Join service groups */ @@ -344,22 +253,6 @@ SQL; $group[] = 'sps.unhandled_services_count'; } - if ($this->hasJoinedVirtualTable('lasthostackcomment')) { - $group[] = 'hlac.last_ack_data'; - } - - if ($this->hasJoinedVirtualTable('lasthostcomment')) { - $group[] = 'hlc.last_comment_data'; - } - - if ($this->hasJoinedVirtualTable('lasthostdowntimecomment')) { - $group[] = 'hldc.last_downtime_data'; - } - - if ($this->hasJoinedVirtualTable('lasthostflappingcomment')) { - $group[] = 'hlfc.last_flapping_data'; - } - if ($this->hasJoinedVirtualTable('hostgroups')) { $selected = false; foreach ($this->columns as $alias => $column) { diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 1dbb38eb7..1a929a006 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -3,8 +3,6 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; -use Zend_Db_Expr; - class StatusQuery extends IdoQuery { /** @@ -310,38 +308,6 @@ class StatusQuery extends IdoQuery ELSE 0 END' ), - - 'lasthostcommentgeneric' => array( - 'host_last_comment' => 'hlcg.last_comment_data' - ), - - 'lasthostcommentdowntime' => array( - 'host_last_downtime' => 'hlcd.last_downtime_data' - ), - - 'lasthostcommentflapping' => array( - 'host_last_flapping' => 'hlcf.last_flapping_data' - ), - - 'lasthostcommentack' => array( - 'host_last_ack' => 'hlca.last_ack_data' - ), - - 'lastservicecommentgeneric' => array( - 'service_last_comment' => 'slcg.last_comment_data' - ), - - 'lastservicecommentdowntime' => array( - 'service_last_downtime' => 'slcd.last_downtime_data' - ), - - 'lastservicecommentflapping' => array( - 'service_last_flapping' => 'slcf.last_flapping_data' - ), - - 'lastservicecommentack' => array( - 'service_last_ack' => 'slca.last_ack_data' - ) ); protected function joinBaseTables() @@ -523,119 +489,4 @@ class StatusQuery extends IdoQuery return $this; } - - /** - * Create a subquery to join comments into status query - * @param int $entryType - * @param string $fieldName - * @return Zend_Db_Expr - */ - protected function getLastCommentSubQuery($entryType, $fieldName) - { - $sub = '(SELECT' - . ' c.object_id,' - . " '[' || c.author_name || '] ' || c.comment_data AS $fieldName" - . ' FROM icinga_comments c JOIN (' - . ' SELECT MAX(comment_id) AS comment_id, object_id FROM icinga_comments' - . ' WHERE entry_type = ' . $entryType . ' GROUP BY object_id' - . ' ) lc ON c.comment_id = lc.comment_id)'; - - return new Zend_Db_Expr($sub); - } - - /** - * Join last host comment - */ - protected function joinLasthostcommentgeneric() - { - $this->select->joinLeft( - array('hlcg' => $this->getLastCommentSubQuery(1, 'last_comment_data')), - 'hlcg.object_id = hs.host_object_id', - array() - ); - } - - /** - * Join last host downtime comment - */ - protected function joinLasthostcommentdowntime() - { - $this->select->joinLeft( - array('hlcd' => $this->getLastCommentSubQuery(2, 'last_downtime_data')), - 'hlcd.object_id = hs.host_object_id', - array() - ); - } - - /** - * Join last host flapping comment - */ - protected function joinLastHostcommentflapping() - { - $this->select->joinLeft( - array('hlcf' => $this->getLastCommentSubQuery(3, 'last_flapping_data')), - 'hlcf.object_id = hs.host_object_id', - array() - ); - } - - /** - * Join last host acknowledgement comment - */ - protected function joinLasthostcommentack() - { - $this->select->joinLeft( - array('hlca' => $this->getLastCommentSubQuery(4, 'last_ack_data')), - 'hlca.object_id = hs.host_object_id', - array() - ); - } - - /** - * Join last service comment - */ - protected function joinLastservicecommentgeneric() - { - $this->select->joinLeft( - array('slcg' => $this->getLastCommentSubQuery(1, 'last_comment_data')), - 'slcg.object_id = ss.service_object_id', - array() - ); - } - - /** - * Join last service downtime comment - */ - protected function joinLastservicecommentdowntime() - { - $this->select->joinLeft( - array('slcd' => $this->getLastCommentSubQuery(2, 'last_downtime_data')), - 'slcd.object_id = ss.service_object_id', - array() - ); - } - - /** - * Join last service flapping comment - */ - protected function joinLastservicecommentflapping() - { - $this->select->joinLeft( - array('slcf' => $this->getLastCommentSubQuery(3, 'last_flapping_data')), - 'slcf.object_id = ss.service_object_id', - array() - ); - } - - /** - * Join last service acknowledgement comment - */ - protected function joinLastservicecommentack() - { - $this->select->joinLeft( - array('slca' => $this->getLastCommentSubQuery(4, 'last_ack_data')), - 'slca.object_id = ss.service_object_id', - array() - ); - } } diff --git a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php index 4fb049c93..c9f98ec43 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php @@ -51,10 +51,6 @@ class HostStatus extends DataView 'host_current_notification_number', 'host_percent_state_change', 'host_is_flapping', - 'host_last_comment', - 'host_last_downtime', - 'host_last_ack', - 'host_last_flapping', 'host_action_url', 'host_notes_url', 'host_percent_state_change', diff --git a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php index a4516a93a..00997bced 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php @@ -49,10 +49,6 @@ class ServiceStatus extends DataView 'service_notifications_enabled_changed', 'service_action_url', 'service_notes_url', - 'service_last_comment', - 'service_last_downtime', - 'service_last_flapping', - 'service_last_ack', 'service_last_check', 'service_next_check', 'service_attempt', @@ -69,7 +65,6 @@ class ServiceStatus extends DataView 'host_unhandled_service_count', 'host_action_url', 'host_notes_url', - 'host_last_comment', 'host_display_name', 'host_alias', 'host_ipv4',