diff --git a/modules/monitoring/application/views/scripts/host/history.phtml b/modules/monitoring/application/views/scripts/host/history.phtml new file mode 100644 index 000000000..829d46fac --- /dev/null +++ b/modules/monitoring/application/views/scripts/host/history.phtml @@ -0,0 +1,169 @@ +compact): ?> +
+ tabs; ?> + render('partials/host/object-header.phtml'); ?> +

translate('This Host\'s Event History'); ?>

+ sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?> +
+ +
+translate('No history events found matching the filter') . '
'; + return; +} +?> + +qlink( + $contact, + 'monitoring/show/contact', + array('contact_name' => $contact), + array('title' => sprintf($view->translate('Show detailed information about %s'), $contact)) + ); + } + return '[' . implode(', ', $links) . ']'; +} +?> + + + + + service_description); + switch ($event->type) { + case 'notify': + $icon = 'notification'; + $title = $this->translate('Notification'); + $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + + $msg = preg_replace_callback( + '/^\[([^\]]+)\]/', + function($match) use ($self) { return contactsLink($match, $self); }, + $this->escape($event->output) + ); + break; + case 'comment': + $icon = 'comment'; + $title = $this->translate('Comment'); + $msg = $this->escape($event->output); + break; + case 'comment_deleted': + $icon = 'remove'; + $title = $this->translate('Comment deleted'); + $msg = $this->escape($event->output); + break; + case 'ack': + $icon = 'acknowledgement'; + $title = $this->translate('Acknowledge'); + $msg = $this->escape($event->output); + break; + case 'ack_deleted': + $icon = 'remove'; + $title = $this->translate('Ack removed'); + $msg = $this->escape($event->output); + break; + case 'dt_comment': + $icon = 'in_downtime'; + $title = $this->translate('In Downtime'); + $msg = $this->escape($event->output); + break; + case 'dt_comment_deleted': + $icon = 'remove'; + $title = $this->translate('Downtime removed'); + $msg = $this->escape($event->output); + break; + case 'flapping': + $icon = 'flapping'; + $title = $this->translate('Flapping'); + $msg = $this->escape($event->output); + break; + case 'flapping_deleted': + $icon = 'remove'; + $title = $this->translate('Flapping stopped'); + $msg = $this->escape($event->output); + break; + case 'hard_state': + $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); + $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + $icon = 'attention-alt'; + $title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + break; + case 'soft_state': + $icon = 'spinner'; + $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); + $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + $title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + break; + case 'dt_start': + $icon = 'downtime_start'; + $title = $this->translate('Downtime Start'); + $msg = $this->escape($event->output); + break; + case 'dt_end': + $icon = 'downtime_end'; + $title = $this->translate('Downtime End'); + $msg = $this->escape($event->output); + break; + } + ?> + + + + + + +
+ escape($title); ?> +
+ timestamp); ?> +
tickets ? preg_replace_callback( + $this->tickets->getPattern(), + array($this->tickets, 'createLink'), + $msg +) : $msg; + +?> + + translate('%s on %s', 'Service running on host'), + $this->qlink( + $event->service_display_name, + 'monitoring/show/service', + array( + 'host' => $event->host_name, + 'service' => $event->service_description + ), + array('title' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $event->service_display_name, + $event->host_display_name + )) + ), + $event->host_display_name + ) ?> + + escape($event->host_name); ?> + +
+
+ icon($icon, $title); ?> +
+
+ \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/service/history.phtml b/modules/monitoring/application/views/scripts/service/history.phtml new file mode 100644 index 000000000..dd6a0b3d9 --- /dev/null +++ b/modules/monitoring/application/views/scripts/service/history.phtml @@ -0,0 +1,151 @@ +compact): ?> +
+ tabs; ?> + render('partials/service/object-header.phtml'); ?> +

translate('This Service\'s Event History'); ?>

+ sortBox; ?> + limiter; ?> + paginator; ?> + filterEditor; ?> +
+ +
+translate('No history events found matching the filter') . '
'; + return; +} +?> + +qlink( + $contact, + 'monitoring/show/contact', + array('contact_name' => $contact), + array('title' => sprintf($view->translate('Show detailed information about %s'), $contact)) + ); + } + return '[' . implode(', ', $links) . ']'; +} +?> + + + + + type) { + case 'notify': + $icon = 'notification'; + $title = $this->translate('Notification'); + $stateClass = Service::getStateText($event->state); + + $msg = preg_replace_callback( + '/^\[([^\]]+)\]/', + function($match) use ($self) { return contactsLink($match, $self); }, + $this->escape($event->output) + ); + break; + case 'comment': + $icon = 'comment'; + $title = $this->translate('Comment'); + $msg = $this->escape($event->output); + break; + case 'comment_deleted': + $icon = 'remove'; + $title = $this->translate('Comment deleted'); + $msg = $this->escape($event->output); + break; + case 'ack': + $icon = 'acknowledgement'; + $title = $this->translate('Acknowledge'); + $msg = $this->escape($event->output); + break; + case 'ack_deleted': + $icon = 'remove'; + $title = $this->translate('Ack removed'); + $msg = $this->escape($event->output); + break; + case 'dt_comment': + $icon = 'in_downtime'; + $title = $this->translate('In Downtime'); + $msg = $this->escape($event->output); + break; + case 'dt_comment_deleted': + $icon = 'remove'; + $title = $this->translate('Downtime removed'); + $msg = $this->escape($event->output); + break; + case 'flapping': + $icon = 'flapping'; + $title = $this->translate('Flapping'); + $msg = $this->escape($event->output); + break; + case 'flapping_deleted': + $icon = 'remove'; + $title = $this->translate('Flapping stopped'); + $msg = $this->escape($event->output); + break; + case 'hard_state': + $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); + $stateClass = Service::getStateText($event->state); + $icon = 'attention-alt'; + $title = Service::getStateText($event->state); + break; + case 'soft_state': + $icon = 'spinner'; + $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); + $stateClass = Service::getStateText($event->state); + $title = Service::getStateText($event->state); + break; + case 'dt_start': + $icon = 'downtime_start'; + $title = $this->translate('Downtime Start'); + $msg = $this->escape($event->output); + break; + case 'dt_end': + $icon = 'downtime_end'; + $title = $this->translate('Downtime End'); + $msg = $this->escape($event->output); + break; + } + ?> + + + + + + +
+ escape($title); ?> +
+ timestamp); ?> +
tickets ? preg_replace_callback( + $this->tickets->getPattern(), + array($this->tickets, 'createLink'), + $msg +) : $msg; + +?> + translate('%s on %s', 'Service running on host'), + $this->escape($event->service_display_name), + $event->host_display_name + ) ?> +
+
+ icon($icon, $title); ?> +
+
+ \ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 0b1cda923..8879a40ea 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -93,6 +93,19 @@ abstract class MonitoredObjectController extends Controller $this->view->object = $this->object; } + /** + * Show the history for a host or service + */ + public function historyAction() + { + $this->getTabs()->activate('history'); + $this->view->history = $this->object->fetchEventHistory()->eventhistory; + + $this->setupLimitControl(50); + $this->setupPaginationControl($this->view->history, 50); + $this->view->object = $this->object; + } + /** * Handle a command form * @@ -211,7 +224,7 @@ abstract class MonitoredObjectController extends Controller , 'label' => $this->translate('History'), 'icon' => 'rewind', - 'url' => 'monitoring/show/history', + 'url' => $isService ? 'monitoring/service/history' : 'monitoring/host/history', 'urlParams' => $params ) );