Merge branch 'bugfix/prefer-display_name-over-name1-name2-7843'

fixes #7843
This commit is contained in:
Eric Lippmann 2015-01-22 11:05:35 +01:00
commit 21c0091cdc
25 changed files with 438 additions and 258 deletions

View File

@ -104,6 +104,7 @@ class Monitoring_ListController extends Controller
$query = $this->backend->select()->from('hostStatus', array_merge(array( $query = $this->backend->select()->from('hostStatus', array_merge(array(
'host_icon_image', 'host_icon_image',
'host_name', 'host_name',
'host_display_name',
'host_state' => $stateColumn, 'host_state' => $stateColumn,
'host_address', 'host_address',
'host_acknowledged', 'host_acknowledged',
@ -131,11 +132,11 @@ class Monitoring_ListController extends Controller
$this->filterQuery($query); $this->filterQuery($query);
$this->setupSortControl(array( $this->setupSortControl(array(
'host_last_check' => $this->translate('Last Check'),
'host_severity' => $this->translate('Severity'), '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_address' => $this->translate('Address'),
'host_state' => $this->translate('Current State') 'host_last_check' => $this->translate('Last Check')
)); ));
$this->view->hosts = $query->paginate(); $this->view->hosts = $query->paginate();
@ -181,6 +182,7 @@ class Monitoring_ListController extends Controller
$columns = array_merge(array( $columns = array_merge(array(
'host_name', 'host_name',
'host_display_name',
'host_state', 'host_state',
'host_state_type', 'host_state_type',
'host_last_state_change', 'host_last_state_change',
@ -217,14 +219,13 @@ class Monitoring_ListController extends Controller
$this->filterQuery($query); $this->filterQuery($query);
$this->setupSortControl(array( $this->setupSortControl(array(
'service_last_check' => $this->translate('Last Service Check'), 'service_severity' => $this->translate('Service Severity'),
'service_severity' => $this->translate('Severity'),
'service_state' => $this->translate('Current Service State'), 'service_state' => $this->translate('Current Service State'),
'service_description' => $this->translate('Service Name'), 'service_display_name' => $this->translate('Service Name'),
'service_state_type' => $this->translate('Hard State'), 'service_last_check' => $this->translate('Last Service Check'),
'host_severity' => $this->translate('Host Severity'), 'host_severity' => $this->translate('Host Severity'),
'host_state' => $this->translate('Current Host State'), '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_address' => $this->translate('Host Address'),
'host_last_check' => $this->translate('Last Host Check') 'host_last_check' => $this->translate('Last Host Check')
)); ));
@ -284,22 +285,24 @@ class Monitoring_ListController extends Controller
'host' => 'downtime_host', 'host' => 'downtime_host',
'service' => 'downtime_service', 'service' => 'downtime_service',
'host_state' => 'downtime_host_state', 'host_state' => 'downtime_host_state',
'service_state' => 'downtime_service_state' 'service_state' => 'downtime_service_state',
))->order('downtime_is_in_effect', 'DESC') 'host_display_name',
->order('downtime_scheduled_start', 'DESC'); 'service_display_name'
));
$this->filterQuery($query); $this->filterQuery($query);
$this->setupSortControl(array( $this->setupSortControl(array(
'downtime_is_in_effect' => $this->translate('Is In Effect'), 'downtime_is_in_effect' => $this->translate('Is In Effect'),
'downtime_host' => $this->translate('Host / Service'), 'host_display_name' => $this->translate('Host'),
'downtime_entry_time' => $this->translate('Entry Time'), 'service_display_name' => $this->translate('Service'),
'downtime_author' => $this->translate('Author'), 'downtime_entry_time' => $this->translate('Entry Time'),
'downtime_start' => $this->translate('Start Time'), 'downtime_author' => $this->translate('Author'),
'downtime_start' => $this->translate('End Time'), 'downtime_start' => $this->translate('Start Time'),
'downtime_scheduled_start' => $this->translate('Scheduled Start'), 'downtime_end' => $this->translate('End Time'),
'downtime_scheduled_end' => $this->translate('Scheduled End'), 'downtime_scheduled_start' => $this->translate('Scheduled Start'),
'downtime_duration' => $this->translate('Duration'), 'downtime_scheduled_end' => $this->translate('Scheduled End'),
'downtime_duration' => $this->translate('Duration')
)); ));
$this->view->downtimes = $query->paginate(); $this->view->downtimes = $query->paginate();
@ -322,7 +325,9 @@ class Monitoring_ListController extends Controller
'notification_output', 'notification_output',
'notification_contact', 'notification_contact',
'notification_start_time', 'notification_start_time',
'notification_state' 'notification_state',
'host_display_name',
'service_display_name'
)); ));
$this->filterQuery($query); $this->filterQuery($query);
$this->view->notifications = $query->paginate(); $this->view->notifications = $query->paginate();
@ -460,17 +465,20 @@ class Monitoring_ListController extends Controller
'persistent' => 'comment_is_persistent', 'persistent' => 'comment_is_persistent',
'expiration' => 'comment_expiration', 'expiration' => 'comment_expiration',
'host' => 'comment_host', 'host' => 'comment_host',
'service' => 'comment_service' 'service' => 'comment_service',
'host_display_name',
'service_display_name'
)); ));
$this->filterQuery($query); $this->filterQuery($query);
$this->view->comments = $query->paginate(); $this->view->comments = $query->paginate();
$this->setupSortControl( $this->setupSortControl(
array( array(
'comment_timestamp' => $this->translate('Comment Timestamp'), 'comment_timestamp' => $this->translate('Comment Timestamp'),
'comment_host' => $this->translate('Host / Service'), 'host_display_name' => $this->translate('Host'),
'comment_type' => $this->translate('Comment Type'), 'service_display_name' => $this->translate('Service'),
'comment_expiration' => $this->translate('Expiration'), 'comment_type' => $this->translate('Comment Type'),
'comment_expiration' => $this->translate('Expiration')
) )
); );
$this->view->delCommentForm = new DeleteCommentCommandForm(); $this->view->delCommentForm = new DeleteCommentCommandForm();
@ -579,7 +587,9 @@ class Monitoring_ListController extends Controller
$query = $this->backend->select()->from('eventHistory', array( $query = $this->backend->select()->from('eventHistory', array(
'host_name', 'host_name',
'host_display_name',
'service_description', 'service_description',
'service_display_name',
'object_type', 'object_type',
'timestamp', 'timestamp',
'state', 'state',

View File

@ -165,8 +165,10 @@ class Monitoring_ShowController extends Controller
'notification_output', 'notification_output',
'notification_contact', 'notification_contact',
'notification_start_time', 'notification_start_time',
'notification_state' 'notification_state',
))->order('notification_start_time'); 'host_display_name',
'service_display_name'
));
$notifications->where('contact_object_id', $contact->contact_object_id); $notifications->where('contact_object_id', $contact->contact_object_id);

View File

@ -0,0 +1,59 @@
<?php
/**
* Helper for generating frequently used jump links
*
* Most of the monitoring overviews link to detail information, e.g. the full information of the involved monitored
* object. Instead of reintroducing link generation and translation in those views, this helper contains most
* frequently used jump links.
*/
class Zend_View_Helper_Link extends Zend_View_Helper_Abstract
{
/**
* Helper entry point
*
* @return $this
*/
public function link()
{
return $this;
}
/**
* Create a host link
*
* @param string $host Hostname
* @param string $linkText Link text, e.g. the host's display name
*
* @return string
*/
public function host($host, $linkText)
{
return $this->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)
);
}
}

View File

@ -50,21 +50,13 @@
</td> </td>
<td> <td>
<?php if ($comment->objecttype === 'service'): ?> <?php if ($comment->objecttype === 'service'): ?>
<?= $this->icon('conf'); ?> <a href="<?= $this->href('monitoring/service/show', array( <?= $this->icon('service') ?>
'host' => $comment->host, <?= $this->link()->service(
'service' => $comment->service, $comment->service, $comment->service_display_name, $comment->host, $comment->host_display_name
)); ?>"> ) ?>
<?= $comment->service; ?>
</a>
<small>
<?= $this->translate('on') . ' ' . $comment->host; ?>
</small>
<?php else: ?> <?php else: ?>
<?= $this->icon('host'); ?> <a href="<?= $this->href('monitoring/host/show', array( <?= $this->icon('host') ?>
'host' => $comment->host <?= $this->link()->host($comment->host, $comment->host_display_name) ?>
)); ?>">
<?= $comment->host; ?>
</a>
<?php endif ?> <?php endif ?>
<br> <br>
<?= $this->icon('comment'); ?> <?= isset($comment->author) <?= $this->icon('comment'); ?> <?= isset($comment->author)

View File

@ -31,8 +31,10 @@ use Icinga\Module\Monitoring\Object\Service;
<?php foreach ($downtimes as $downtime): ?> <?php foreach ($downtimes as $downtime): ?>
<?php <?php
if (isset($downtime->service)) { if (isset($downtime->service)) {
$isService = true;
$stateName = Service::getStateText($downtime->service_state); $stateName = Service::getStateText($downtime->service_state);
} else { } else {
$isService = false;
$stateName = Host::getStateText($downtime->host_state); $stateName = Host::getStateText($downtime->host_state);
} }
?> ?>
@ -52,25 +54,17 @@ use Icinga\Module\Monitoring\Object\Service;
?> ?>
</td> </td>
<td> <td>
<?php if (isset($downtime->service)): ?> <?php if ($isService): ?>
<?= $this->icon('service'); ?> <a href="<?= $this->href('monitoring/service/show', array( <?= $this->icon('service') ?>
'host' => $downtime->host, <?= $this->link()->service(
'service' => $downtime->service $downtime->service, $downtime->service_display_name, $downtime->host, $downtime->host_display_name
)); ?>"> ) ?>
<?= $downtime->service; ?>
</a>
<small>
<?= $this->translate('on'); ?> <?= $downtime->host; ?>
</small>
<?php else: ?> <?php else: ?>
<?= $this->icon('host'); ?> <a href="<?= $this->href('monitoring/host/show', array( <?= $this->icon('host') ?>
'host' => $downtime->host <?= $this->link()->host($downtime->host, $downtime->host_display_name) ?>
)); ?>">
<?= $downtime->host; ?>
</a>
<?php endif ?> <?php endif ?>
<br> <br>
<?= $this->icon('comment'); ?> [<?= $downtime->author; ?>] <?= $downtime->comment; ?> <?= $this->icon('comment') ?> [<?= $this->escape($downtime->author) ?>] <?= $this->escape($downtime->comment) ?>
<br> <br>
<small> <small>
<?php if ($downtime->is_flexible): ?> <?php if ($downtime->is_flexible): ?>

View File

@ -106,25 +106,15 @@ use Icinga\Module\Monitoring\Object\Service;
</td> </td>
<td> <td>
<?php if ($isService): ?> <?php if ($isService): ?>
<a href="<?= $this->href('monitoring/show/service', array( <?= $this->link()->service(
'host' => $event->host, $event->service, $event->service_display_name, $event->host, $event->host_display_name
'service' => $event->service ) ?>
)); ?>">
<?= $event->service; ?>
</a>
<small>
<?= $this->translate('on') . ' ' . $event->host; ?>
</small>
<?php else: ?> <?php else: ?>
<a href="<?= $this->href('monitoring/show/host', array( <?= $this->link()->host($event->host, $event->host_display_name) ?>
'host' => $event->host
)); ?>">
<?= $event->host; ?>
</a>
<?php endif ?> <?php endif ?>
<br> <br>
<div> <div>
<?= $this->icon($icon, $title); ?> <?= empty($msg) ? '' : $msg; ?> <?= $this->icon($icon, $title); ?> <?= empty($msg) ? '' : $this->escape($msg) ?>
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -98,7 +98,7 @@ if ($hosts->count() === 0) {
<?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?> <?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?>
<?php endif ?> <?php endif ?>
<?= implode(' ', $icons) ?> <?= implode(' ', $icons) ?>
<a href="<?= $hostLink ?>"><?= $host->host_name ?></a> <a href="<?= $hostLink ?>"><?= $this->escape($host->host_display_name) ?></a>
<?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?> <?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?>
<span title="<?= <span title="<?=
$host->host_unhandled_services $host->host_unhandled_services

View File

@ -25,20 +25,13 @@ use Icinga\Module\Monitoring\Object\Service;
<tbody> <tbody>
<?php foreach ($notifications as $notification): <?php foreach ($notifications as $notification):
if (isset($notification->service)) { if (isset($notification->service)) {
$isService = true; $isService = true;
$href = $this->href('monitoring/show/service', array( $stateName = Service::getStateText($notification->notification_state);
'host' => $notification->host,
'service' => $notification->service
));
$stateName = Service::getStateText($notification->notification_state);
} else { } else {
$isService = false; $isService = false;
$href = $this->href('monitoring/show/host', array(
'host' => $notification->host
));
$stateName = Host::getStateText($notification->notification_state); $stateName = Host::getStateText($notification->notification_state);
} }
?> ?>
<tr class="state <?= $stateName ?>"> <tr class="state <?= $stateName ?>">
<td class="state"> <td class="state">
<?= $this->dateTimeRenderer($notification->notification_start_time)->render( <?= $this->dateTimeRenderer($notification->notification_start_time)->render(
@ -49,15 +42,19 @@ use Icinga\Module\Monitoring\Object\Service;
</td> </td>
<td style="font-size: 0.8em"> <td style="font-size: 0.8em">
<?php if ($isService): ?> <?php if ($isService): ?>
<?= sprintf( <?= $this->icon('service') ?>
$this->translate('%s on %s'), <?= $this->link()->service(
$this->qlink($notification->service, $href), $notification->host $notification->service,
$notification->service_display_name,
$notification->host,
$notification->host_display_name
) ?> ) ?>
<?php else: ?> <?php else: ?>
<?= $this->qlink($notification->host, $href) ?> <?= $this->icon('host') ?>
<?= $this->link()->host($notification->host, $notification->host_display_name) ?>
<?php endif ?> <?php endif ?>
<br> <br>
<?= $this->escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> <?= $this->escape($this->ellipsis($notification->notification_output, 10000)) ?>
<br> <br>
<?php if (! $this->contact): ?> <?php if (! $this->contact): ?>
<small> <small>

View File

@ -107,7 +107,7 @@ foreach ($services as $service):
<?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> <?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?> <?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?php endif ?> <?php endif ?>
<a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a><?php if ($this->showHost): ?> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?> <a href="<?= $serviceLink ?>"><?= $this->escape($service->service_display_name) ?></a><?php if ($this->showHost): ?> on <a href="<?= $hostLink ?>"><?= $this->escape($service->host_display_name) ?>
<?php if ($service->host_state != 0): ?> <?php if ($service->host_state != 0): ?>
(<?= strtoupper(Host::getStateText($service->host_state, true)); ?>) (<?= strtoupper(Host::getStateText($service->host_state, true)); ?>)
<?php endif ?> <?php endif ?>

View File

@ -3,37 +3,44 @@
use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
$showService = $object->getType() === $object::TYPE_SERVICE; $isService = $object->getType() === $object::TYPE_SERVICE;
?> ?>
<?php if (!$this->compact): ?>
<?php if (! $this->compact): ?>
<?= $tabs ?> <?= $tabs ?>
<?php endif ?> <?php endif ?>
<table class="objectstate"> <table class="objectstate">
<tr class="state <?= Host::getStateText($object->host_state); ?><?= $object->host_handled ? ' handled' : '' ?>"> <tr class="state <?= Host::getStateText($object->host_state); ?><?= $object->host_handled ? ' handled' : '' ?>">
<td class="state"<?= $showService ? '' : ' rowspan="2"' ?>> <td class="state"<?= $isService ? '' : ' rowspan="2"' ?>>
<strong><?= strtoupper(Host::getStateText($object->host_state, true)); ?></strong><br /> <strong><?= strtoupper(Host::getStateText($object->host_state, true)); ?></strong><br>
<?= $this->prefixedTimeSince($object->host_last_state_change, true) ?> <?= $this->prefixedTimeSince($object->host_last_state_change, true) ?>
</td> </td>
<td><b><?= $this->escape($object->host_name) ?></b><?php <td>
if ($object->host_address && $object->host_address !== $object->host_name): ?> <b><?= $this->escape($object->host_display_name) ?></b>
<br><?= $this->escape($object->host_address) ?> <?php if ($object->host_display_name !== $object->host_name): ?>
<?php endif ?> <small>(<?= $this->escape($object->host_name) ?>)</small>
</td> <?php endif ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address) ?>
<?php endif ?>
</td>
</tr>
<?php if ($isService): ?>
<tr class="state <?= Service::getStateText($object->service_state); ?><?= $object->service_handled ? ' handled' : '' ?>">
<td class="state">
<strong><?= strtoupper(Service::getStateText($object->service_state, true)); ?></strong><br>
<?= $this->prefixedTimeSince($object->service_last_state_change, true) ?>
</td>
<td>
<b><?= $this->translate('Service') ?>: <?= $this->escape($object->service_display_name) ?></b>
<?php if ($object->service_display_name !== $object->service_description): ?>
<small>(<?= $this->escape($object->service_description) ?>)</small>
<?php endif ?>
<?= $this->render('show/components/statusIcons.phtml') ?>
</td>
</tr> </tr>
<?php if ($showService): ?>
<tr class="state <?= Service::getStateText($object->service_state); ?><?= $object->service_handled ? ' handled' : '' ?>">
<td class="state">
<strong><?= strtoupper(Service::getStateText($object->service_state, true)); ?></strong><br />
<?= $this->prefixedTimeSince($object->service_last_state_change, true) ?>
</td>
<td><b><?= $this->translate('Service') ?>: <?= $this->escape($object->service_description) ?></b>
<?= $this->render('show/components/statusIcons.phtml') ?>
</td>
</tr>
<?php else: ?>
<tr><td><!--<b>Host state</b>-->&nbsp;</td></tr>
<?php endif ?> <?php endif ?>
</table> </table>

View File

@ -136,19 +136,24 @@ $output = $this->tickets ? preg_replace_callback(
?> ?>
<?php if ($isService): ?> <?php if ($isService): ?>
<?= $hostContext ? $this->qlink( <?= sprintf(
$this->escape($event->service_description), $this->translate('%s on %s', 'Service running on host'),
'monitoring/show/service', $hostContext ? $this->qlink(
array( $this->escape($event->service_display_name),
'host' => $event->host_name, 'monitoring/show/service',
'service' => $event->service_description) array(
) : $this->escape($event->service_description); ?> <?= $this->translate('on') . ' ' . $this->escape($event->host_name); ?> 'host' => $event->host_name,
'service' => $event->service_description
)
) : $this->escape($event->service_display_name),
$event->host_display_name
) ?>
<?php else: ?> <?php else: ?>
<?= $this->escape($event->host_name); ?> <?= $this->escape($event->host_name); ?>
<?php endif ?> <?php endif ?>
<br> <br>
<div> <div>
<?= $this->icon($icon, $title); ?> <?= empty($msg) ? '' : $msg; ?> <?= $this->icon($icon, $title); ?> <?= empty($msg) ? '' : $this->escape($msg) ?>
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -23,6 +23,12 @@ class CommentQuery extends IdoQuery
'comment_service' => 'so.name2 COLLATE latin1_general_ci', 'comment_service' => 'so.name2 COLLATE latin1_general_ci',
'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 '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", '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); $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;
}
} }

View File

@ -1,47 +1,41 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query; namespace Icinga\Module\Monitoring\Backend\Ido\Query;
/**
* Handling downtime queries
*/
class DowntimeQuery extends IdoQuery class DowntimeQuery extends IdoQuery
{ {
/**
* Column map
* @var array
*/
protected $columnMap = array( protected $columnMap = array(
'downtime' => array( 'downtime' => array(
'downtime_author' => 'sd.author_name', 'downtime_author' => 'sd.author_name',
'author' => 'sd.author_name', 'author' => 'sd.author_name',
'downtime_comment' => 'sd.comment_data', 'downtime_comment' => 'sd.comment_data',
'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)', 'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)',
'downtime_is_fixed' => 'sd.is_fixed', 'downtime_is_fixed' => 'sd.is_fixed',
'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END',
'downtime_triggered_by_id' => 'sd.triggered_by_id', 'downtime_triggered_by_id' => 'sd.triggered_by_id',
'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)',
'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_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_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_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_duration' => 'sd.duration',
'downtime_is_in_effect' => 'sd.is_in_effect', 'downtime_is_in_effect' => 'sd.is_in_effect',
'downtime_internal_id' => 'sd.internal_downtime_id', '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 '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', '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', 'downtime_service' => 'so.name2 COLLATE latin1_general_ci',
'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 '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_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_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_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() protected function joinBaseTables()
{ {
$this->select->from( $this->select->from(
@ -70,4 +64,29 @@ class DowntimeQuery extends IdoQuery
); );
$this->joinedVirtualTables = array('downtime' => true); $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;
}
} }

View File

@ -1,11 +1,9 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query; namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use Icinga\Data\Filter\Filter;
use Zend_Db_Select; use Zend_Db_Select;
use Icinga\Data\Filter\Filter;
class EventHistoryQuery extends IdoQuery class EventHistoryQuery extends IdoQuery
{ {
@ -13,28 +11,33 @@ class EventHistoryQuery extends IdoQuery
protected $columnMap = array( protected $columnMap = array(
'eventhistory' => array( 'eventhistory' => array(
'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)", '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_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_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_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)", 'cnt_downtime_end' => "SUM(CASE eh.type WHEN 'dt_end' THEN 1 ELSE 0 END)",
'host' => 'eho.name1 COLLATE latin1_general_ci', 'host' => 'eho.name1 COLLATE latin1_general_ci',
'service' => 'eho.name2 COLLATE latin1_general_ci', 'service' => 'eho.name2 COLLATE latin1_general_ci',
'host_name' => 'eho.name1 COLLATE latin1_general_ci', 'host_name' => 'eho.name1 COLLATE latin1_general_ci',
'service_description' => 'eho.name2 COLLATE latin1_general_ci', 'service_description' => 'eho.name2 COLLATE latin1_general_ci',
'object_type' => 'eh.object_type', 'object_type' => 'eh.object_type',
'timestamp' => 'eh.timestamp', 'timestamp' => 'eh.timestamp',
'state' => 'eh.state', 'state' => 'eh.state',
'attempt' => 'eh.attempt', 'attempt' => 'eh.attempt',
'max_attempts' => 'eh.max_attempts', 'max_attempts' => 'eh.max_attempts',
'output' => 'eh.output', // we do not want long_output 'output' => 'eh.output', // we do not want long_output
'type' => 'eh.type', 'type' => 'eh.type',
'service_host_name' => 'eho.name1 COLLATE latin1_general_ci', 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci'
'service_description' => 'eho.name2 COLLATE latin1_general_ci'
), ),
'hostgroups' => array( '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; protected $useSubqueryCount = true;
@ -84,20 +87,20 @@ class EventHistoryQuery extends IdoQuery
public function addFilter(Filter $filter) public function addFilter(Filter $filter)
{ {
foreach ($this->subQueries as $sub) { foreach ($this->subQueries as $sub) {
$sub->applyFilter(clone $filter); $sub->applyFilter(clone $filter);
} }
return $this; return $this;
} }
public function where($condition, $value = null) public function where($condition, $value = null)
{ {
$this->requireColumn($condition); $this->requireColumn($condition);
foreach ($this->subQueries as $sub) { foreach ($this->subQueries as $sub) {
$sub->where($condition, $value); $sub->where($condition, $value);
} }
return $this; return $this;
} }
protected function joinHostgroups() protected function joinHostgroups()
{ {
@ -117,4 +120,28 @@ class EventHistoryQuery extends IdoQuery
return $this; 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;
}
} }

View File

@ -1,41 +1,37 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query; namespace Icinga\Module\Monitoring\Backend\Ido\Query;
/**
* Notification query
*/
class NotificationQuery extends IdoQuery class NotificationQuery extends IdoQuery
{ {
/**
* Column map
*
* @var array
*/
protected $columnMap = array( protected $columnMap = array(
'notification' => array( 'notification' => array(
'notification_output' => 'n.output', 'notification_output' => 'n.output',
'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)', 'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)',
'notification_state' => 'n.state', 'notification_state' => 'n.state',
'notification_object_id' => 'n.object_id' 'notification_object_id' => 'n.object_id'
), ),
'objects' => array( 'objects' => array(
'host' => 'o.name1', 'host' => 'o.name1',
'service' => 'o.name2' 'service' => 'o.name2'
), ),
'contact' => array( 'contact' => array(
'notification_contact' => 'c_o.name1', 'notification_contact' => 'c_o.name1',
'contact_object_id' => 'c_o.object_id' 'contact_object_id' => 'c_o.object_id'
), ),
'command' => array( 'command' => array(
'notification_command' => 'cmd_o.name1' 'notification_command' => 'cmd_o.name1'
), ),
'acknowledgement' => array( 'acknowledgement' => array(
'acknowledgement_entry_time' => 'UNIX_TIMESTAMP(a.entry_time)', 'acknowledgement_entry_time' => 'UNIX_TIMESTAMP(a.entry_time)',
'acknowledgement_author_name' => 'a.author_name', 'acknowledgement_author_name' => 'a.author_name',
'acknowledgement_comment_data' => 'a.comment_data' '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() 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;
}
} }

View File

@ -1,6 +1,4 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query; namespace Icinga\Module\Monitoring\Backend\Ido\Query;
@ -8,29 +6,27 @@ class StatehistoryQuery extends IdoQuery
{ {
protected $types = array( protected $types = array(
'soft_state' => 0, 'soft_state' => 0,
'hard_state' => 1, 'hard_state' => 1
); );
protected $columnMap = array( protected $columnMap = array(
'statehistory' => array( 'statehistory' => array(
'raw_timestamp' => 'sh.state_time', 'raw_timestamp' => 'sh.state_time',
'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)',
'state_time' => 'sh.state_time', 'state_time' => 'sh.state_time',
'object_id' => 'sho.object_id', 'object_id' => 'sho.object_id',
'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)",
'state' => 'sh.state', 'state' => 'sh.state',
'state_type' => 'sh.state_type', 'state_type' => 'sh.state_type',
'output' => 'sh.output', 'output' => 'sh.output',
'attempt' => 'sh.current_check_attempt', 'attempt' => 'sh.current_check_attempt',
'max_attempts' => 'sh.max_check_attempts', 'max_attempts' => 'sh.max_check_attempts',
'host' => 'sho.name1 COLLATE latin1_general_ci',
'host' => 'sho.name1 COLLATE latin1_general_ci', 'host_name' => 'sho.name1 COLLATE latin1_general_ci',
'service' => 'sho.name2 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_description' => 'sho.name2 COLLATE latin1_general_ci', 'service_host_name' => 'sho.name1 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"
'service_description' => 'sho.name2 COLLATE latin1_general_ci',
'object_type' => "CASE WHEN sho.objecttype_id = 1 THEN 'host' ELSE 'service' END"
) )
); );

View File

@ -29,6 +29,8 @@ class Comment extends DataView
'comment_service', 'comment_service',
'host', 'host',
'service', 'service',
'host_display_name',
'service_display_name'
); );
} }
@ -43,13 +45,20 @@ class Comment extends DataView
'comment_timestamp' => array( 'comment_timestamp' => array(
'order' => self::SORT_DESC 'order' => self::SORT_DESC
), ),
'comment_host' => array( 'host_display_name' => array(
'columns' => array( 'columns' => array(
'comment_host', 'host_display_name',
'comment_service' 'service_display_name'
), ),
'order' => self::SORT_ASC 'order' => self::SORT_ASC
), ),
'service_display_name' => array(
'columns' => array(
'service_display_name',
'host_display_name'
),
'order' => self::SORT_ASC
)
); );
} }
} }

View File

@ -32,7 +32,9 @@ class Downtime extends DataView
'downtime_host', 'downtime_host',
'downtime_service', 'downtime_service',
'downtime_host_state', '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( return array(
'downtime_is_in_effect' => array( 'downtime_is_in_effect' => array(
'columns' => array(
'downtime_is_in_effect',
'downtime_scheduled_start'
),
'order' => self::SORT_DESC 'order' => self::SORT_DESC
), ),
'downtime_start' => array( 'downtime_start' => array(
'order' => self::SORT_DESC 'order' => self::SORT_DESC
), ),
'downtime_host' => array( 'host_display_name' => array(
'columns' => array( 'columns' => array(
'downtime_host', 'host_display_name',
'downtime_service' 'service_display_name'
), ),
'order' => self::SORT_ASC 'order' => self::SORT_ASC
), ),
'service_display_name' => array(
'columns' => array(
'service_display_name',
'host_display_name'
),
'order' => self::SORT_ASC
)
); );
} }
} }

View File

@ -1,6 +1,4 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView; namespace Icinga\Module\Monitoring\DataView;
@ -20,7 +18,9 @@ class EventHistory extends DataView
'cnt_downtime_start', 'cnt_downtime_start',
'cnt_downtime_end', 'cnt_downtime_end',
'host_name', 'host_name',
'host_display_name',
'service_description', 'service_description',
'service_display_name',
'object_type', 'object_type',
'timestamp', 'timestamp',
'state', 'state',
@ -38,8 +38,8 @@ class EventHistory extends DataView
{ {
return array( return array(
'timestamp' => array( 'timestamp' => array(
'columns' => array('timestamp'), 'columns' => array('timestamp'),
'order' => 'DESC' 'order' => 'DESC'
) )
); );
} }

View File

@ -24,6 +24,7 @@ class HostStatus extends DataView
return array( return array(
'host', 'host',
'host_name', 'host_name',
'host_display_name',
'host_alias', 'host_alias',
'host_address', 'host_address',
'host_state', 'host_state',
@ -90,7 +91,7 @@ class HostStatus extends DataView
public function getSortRules() public function getSortRules()
{ {
return array( return array(
'host_name' => array( 'host_display_name' => array(
'order' => self::SORT_ASC 'order' => self::SORT_ASC
), ),
'host_address' => array( 'host_address' => array(

View File

@ -20,7 +20,9 @@ class Notification extends DataView
'notification_start_time', 'notification_start_time',
'notification_contact', 'notification_contact',
'notification_output', 'notification_output',
'notification_command' 'notification_command',
'host_display_name',
'service_display_name'
); );
} }

View File

@ -25,6 +25,7 @@ class ServiceStatus extends DataView
{ {
return array( return array(
'host_name', 'host_name',
'host_display_name',
'host_state', 'host_state',
'host_state_type', 'host_state_type',
'host_last_state_change', 'host_last_state_change',
@ -123,19 +124,12 @@ class ServiceStatus extends DataView
public function getSortRules() public function getSortRules()
{ {
return array( return array(
'host_name' => array( 'service_severity' => array(
'columns' => array( 'columns' => array(
'service_host_name', 'service_severity',
'service_description' 'service_last_state_change'
), ),
'order' => self::SORT_ASC 'order' => self::SORT_DESC
),
'host_address' => array(
'columns' => array(
'host_ipv4',
'service_description'
),
'order' => self::SORT_ASC
), ),
'host_severity' => array( 'host_severity' => array(
'columns' => array( 'columns' => array(
@ -144,12 +138,19 @@ class ServiceStatus extends DataView
), ),
'order' => self::SORT_ASC 'order' => self::SORT_ASC
), ),
'service_severity' => array( 'host_display_name' => array(
'columns' => array( 'columns' => array(
'service_severity', 'host_display_name',
'service_last_state_change', '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
) )
); );
} }

View File

@ -91,6 +91,7 @@ class Host extends MonitoredObject
{ {
$columns = array( $columns = array(
'host_name', 'host_name',
'host_display_name',
'host_alias', 'host_alias',
'host_address', 'host_address',
'host_state', 'host_state',

View File

@ -408,7 +408,9 @@ abstract class MonitoredObject
$eventHistory = $this->backend->select()->from('eventHistory', array( $eventHistory = $this->backend->select()->from('eventHistory', array(
'object_type', 'object_type',
'host_name', 'host_name',
'host_display_name',
'service_description', 'service_description',
'service_display_name',
'timestamp', 'timestamp',
'state', 'state',
'attempt', 'attempt',

View File

@ -108,6 +108,7 @@ class Service extends MonitoredObject
{ {
return $this->backend->select()->from('serviceStatus', array( return $this->backend->select()->from('serviceStatus', array(
'host_name', 'host_name',
'host_display_name',
'host_state', 'host_state',
'host_state_type', 'host_state_type',
'host_last_state_change', 'host_last_state_change',