diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 0b4066e7b..f5afc9a24 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -104,6 +104,7 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('hostStatus', array_merge(array( 'host_icon_image', 'host_name', + 'host_display_name', 'host_state' => $stateColumn, 'host_address', 'host_acknowledged', @@ -131,11 +132,11 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->setupSortControl(array( - 'host_last_check' => $this->translate('Last Check'), 'host_severity' => $this->translate('Severity'), - 'host_name' => $this->translate('Hostname'), + 'host_state' => $this->translate('Current State'), + 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Address'), - 'host_state' => $this->translate('Current State') + 'host_last_check' => $this->translate('Last Check') )); $this->view->hosts = $query->paginate(); @@ -181,6 +182,7 @@ class Monitoring_ListController extends Controller $columns = array_merge(array( 'host_name', + 'host_display_name', 'host_state', 'host_state_type', 'host_last_state_change', @@ -217,14 +219,13 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->setupSortControl(array( - 'service_last_check' => $this->translate('Last Service Check'), - 'service_severity' => $this->translate('Severity'), + 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), - 'service_description' => $this->translate('Service Name'), - 'service_state_type' => $this->translate('Hard State'), + 'service_display_name' => $this->translate('Service Name'), + 'service_last_check' => $this->translate('Last Service Check'), 'host_severity' => $this->translate('Host Severity'), 'host_state' => $this->translate('Current Host State'), - 'host_name' => $this->translate('Hostname'), + 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') )); @@ -284,22 +285,24 @@ class Monitoring_ListController extends Controller 'host' => 'downtime_host', 'service' => 'downtime_service', 'host_state' => 'downtime_host_state', - 'service_state' => 'downtime_service_state' - ))->order('downtime_is_in_effect', 'DESC') - ->order('downtime_scheduled_start', 'DESC'); + 'service_state' => 'downtime_service_state', + 'host_display_name', + 'service_display_name' + )); $this->filterQuery($query); $this->setupSortControl(array( - 'downtime_is_in_effect' => $this->translate('Is In Effect'), - 'downtime_host' => $this->translate('Host / Service'), - 'downtime_entry_time' => $this->translate('Entry Time'), - 'downtime_author' => $this->translate('Author'), - 'downtime_start' => $this->translate('Start Time'), - 'downtime_start' => $this->translate('End Time'), - 'downtime_scheduled_start' => $this->translate('Scheduled Start'), - 'downtime_scheduled_end' => $this->translate('Scheduled End'), - 'downtime_duration' => $this->translate('Duration'), + 'downtime_is_in_effect' => $this->translate('Is In Effect'), + 'host_display_name' => $this->translate('Host'), + 'service_display_name' => $this->translate('Service'), + 'downtime_entry_time' => $this->translate('Entry Time'), + 'downtime_author' => $this->translate('Author'), + 'downtime_start' => $this->translate('Start Time'), + 'downtime_end' => $this->translate('End Time'), + 'downtime_scheduled_start' => $this->translate('Scheduled Start'), + 'downtime_scheduled_end' => $this->translate('Scheduled End'), + 'downtime_duration' => $this->translate('Duration') )); $this->view->downtimes = $query->paginate(); @@ -322,7 +325,9 @@ class Monitoring_ListController extends Controller 'notification_output', 'notification_contact', 'notification_start_time', - 'notification_state' + 'notification_state', + 'host_display_name', + 'service_display_name' )); $this->filterQuery($query); $this->view->notifications = $query->paginate(); @@ -460,17 +465,20 @@ class Monitoring_ListController extends Controller 'persistent' => 'comment_is_persistent', 'expiration' => 'comment_expiration', 'host' => 'comment_host', - 'service' => 'comment_service' + 'service' => 'comment_service', + 'host_display_name', + 'service_display_name' )); $this->filterQuery($query); $this->view->comments = $query->paginate(); $this->setupSortControl( array( - 'comment_timestamp' => $this->translate('Comment Timestamp'), - 'comment_host' => $this->translate('Host / Service'), - 'comment_type' => $this->translate('Comment Type'), - 'comment_expiration' => $this->translate('Expiration'), + 'comment_timestamp' => $this->translate('Comment Timestamp'), + 'host_display_name' => $this->translate('Host'), + 'service_display_name' => $this->translate('Service'), + 'comment_type' => $this->translate('Comment Type'), + 'comment_expiration' => $this->translate('Expiration') ) ); $this->view->delCommentForm = new DeleteCommentCommandForm(); @@ -579,7 +587,9 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('eventHistory', array( 'host_name', + 'host_display_name', 'service_description', + 'service_display_name', 'object_type', 'timestamp', 'state', diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index ba865deaa..0b7a2f897 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -165,8 +165,10 @@ class Monitoring_ShowController extends Controller 'notification_output', 'notification_contact', 'notification_start_time', - 'notification_state' - ))->order('notification_start_time'); + 'notification_state', + 'host_display_name', + 'service_display_name' + )); $notifications->where('contact_object_id', $contact->contact_object_id); diff --git a/modules/monitoring/application/views/helpers/Link.php b/modules/monitoring/application/views/helpers/Link.php new file mode 100644 index 000000000..0d8c35861 --- /dev/null +++ b/modules/monitoring/application/views/helpers/Link.php @@ -0,0 +1,59 @@ +view->qlink( + $linkText, + $this->view->href('monitoring/host/show', array('host' => $host)) + ); + } + + /** + * Create a service link + * + * @param string $service Service name + * @param string $serviceLinkText Text for the service link, e.g. the service's display name + * @param string $host Hostname + * @param string $hostLinkText Text for the host link, e.g. the host's display name + * + * @return string + */ + public function service($service, $serviceLinkText, $host, $hostLinkText) + { + return sprintf( + $this->view->translate('%s on %s', 'Service running on host'), + $this->view->qlink( + $serviceLinkText, + $this->view->href('monitoring/service/show', array('host' => $host, 'service' => $service)) + ), + $this->host($host, $hostLinkText) + ); + } +} diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 677010f1b..29fc76d49 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -50,21 +50,13 @@ objecttype === 'service'): ?> - icon('conf'); ?> - service; ?> - - - translate('on') . ' ' . $comment->host; ?> - + icon('service') ?> + link()->service( + $comment->service, $comment->service_display_name, $comment->host, $comment->host_display_name + ) ?> - icon('host'); ?> - host; ?> - + icon('host') ?> + link()->host($comment->host, $comment->host_display_name) ?>
icon('comment'); ?> author) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 8a8e5576c..485782e3c 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -31,8 +31,10 @@ use Icinga\Module\Monitoring\Object\Service; service)) { + $isService = true; $stateName = Service::getStateText($downtime->service_state); } else { + $isService = false; $stateName = Host::getStateText($downtime->host_state); } ?> @@ -52,25 +54,17 @@ use Icinga\Module\Monitoring\Object\Service; ?> - service)): ?> - icon('service'); ?> - service; ?> - - - translate('on'); ?> host; ?> - + + icon('service') ?> + link()->service( + $downtime->service, $downtime->service_display_name, $downtime->host, $downtime->host_display_name + ) ?> - icon('host'); ?> - host; ?> - + icon('host') ?> + link()->host($downtime->host, $downtime->host_display_name) ?>
- icon('comment'); ?> [author; ?>] comment; ?> + icon('comment') ?> [escape($downtime->author) ?>] escape($downtime->comment) ?>
is_flexible): ?> diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index a9516aab1..2970675e2 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -106,25 +106,15 @@ use Icinga\Module\Monitoring\Object\Service; - - service; ?> - - - translate('on') . ' ' . $event->host; ?> - + link()->service( + $event->service, $event->service_display_name, $event->host, $event->host_display_name + ) ?> - - host; ?> - + link()->host($event->host, $event->host_display_name) ?>
- icon($icon, $title); ?> + icon($icon, $title); ?> escape($msg) ?>
diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 920a77e01..4afc14731 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -98,7 +98,7 @@ if ($hosts->count() === 0) { icon($this->resolveMacros($host->host_icon_image, $host)) ?> - host_name ?> + escape($host->host_display_name) ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> "> dateTimeRenderer($notification->notification_start_time)->render( @@ -49,15 +42,19 @@ use Icinga\Module\Monitoring\Object\Service; - translate('%s on %s'), - $this->qlink($notification->service, $href), $notification->host + icon('service') ?> + link()->service( + $notification->service, + $notification->service_display_name, + $notification->host, + $notification->host_display_name ) ?> - qlink($notification->host, $href) ?> + icon('host') ?> + link()->host($notification->host, $notification->host_display_name) ?>
- escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> + escape($this->ellipsis($notification->notification_output, 10000)) ?>
contact): ?> diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 0b63c7887..962d22bda 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -107,7 +107,7 @@ foreach ($services as $service): service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> icon($this->resolveMacros($service->service_icon_image, $service)) ?> -service_display_name ?>showHost): ?> on host_name; ?> +escape($service->service_display_name) ?>showHost): ?> on escape($service->host_display_name) ?> host_state != 0): ?> (host_state, true)); ?>) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index ccf7d2d5e..7f58790f4 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -3,37 +3,44 @@ use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; -$showService = $object->getType() === $object::TYPE_SERVICE; +$isService = $object->getType() === $object::TYPE_SERVICE; ?> -compact): ?> + +compact): ?> + - - + + + + + + + - - - - - - -
> - host_state, true)); ?>
- prefixedTimeSince($object->host_last_state_change, true) ?> -
escape($object->host_name) ?>host_address && $object->host_address !== $object->host_name): ?> -
escape($object->host_address) ?> - -
> + host_state, true)); ?>
+ prefixedTimeSince($object->host_last_state_change, true) ?> +
+ escape($object->host_display_name) ?> + host_display_name !== $object->host_name): ?> + (escape($object->host_name) ?>) + + host_address && $object->host_address !== $object->host_name): ?> +
+ escape($object->host_address) ?> + +
+ service_state, true)); ?>
+ prefixedTimeSince($object->service_last_state_change, true) ?> +
+ translate('Service') ?>: escape($object->service_display_name) ?> + service_display_name !== $object->service_description): ?> + (escape($object->service_description) ?>) + + render('show/components/statusIcons.phtml') ?> +
- service_state, true)); ?>
- prefixedTimeSince($object->service_last_state_change, true) ?> -
translate('Service') ?>: escape($object->service_description) ?> - - render('show/components/statusIcons.phtml') ?> - -
 
diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 5b922d4a0..a0cc4944e 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -136,19 +136,24 @@ $output = $this->tickets ? preg_replace_callback( ?> - qlink( - $this->escape($event->service_description), - 'monitoring/show/service', - array( - 'host' => $event->host_name, - 'service' => $event->service_description) - ) : $this->escape($event->service_description); ?> translate('on') . ' ' . $this->escape($event->host_name); ?> + translate('%s on %s', 'Service running on host'), + $hostContext ? $this->qlink( + $this->escape($event->service_display_name), + 'monitoring/show/service', + array( + 'host' => $event->host_name, + 'service' => $event->service_description + ) + ) : $this->escape($event->service_display_name), + $event->host_display_name + ) ?> escape($event->host_name); ?>
- icon($icon, $title); ?> + icon($icon, $title); ?> escape($msg) ?>
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php index 5145a96ad..a522d702e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php @@ -23,6 +23,12 @@ class CommentQuery extends IdoQuery 'comment_service' => 'so.name2 COLLATE latin1_general_ci', 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 'comment_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", + ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' ) ); @@ -44,4 +50,29 @@ class CommentQuery extends IdoQuery ); $this->joinedVirtualTables = array('comments' => true); } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = ho.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = so.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index a53fd18e9..efc10f6a5 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -1,47 +1,41 @@ array( - 'downtime_author' => 'sd.author_name', - 'author' => 'sd.author_name', - 'downtime_comment' => 'sd.comment_data', - 'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)', - 'downtime_is_fixed' => 'sd.is_fixed', - 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', - 'downtime_triggered_by_id' => 'sd.triggered_by_id', - 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', - 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', - 'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)", - 'downtime_end' => 'CASE WHEN sd.is_fixed > 0 THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration END', - 'downtime_duration' => 'sd.duration', - 'downtime_is_in_effect' => 'sd.is_in_effect', - 'downtime_internal_id' => 'sd.internal_downtime_id', - 'downtime_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', // #7278, #7279 - 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', - 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', - 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 - 'downtime_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", - 'downtime_host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', - 'downtime_service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END' + 'downtime_author' => 'sd.author_name', + 'author' => 'sd.author_name', + 'downtime_comment' => 'sd.comment_data', + 'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)', + 'downtime_is_fixed' => 'sd.is_fixed', + 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', + 'downtime_triggered_by_id' => 'sd.triggered_by_id', + 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', + 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', + 'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)", + 'downtime_end' => 'CASE WHEN sd.is_fixed > 0 THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration END', + 'downtime_duration' => 'sd.duration', + 'downtime_is_in_effect' => 'sd.is_in_effect', + 'downtime_internal_id' => 'sd.internal_downtime_id', + 'downtime_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', // #7278, #7279 + 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', + 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', + 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 + 'downtime_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", + 'downtime_host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', + 'downtime_service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END' ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' + ) ); - /** - * Join with scheduleddowntime - */ protected function joinBaseTables() { $this->select->from( @@ -70,4 +64,29 @@ class DowntimeQuery extends IdoQuery ); $this->joinedVirtualTables = array('downtime' => true); } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = ho.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = so.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index 2d5a0a2d8..2896f9536 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -1,11 +1,9 @@ array( - 'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)", - 'cnt_hard_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", - 'cnt_soft_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", - 'cnt_downtime_start' => "SUM(CASE eh.type WHEN 'dt_start' THEN 1 ELSE 0 END)", - 'cnt_downtime_end' => "SUM(CASE eh.type WHEN 'dt_end' THEN 1 ELSE 0 END)", - 'host' => 'eho.name1 COLLATE latin1_general_ci', - 'service' => 'eho.name2 COLLATE latin1_general_ci', - 'host_name' => 'eho.name1 COLLATE latin1_general_ci', - 'service_description' => 'eho.name2 COLLATE latin1_general_ci', - 'object_type' => 'eh.object_type', - 'timestamp' => 'eh.timestamp', - 'state' => 'eh.state', - 'attempt' => 'eh.attempt', - 'max_attempts' => 'eh.max_attempts', - 'output' => 'eh.output', // we do not want long_output - 'type' => 'eh.type', - 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci', - 'service_description' => 'eho.name2 COLLATE latin1_general_ci' + 'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)", + 'cnt_hard_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", + 'cnt_soft_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", + 'cnt_downtime_start' => "SUM(CASE eh.type WHEN 'dt_start' THEN 1 ELSE 0 END)", + 'cnt_downtime_end' => "SUM(CASE eh.type WHEN 'dt_end' THEN 1 ELSE 0 END)", + 'host' => 'eho.name1 COLLATE latin1_general_ci', + 'service' => 'eho.name2 COLLATE latin1_general_ci', + 'host_name' => 'eho.name1 COLLATE latin1_general_ci', + 'service_description' => 'eho.name2 COLLATE latin1_general_ci', + 'object_type' => 'eh.object_type', + 'timestamp' => 'eh.timestamp', + 'state' => 'eh.state', + 'attempt' => 'eh.attempt', + 'max_attempts' => 'eh.max_attempts', + 'output' => 'eh.output', // we do not want long_output + 'type' => 'eh.type', + 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci' ), 'hostgroups' => array( - 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', + 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' + ) ); protected $useSubqueryCount = true; @@ -84,20 +87,20 @@ class EventHistoryQuery extends IdoQuery public function addFilter(Filter $filter) { - foreach ($this->subQueries as $sub) { - $sub->applyFilter(clone $filter); - } - return $this; + foreach ($this->subQueries as $sub) { + $sub->applyFilter(clone $filter); + } + return $this; } - public function where($condition, $value = null) - { - $this->requireColumn($condition); - foreach ($this->subQueries as $sub) { - $sub->where($condition, $value); - } - return $this; - } + public function where($condition, $value = null) + { + $this->requireColumn($condition); + foreach ($this->subQueries as $sub) { + $sub->where($condition, $value); + } + return $this; + } protected function joinHostgroups() { @@ -117,4 +120,28 @@ class EventHistoryQuery extends IdoQuery return $this; } + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = eho.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = eho.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php index 00b6957b8..3181eebbf 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php @@ -1,41 +1,37 @@ array( - 'notification_output' => 'n.output', - 'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)', - 'notification_state' => 'n.state', - 'notification_object_id' => 'n.object_id' + 'notification_output' => 'n.output', + 'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)', + 'notification_state' => 'n.state', + 'notification_object_id' => 'n.object_id' ), 'objects' => array( - 'host' => 'o.name1', - 'service' => 'o.name2' + 'host' => 'o.name1', + 'service' => 'o.name2' ), 'contact' => array( - 'notification_contact' => 'c_o.name1', - 'contact_object_id' => 'c_o.object_id' + 'notification_contact' => 'c_o.name1', + 'contact_object_id' => 'c_o.object_id' ), 'command' => array( - 'notification_command' => 'cmd_o.name1' + 'notification_command' => 'cmd_o.name1' ), 'acknowledgement' => array( 'acknowledgement_entry_time' => 'UNIX_TIMESTAMP(a.entry_time)', 'acknowledgement_author_name' => 'a.author_name', 'acknowledgement_comment_data' => 'a.comment_data' + ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' ) ); @@ -110,4 +106,29 @@ class NotificationQuery extends IdoQuery array() ); } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = o.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = o.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php index e979cdc08..dfa81b1ef 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php @@ -1,6 +1,4 @@ 0, - 'hard_state' => 1, + 'hard_state' => 1 ); protected $columnMap = array( 'statehistory' => array( - 'raw_timestamp' => 'sh.state_time', - 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', - 'state_time' => 'sh.state_time', - 'object_id' => 'sho.object_id', - 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)", - 'state' => 'sh.state', - 'state_type' => 'sh.state_type', - 'output' => 'sh.output', - 'attempt' => 'sh.current_check_attempt', - 'max_attempts' => 'sh.max_check_attempts', - - 'host' => 'sho.name1 COLLATE latin1_general_ci', - 'service' => 'sho.name2 COLLATE latin1_general_ci', - 'host_name' => 'sho.name1 COLLATE latin1_general_ci', - 'service_description' => 'sho.name2 COLLATE latin1_general_ci', - 'service_host_name' => 'sho.name1 COLLATE latin1_general_ci', - 'service_description' => 'sho.name2 COLLATE latin1_general_ci', - 'object_type' => "CASE WHEN sho.objecttype_id = 1 THEN 'host' ELSE 'service' END" + 'raw_timestamp' => 'sh.state_time', + 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', + 'state_time' => 'sh.state_time', + 'object_id' => 'sho.object_id', + 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)", + 'state' => 'sh.state', + 'state_type' => 'sh.state_type', + 'output' => 'sh.output', + 'attempt' => 'sh.current_check_attempt', + 'max_attempts' => 'sh.max_check_attempts', + 'host' => 'sho.name1 COLLATE latin1_general_ci', + 'host_name' => 'sho.name1 COLLATE latin1_general_ci', + 'service' => 'sho.name2 COLLATE latin1_general_ci', + 'service_description' => 'sho.name2 COLLATE latin1_general_ci', + 'service_host_name' => 'sho.name1 COLLATE latin1_general_ci', + 'object_type' => "CASE WHEN sho.objecttype_id = 1 THEN 'host' ELSE 'service' END" ) ); diff --git a/modules/monitoring/library/Monitoring/DataView/Comment.php b/modules/monitoring/library/Monitoring/DataView/Comment.php index 4d62fd27c..4cd11e1a1 100644 --- a/modules/monitoring/library/Monitoring/DataView/Comment.php +++ b/modules/monitoring/library/Monitoring/DataView/Comment.php @@ -29,6 +29,8 @@ class Comment extends DataView 'comment_service', 'host', 'service', + 'host_display_name', + 'service_display_name' ); } @@ -43,13 +45,20 @@ class Comment extends DataView 'comment_timestamp' => array( 'order' => self::SORT_DESC ), - 'comment_host' => array( + 'host_display_name' => array( 'columns' => array( - 'comment_host', - 'comment_service' + 'host_display_name', + 'service_display_name' ), 'order' => self::SORT_ASC ), + 'service_display_name' => array( + 'columns' => array( + 'service_display_name', + 'host_display_name' + ), + 'order' => self::SORT_ASC + ) ); } } diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index e075d658c..681608b17 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -32,7 +32,9 @@ class Downtime extends DataView 'downtime_host', 'downtime_service', 'downtime_host_state', - 'downtime_service_state' + 'downtime_service_state', + 'host_display_name', + 'service_display_name' ); } @@ -40,18 +42,29 @@ class Downtime extends DataView { return array( 'downtime_is_in_effect' => array( + 'columns' => array( + 'downtime_is_in_effect', + 'downtime_scheduled_start' + ), 'order' => self::SORT_DESC ), 'downtime_start' => array( 'order' => self::SORT_DESC ), - 'downtime_host' => array( + 'host_display_name' => array( 'columns' => array( - 'downtime_host', - 'downtime_service' + 'host_display_name', + 'service_display_name' ), 'order' => self::SORT_ASC ), + 'service_display_name' => array( + 'columns' => array( + 'service_display_name', + 'host_display_name' + ), + 'order' => self::SORT_ASC + ) ); } } diff --git a/modules/monitoring/library/Monitoring/DataView/EventHistory.php b/modules/monitoring/library/Monitoring/DataView/EventHistory.php index 09779b27d..f13815aae 100644 --- a/modules/monitoring/library/Monitoring/DataView/EventHistory.php +++ b/modules/monitoring/library/Monitoring/DataView/EventHistory.php @@ -1,6 +1,4 @@ array( - 'columns' => array('timestamp'), - 'order' => 'DESC' + 'columns' => array('timestamp'), + 'order' => 'DESC' ) ); } diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index e9b5b60dd..86bff52bf 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -24,6 +24,7 @@ class HostStatus extends DataView return array( 'host', 'host_name', + 'host_display_name', 'host_alias', 'host_address', 'host_state', @@ -90,7 +91,7 @@ class HostStatus extends DataView public function getSortRules() { return array( - 'host_name' => array( + 'host_display_name' => array( 'order' => self::SORT_ASC ), 'host_address' => array( diff --git a/modules/monitoring/library/Monitoring/DataView/Notification.php b/modules/monitoring/library/Monitoring/DataView/Notification.php index 6156a5f15..7f6fd238f 100644 --- a/modules/monitoring/library/Monitoring/DataView/Notification.php +++ b/modules/monitoring/library/Monitoring/DataView/Notification.php @@ -20,7 +20,9 @@ class Notification extends DataView 'notification_start_time', 'notification_contact', 'notification_output', - 'notification_command' + 'notification_command', + 'host_display_name', + 'service_display_name' ); } diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index e90caef9e..e7e2accb2 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -25,6 +25,7 @@ class ServiceStatus extends DataView { return array( 'host_name', + 'host_display_name', 'host_state', 'host_state_type', 'host_last_state_change', @@ -123,19 +124,12 @@ class ServiceStatus extends DataView public function getSortRules() { return array( - 'host_name' => array( + 'service_severity' => array( 'columns' => array( - 'service_host_name', - 'service_description' + 'service_severity', + 'service_last_state_change' ), - 'order' => self::SORT_ASC - ), - 'host_address' => array( - 'columns' => array( - 'host_ipv4', - 'service_description' - ), - 'order' => self::SORT_ASC + 'order' => self::SORT_DESC ), 'host_severity' => array( 'columns' => array( @@ -144,12 +138,19 @@ class ServiceStatus extends DataView ), 'order' => self::SORT_ASC ), - 'service_severity' => array( + 'host_display_name' => array( 'columns' => array( - 'service_severity', - 'service_last_state_change', + 'host_display_name', + 'service_display_name' ), - 'order' => self::SORT_DESC + 'order' => self::SORT_ASC + ), + 'host_address' => array( + 'columns' => array( + 'host_ipv4', + 'service_display_name' + ), + 'order' => self::SORT_ASC ) ); } diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 79a760d82..eeac94cb9 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -91,6 +91,7 @@ class Host extends MonitoredObject { $columns = array( 'host_name', + 'host_display_name', 'host_alias', 'host_address', 'host_state', diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 2d9f1f30c..8d3246aab 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -408,7 +408,9 @@ abstract class MonitoredObject $eventHistory = $this->backend->select()->from('eventHistory', array( 'object_type', 'host_name', + 'host_display_name', 'service_description', + 'service_display_name', 'timestamp', 'state', 'attempt', diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 64bfe530b..3b7bff4fa 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -108,6 +108,7 @@ class Service extends MonitoredObject { return $this->backend->select()->from('serviceStatus', array( 'host_name', + 'host_display_name', 'host_state', 'host_state_type', 'host_last_state_change',