From 1d1fd0b3b2c90387ae4b15792f9a0623fb0fd1af Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 15 Jul 2019 16:34:48 +0200 Subject: [PATCH 1/5] Use notification_reason for new notification types --- .../Backend/Ido/Query/HostnotificationQuery.php | 12 +++++++++++- .../Backend/Ido/Query/ServicenotificationQuery.php | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php index 5356c3fcc..21e804652 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php @@ -38,7 +38,17 @@ class HostnotificationQuery extends IdoQuery 'output' => null, 'state' => 'hn.state', 'timestamp' => 'UNIX_TIMESTAMP(hn.start_time)', - 'type' => '(\'notify\')' + 'type' => ' + CASE hn.notification_reason + WHEN 1 THEN \'notification_ack\' + WHEN 2 THEN \'notification_flapping\' + WHEN 3 THEN \'notification_flapping_end\' + WHEN 5 THEN \'notification_dt_start\' + WHEN 6 THEN \'notification_dt_end\' + WHEN 7 THEN \'notification_dt_end\' + WHEN 8 THEN \'notification_custom\' + ELSE \'notification_state\' + END', ), 'instances' => array( 'instance_name' => 'i.instance_name' diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php index b15587b5d..3c94cac71 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php @@ -30,7 +30,17 @@ class ServicenotificationQuery extends IdoQuery 'output' => null, 'state' => 'sn.state', 'timestamp' => 'UNIX_TIMESTAMP(sn.start_time)', - 'type' => '(\'notify\')' + 'type' => ' + CASE sn.notification_reason + WHEN 1 THEN \'notification_ack\' + WHEN 2 THEN \'notification_flapping\' + WHEN 3 THEN \'notification_flapping_end\' + WHEN 5 THEN \'notification_dt_start\' + WHEN 6 THEN \'notification_dt_end\' + WHEN 7 THEN \'notification_dt_end\' + WHEN 8 THEN \'notification_custom\' + ELSE \'notification_state\' + END', ), 'hostgroups' => array( 'hostgroup_name' => 'hgo.name1', From f80a61d9e5a718cf9de3e2dfb2d92c0ef793f7ad Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 15 Jul 2019 16:35:27 +0200 Subject: [PATCH 2/5] Respect notification type of subqueries --- .../Backend/Ido/Query/NotificationhistoryQuery.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php index b159a7415..f08a2b916 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php @@ -27,7 +27,7 @@ class NotificationhistoryQuery extends IdoQuery 'output' => 'n.output', 'state' => 'n.state', 'timestamp' => 'n.timestamp', - 'type' => "('notify')" + 'type' => 'n.type' ), 'hosts' => array( 'host_display_name' => 'n.host_display_name', @@ -79,9 +79,6 @@ class NotificationhistoryQuery extends IdoQuery $columns[$column] = new Zend_Db_Expr('NULL'); } } - if (isset($columns['type'])) { - unset($columns['type']); - } $hosts = $this->createSubQuery('hostnotification', $columns); $this->subQueries[] = $hosts; $this->notificationQuery->union(array($hosts), Zend_Db_Select::SQL_UNION_ALL); @@ -93,9 +90,6 @@ class NotificationhistoryQuery extends IdoQuery protected function joinServices() { $columns = array_flip($this->desiredColumns); - if (isset($columns['type'])) { - unset($columns['type']); - } $services = $this->createSubQuery('servicenotification', array_flip($columns)); $this->subQueries[] = $services; $this->notificationQuery->union(array($services), Zend_Db_Select::SQL_UNION_ALL); From 54f9c68887cdda25cede4f6077b8d424200ad2e8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 15 Jul 2019 16:36:25 +0200 Subject: [PATCH 3/5] Show notifications before any other event in the history views --- .../library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php index 4aa57b51b..041028cda 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php @@ -59,12 +59,12 @@ class EventhistoryQuery extends IdoQuery 'service_display_name' ); $this->subQueries = array( + $this->createSubQuery('Notificationhistory', $columns), $this->createSubQuery('Statehistory', $columns), $this->createSubQuery('Downtimestarthistory', $columns), $this->createSubQuery('Downtimeendhistory', $columns), $this->createSubQuery('Commenthistory', $columns), $this->createSubQuery('Commentdeletionhistory', $columns), - $this->createSubQuery('Notificationhistory', $columns), $this->createSubQuery('Flappingstarthistory', $columns), $this->createSubQuery('Flappingendhistory', $columns) ); From 213e7a3c132c75b084ab88155ee00f78a3f5da2e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 15 Jul 2019 16:37:26 +0200 Subject: [PATCH 4/5] Show new notfication types in the history views --- .../scripts/partials/event-history.phtml | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/partials/event-history.phtml b/modules/monitoring/application/views/scripts/partials/event-history.phtml index 5c34fdc72..73648095b 100644 --- a/modules/monitoring/application/views/scripts/partials/event-history.phtml +++ b/modules/monitoring/application/views/scripts/partials/event-history.phtml @@ -53,16 +53,44 @@ $rowAction = Url::fromPath('monitoring/event/show'); 'id' => $event->id )); switch ($event->type) { - case 'notify': + case substr($event->type, 0, 13) === 'notification_': $icon = 'bell'; - $iconTitle = $this->translate('Notification', 'tooltip'); - $label = $this->translate('NOTIFICATION'); + switch (substr($event->type, 13)) { + case 'state': + $iconTitle = $this->translate('State notification', 'tooltip'); + $label = $this->translate('NOTIFICATION'); + $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + break; + case 'ack': + $iconTitle = $this->translate('Ack Notification', 'tooltip'); + $label = $this->translate('ACK NOTIFICATION'); + break; + case 'dt_start': + $iconTitle = $this->translate('Downtime start notification', 'tooltip'); + $label = $this->translate('DOWNTIME START NOTIFICATION'); + break; + case 'dt_end': + $iconTitle = $this->translate('Downtime end notification', 'tooltip'); + $label = $this->translate('DOWNTIME END NOTIFICATION'); + break; + case 'flapping': + $iconTitle = $this->translate('Flapping notification', 'tooltip'); + $label = $this->translate('FLAPPING NOTIFICATION'); + break; + case 'flapping_end': + $iconTitle = $this->translate('Flapping end notification', 'tooltip'); + $label = $this->translate('FLAPPING END NOTIFICATION'); + break; + case 'custom': + $iconTitle = $this->translate('Custom notification', 'tooltip'); + $label = $this->translate('CUSTOM NOTIFICATION'); + break; + } $msg = $msg ? preg_replace_callback( '/^\[([^\]]+)\]/', function($match) use ($self) { return contactsLink($match, $self); }, $msg ) : $this->translate('This notification was not sent out to any contact.'); - $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); break; case 'comment': $icon = 'comment-empty'; From aa293f54bd1809d26c03ca8026a2264e15cfb183 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 15 Jul 2019 16:38:32 +0200 Subject: [PATCH 5/5] Separate icon and event output in the history views --- .../scripts/partials/event-history.phtml | 63 +++++++++++-------- modules/monitoring/public/css/tables.less | 15 +++++ 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/modules/monitoring/application/views/scripts/partials/event-history.phtml b/modules/monitoring/application/views/scripts/partials/event-history.phtml index 73648095b..3318deae3 100644 --- a/modules/monitoring/application/views/scripts/partials/event-history.phtml +++ b/modules/monitoring/application/views/scripts/partials/event-history.phtml @@ -179,38 +179,47 @@ $rowAction = Url::fromPath('monitoring/event/show');
formatTime($event->timestamp) ?>
- isOverview): ?> - qlink( - $event->host_display_name, - 'monitoring/host/show', - array( - 'host' => $event->host_name, - ), - array('title' => sprintf( - $this->translate('Show detailed information for host %s'), - $event->host_display_name - )) - ) ?>: +
+ +
+ icon($icon, $iconTitle) ?> +
+ +
+ isOverview): ?> qlink( - $event->service_display_name, - 'monitoring/service/show', - array( - 'host' => $event->host_name, - 'service' => $event->service_description - ), - array( + $event->host_display_name, + 'monitoring/host/show', + [ + 'host' => $event->host_name, + ], + [ 'title' => sprintf( - $this->translate('Show detailed information for service %s on host %s'), - $event->service_display_name, + $this->translate('Show detailed information for host %s'), $event->host_display_name ) - ) - ) ?> + ] + ) ?>: + qlink( + $event->service_display_name, + 'monitoring/service/show', + [ + 'host' => $event->host_name, + 'service' => $event->service_description + ], + [ + 'title' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $event->service_display_name, + $event->host_display_name + ) + ] + ) ?> + - - icon($icon, $iconTitle); - } ?>nl2br($this->createTicketLinks($this->markdown($msg, ['class' => 'overview-plugin-output']))) ?> + nl2br($this->createTicketLinks($this->markdown($msg, ['class' => 'overview-plugin-output']))) ?> +
+
diff --git a/modules/monitoring/public/css/tables.less b/modules/monitoring/public/css/tables.less index 04d5a71ee..33472373a 100644 --- a/modules/monitoring/public/css/tables.less +++ b/modules/monitoring/public/css/tables.less @@ -241,3 +241,18 @@ cursor: pointer; } } + +// Event history +.history-message-container { + display: flex; + align-items: center; + justify-content: center; + + > .history-message-icon { + padding: 0.25em; + } + + > .history-message-output { + flex: 1; + } +}