diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
commit | 8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch) | |
tree | 2492de6f1528dd44eaa169a5c1555026d9cb75ec /modules/monitoring/application/views/scripts/list/eventgrid.phtml | |
parent | Initial commit. (diff) | |
download | icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.tar.xz icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.zip |
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | modules/monitoring/application/views/scripts/list/eventgrid.phtml | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/modules/monitoring/application/views/scripts/list/eventgrid.phtml b/modules/monitoring/application/views/scripts/list/eventgrid.phtml new file mode 100644 index 0000000..8809c53 --- /dev/null +++ b/modules/monitoring/application/views/scripts/list/eventgrid.phtml @@ -0,0 +1,123 @@ +<?php +use Icinga\Data\Filter\Filter; +use Icinga\Web\Widget\Chart\HistoryColorGrid; + +if (! $this->compact): ?> +<div class="controls"> + <?= $this->tabs ?> + <?= $this->form ?> +</div> +<?php endif ?> +<div class="content" data-base-target="_next"> +<?php + +$settings = array( + 'cnt_up' => array( + 'tooltip' => $this->translate('%d hosts ok on %s'), + 'color' => '#49DF96', + 'opacity' => '0.55' + ), + 'cnt_unreachable_hard' => array( + 'tooltip' => $this->translate('%d hosts unreachable on %s'), + 'color' => '#77AAFF', + 'opacity' => '0.55' + ), + 'cnt_critical_hard' => array( + 'tooltip' => $this->translate('%d services critical on %s'), + 'color' => '#ff5566', + 'opacity' => '0.9' + ), + + 'cnt_warning_hard' => array( + 'tooltip' => $this->translate('%d services warning on %s'), + 'color' => '#ffaa44', + 'opacity' => '1.0' + ), + + 'cnt_down_hard' => array( + 'tooltip' => $this->translate('%d hosts down on %s'), + 'color' => '#ff5566', + 'opacity' => '0.9' + ), + 'cnt_unknown_hard' => array( + 'tooltip' => $this->translate('%d services unknown on %s'), + 'color' => '#cc77ff', + 'opacity' => '0.7' + ), + 'cnt_ok' => array( + 'tooltip' => $this->translate('%d services ok on %s'), + 'color' => '#49DF96', + 'opacity' => '0.55' + ) +); + +$data = array(); +foreach ($summary as $entry) { + $day = $entry->day; + $value = $entry->$column; + $caption = sprintf( + $settings[$column]['tooltip'], + $value, + $this->formatDate(strtotime($day ?? '')) + ); + $linkFilter = Filter::matchAll( + Filter::expression('timestamp', '<', strtotime($day . ' 23:59:59')), + Filter::expression('timestamp', '>', strtotime($day . ' 00:00:00')), + $form->getFilter(), + $filter + ); + $data[$day] = array( + 'value' => $value, + 'caption' => $caption, + 'url' => $this->href('monitoring/list/eventhistory?' . $linkFilter->toQueryString()) + ); +} + +if (! $summary->hasResult()) { + echo $this->translate('No state changes in the selected time period.') . '</div>'; + return; +} + +$from = intval($form->getValue('from', strtotime('3 months ago'))); +$to = intval($form->getValue('to', time())); + +// don't display more than ten years, or else this will get really slow +if ($to - $from > 315360000) { + $from = $to - 315360000; +} + +$f = new DateTime(); +$f->setTimestamp($from); +$t = new DateTime(); +$t->setTimestamp($to); +$diff = $t->diff($f); +$step = 124; + +for ($i = 0; $i < $diff->days; $i += $step) { + $end = clone $f; + if ($diff->days - $i > $step) { + // full range, move last day to next chunk + $end->add(new DateInterval('P' . ($step - 1) . 'D')); + } else { + // include last day + $end->add(new DateInterval('P' . ($diff->days - $i) . 'D')); + } + $grid = new HistoryColorGrid(null, $f->getTimestamp(), $end->getTimestamp()); + $grid->setColor($settings[$column]['color']); + $grid->opacity = $settings[$column]['opacity']; + $grid->orientation = $orientation; + $grid->setData($data); + $grids[] = $grid; + + $f->add(new DateInterval('P' . $step . 'D')); +} +?> +<div style="width: 33.5em;"> +<?php foreach (array_reverse($grids) as $key => $grid): ?> + <div style=" <?= $this->orientation === 'horizontal' ? '' : 'display: inline-block; vertical-align: top; top; margin: 0.5em;' ?>"> + <?= $grid; ?> + <?= $this->orientation === 'horizontal' ? '<br />' : '' ?> + </div> +<?php endforeach ?> + </div> +</div> |