EventHistoryQuery: Do not fetch columns which only exist in one subquery
Uses the same technique as the NotificationhistoryQuery for the output.
This commit is contained in:
parent
db816e4a5c
commit
41ee39d48f
|
@ -575,8 +575,6 @@ class Monitoring_ListController extends Controller
|
||||||
'object_type',
|
'object_type',
|
||||||
'timestamp',
|
'timestamp',
|
||||||
'state',
|
'state',
|
||||||
'attempt',
|
|
||||||
'max_attempts',
|
|
||||||
'output',
|
'output',
|
||||||
'type'
|
'type'
|
||||||
));
|
));
|
||||||
|
|
|
@ -23,6 +23,7 @@ if (count($history) === 0) {
|
||||||
<?php foreach ($history as $event): ?>
|
<?php foreach ($history as $event): ?>
|
||||||
<?php
|
<?php
|
||||||
$icon = 'help';
|
$icon = 'help';
|
||||||
|
$msg = $event->output;
|
||||||
$title = $event->type;
|
$title = $event->type;
|
||||||
$stateName = 'invalid';
|
$stateName = 'invalid';
|
||||||
$isService = isset($event->service_description);
|
$isService = isset($event->service_description);
|
||||||
|
@ -30,54 +31,44 @@ if (count($history) === 0) {
|
||||||
case 'notify':
|
case 'notify':
|
||||||
$icon = 'bell';
|
$icon = 'bell';
|
||||||
$title = $this->translate('Notification');
|
$title = $this->translate('Notification');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'comment':
|
case 'comment':
|
||||||
$icon = 'comment';
|
$icon = 'comment';
|
||||||
$title = $this->translate('Comment');
|
$title = $this->translate('Comment');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'ack':
|
case 'ack':
|
||||||
$icon = 'ok';
|
$icon = 'ok';
|
||||||
$title = $this->translate('Acknowledgement');
|
$title = $this->translate('Acknowledgement');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'dt_comment':
|
case 'dt_comment':
|
||||||
$icon = 'plug';
|
$icon = 'plug';
|
||||||
$title = $this->translate('In Downtime');
|
$title = $this->translate('In Downtime');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'flapping':
|
case 'flapping':
|
||||||
$icon = 'flapping';
|
$icon = 'flapping';
|
||||||
$title = $this->translate('Flapping');
|
$title = $this->translate('Flapping');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'flapping_deleted':
|
case 'flapping_deleted':
|
||||||
$icon = 'ok';
|
$icon = 'ok';
|
||||||
$title = $this->translate('Flapping Stopped');
|
$title = $this->translate('Flapping Stopped');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'hard_state':
|
case 'hard_state':
|
||||||
$icon = $isService ? 'service' : 'host';
|
$icon = $isService ? 'service' : 'host';
|
||||||
$msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $event->output;
|
|
||||||
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
||||||
$title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
|
$title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
|
||||||
break;
|
break;
|
||||||
case 'soft_state':
|
case 'soft_state':
|
||||||
$icon = 'lightbulb';
|
$icon = 'lightbulb';
|
||||||
$msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $event->output;
|
|
||||||
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
||||||
$title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
|
$title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
|
||||||
break;
|
break;
|
||||||
case 'dt_start':
|
case 'dt_start':
|
||||||
$icon = 'starttime';
|
$icon = 'starttime';
|
||||||
$title = $this->translate('Downtime Start');
|
$title = $this->translate('Downtime Start');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
case 'dt_end':
|
case 'dt_end':
|
||||||
$icon = 'endtime';
|
$icon = 'endtime';
|
||||||
$title = $this->translate('Downtime End');
|
$title = $this->translate('Downtime End');
|
||||||
$msg = $event->output;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -49,6 +49,7 @@ function contactsLink($match, $view) {
|
||||||
<?php foreach ($history as $event): ?>
|
<?php foreach ($history as $event): ?>
|
||||||
<?php
|
<?php
|
||||||
$stateClass = 'invalid';
|
$stateClass = 'invalid';
|
||||||
|
$msg = $this->escape($event->output);
|
||||||
$isService = isset($event->service_description);
|
$isService = isset($event->service_description);
|
||||||
switch ($event->type) {
|
switch ($event->type) {
|
||||||
case 'notify':
|
case 'notify':
|
||||||
|
@ -59,70 +60,58 @@ function contactsLink($match, $view) {
|
||||||
$msg = preg_replace_callback(
|
$msg = preg_replace_callback(
|
||||||
'/^\[([^\]]+)\]/',
|
'/^\[([^\]]+)\]/',
|
||||||
function($match) use ($self) { return contactsLink($match, $self); },
|
function($match) use ($self) { return contactsLink($match, $self); },
|
||||||
$this->escape($event->output)
|
$msg
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'comment':
|
case 'comment':
|
||||||
$icon = 'comment';
|
$icon = 'comment';
|
||||||
$title = $this->translate('Comment');
|
$title = $this->translate('Comment');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'comment_deleted':
|
case 'comment_deleted':
|
||||||
$icon = 'remove';
|
$icon = 'remove';
|
||||||
$title = $this->translate('Comment deleted');
|
$title = $this->translate('Comment deleted');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'ack':
|
case 'ack':
|
||||||
$icon = 'acknowledgement';
|
$icon = 'acknowledgement';
|
||||||
$title = $this->translate('Acknowledge');
|
$title = $this->translate('Acknowledge');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'ack_deleted':
|
case 'ack_deleted':
|
||||||
$icon = 'remove';
|
$icon = 'remove';
|
||||||
$title = $this->translate('Ack removed');
|
$title = $this->translate('Ack removed');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'dt_comment':
|
case 'dt_comment':
|
||||||
$icon = 'in_downtime';
|
$icon = 'in_downtime';
|
||||||
$title = $this->translate('In Downtime');
|
$title = $this->translate('In Downtime');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'dt_comment_deleted':
|
case 'dt_comment_deleted':
|
||||||
$icon = 'remove';
|
$icon = 'remove';
|
||||||
$title = $this->translate('Downtime removed');
|
$title = $this->translate('Downtime removed');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'flapping':
|
case 'flapping':
|
||||||
$icon = 'flapping';
|
$icon = 'flapping';
|
||||||
$title = $this->translate('Flapping');
|
$title = $this->translate('Flapping');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'flapping_deleted':
|
case 'flapping_deleted':
|
||||||
$icon = 'remove';
|
$icon = 'remove';
|
||||||
$title = $this->translate('Flapping stopped');
|
$title = $this->translate('Flapping stopped');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'hard_state':
|
case 'hard_state':
|
||||||
$msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output);
|
|
||||||
$stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
$stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
||||||
$icon = 'attention-alt';
|
$icon = 'attention-alt';
|
||||||
$title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
$title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
||||||
break;
|
break;
|
||||||
case 'soft_state':
|
case 'soft_state':
|
||||||
$icon = 'spinner';
|
$icon = 'spinner';
|
||||||
$msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output);
|
|
||||||
$stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
$stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
||||||
$title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
$title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
|
||||||
break;
|
break;
|
||||||
case 'dt_start':
|
case 'dt_start':
|
||||||
$icon = 'downtime_start';
|
$icon = 'downtime_start';
|
||||||
$title = $this->translate('Downtime Start');
|
$title = $this->translate('Downtime Start');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
case 'dt_end':
|
case 'dt_end':
|
||||||
$icon = 'downtime_end';
|
$icon = 'downtime_end';
|
||||||
$title = $this->translate('Downtime End');
|
$title = $this->translate('Downtime End');
|
||||||
$msg = $this->escape($event->output);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -37,9 +37,7 @@ class EventHistoryQuery extends IdoQuery
|
||||||
'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',
|
'output' => 'eh.output',
|
||||||
'max_attempts' => 'eh.max_attempts',
|
|
||||||
'output' => 'eh.output', // we do not want long_output
|
|
||||||
'type' => 'eh.type'
|
'type' => 'eh.type'
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
|
@ -70,10 +68,7 @@ class EventHistoryQuery extends IdoQuery
|
||||||
'type',
|
'type',
|
||||||
'output',
|
'output',
|
||||||
'state',
|
'state',
|
||||||
'state_type',
|
'object_type'
|
||||||
'object_type',
|
|
||||||
'attempt',
|
|
||||||
'max_attempts',
|
|
||||||
);
|
);
|
||||||
$this->subQueries = array(
|
$this->subQueries = array(
|
||||||
$this->createSubQuery('Statehistory', $columns),
|
$this->createSubQuery('Statehistory', $columns),
|
||||||
|
|
|
@ -18,10 +18,7 @@ class StatehistoryQuery extends IdoQuery
|
||||||
'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',
|
'output' => "('[ ' || sh.current_check_attempt || '/' || sh.max_check_attempts || ' ] ' || sh.output)",
|
||||||
'output' => 'sh.output',
|
|
||||||
'attempt' => 'sh.current_check_attempt',
|
|
||||||
'max_attempts' => 'sh.max_check_attempts',
|
|
||||||
|
|
||||||
'host' => 'sho.name1 COLLATE latin1_general_ci',
|
'host' => 'sho.name1 COLLATE latin1_general_ci',
|
||||||
'service' => 'sho.name2 COLLATE latin1_general_ci',
|
'service' => 'sho.name2 COLLATE latin1_general_ci',
|
||||||
|
|
|
@ -457,8 +457,6 @@ abstract class MonitoredObject implements Filterable
|
||||||
'service_display_name',
|
'service_display_name',
|
||||||
'timestamp',
|
'timestamp',
|
||||||
'state',
|
'state',
|
||||||
'attempt',
|
|
||||||
'max_attempts',
|
|
||||||
'output',
|
'output',
|
||||||
'type'
|
'type'
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue