From bfa5f9610be01e8bbead9288fe136d97e3365c4d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 12 Sep 2019 10:30:49 +0200 Subject: [PATCH] monitoring: Fix timeline * Fixes extrapolation style * Fixes missing notifications fixes #3947 --- .../controllers/TimelineController.php | 45 +++++++++++++++++-- .../library/Monitoring/Timeline/TimeLine.php | 30 ++++++++++--- modules/monitoring/public/css/module.less | 17 +++++++ 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index c178fb6d2..99a56cbec 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -46,10 +46,47 @@ class TimelineController extends Controller ) ), array( - 'notify' => array( - 'class' => 'timeline-notification', - 'detailUrl' => $detailUrl, - 'label' => mt('monitoring', 'Notifications') + 'notification_ack' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' + ), + 'notification_flapping' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' + ), + 'notification_flapping_end' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' + ), + 'notification_dt_start' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' + ), + 'notification_dt_end' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' + ), + 'notification_custom' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' + ), + 'notification_state' => array( + 'class' => 'timeline-notification', + 'detailUrl' => $detailUrl, + 'label' => mt('monitoring', 'Notifications'), + 'groupBy' => 'notification_*' ), 'hard_state' => array( 'class' => 'timeline-hard-state', diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeLine.php b/modules/monitoring/library/Monitoring/Timeline/TimeLine.php index bfec989bd..d1a98fc40 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeLine.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeLine.php @@ -208,6 +208,10 @@ class TimeLine implements IteratorAggregate { $groupInfo = array(); foreach ($this->identifiers as $name => $attributes) { + if (isset($attributes['groupBy'])) { + $name = $attributes['groupBy']; + } + $groupInfo[$name]['class'] = $attributes['class']; $groupInfo[$name]['label'] = $attributes['label']; } @@ -436,16 +440,28 @@ class TimeLine implements IteratorAggregate foreach ($data as $timestamp => $count) { $dateTime = new DateTime(); $dateTime->setTimestamp($timestamp); - $groups[$timestamp][$name] = TimeEntry::fromArray( - array_merge( - $this->identifiers[$name], + + $groupName = $name; + if (isset($this->identifiers[$name]['groupBy'])) { + $groupName = $this->identifiers[$name]['groupBy']; + } + + if (isset($groups[$timestamp][$groupName])) { + $groups[$timestamp][$groupName]->setValue( + $groups[$timestamp][$groupName]->getValue() + $count + ); + } else { + $groups[$timestamp][$groupName] = TimeEntry::fromArray( array( - 'name' => $name, + 'name' => $groupName, 'value' => $count, - 'dateTime' => $dateTime + 'dateTime' => $dateTime, + 'class' => $this->identifiers[$name]['class'], + 'detailUrl' => $this->identifiers[$name]['detailUrl'], + 'label' => $this->identifiers[$name]['label'] ) - ) - ); + ); + } } } diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 57b80ebfe..7e079adc1 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -503,21 +503,38 @@ div.timeline { } div.circle-box { + // width: inline-style; height: 100%; margin-right: 0.5em; position: relative; float: left; div.outer-circle { + // width: inline-style; + // height: inline-style; position: absolute; top: 50%; + // margin-top: inline-style; + + &.extrapolated { + border-width: 2px; + border-style: dotted; + //border-color: inline-style; + border-radius: 100%; + // background-color: inline-style; + } a.inner-circle { + // width: inline-style; + // height: inline-style; display: block; position: absolute; top: 50%; left: 50%; + // margin-top: inline-style; + // margin-left: inline-style; border-radius: 100%; + // background-color: inline-style; } } }