diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:21:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:21:35 +0000 |
commit | 8adc969fb08ffab5f8e9e0b05b081046bdc2ad9a (patch) | |
tree | 555499bc0262c29210c706b44e0fb23c0ddd8b92 /library/Graphite | |
parent | Adding debian version 1.2.2-3. (diff) | |
download | icingaweb2-module-graphite-8adc969fb08ffab5f8e9e0b05b081046bdc2ad9a.tar.xz icingaweb2-module-graphite-8adc969fb08ffab5f8e9e0b05b081046bdc2ad9a.zip |
Merging upstream version 1.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Graphite')
12 files changed, 38 insertions, 86 deletions
diff --git a/library/Graphite/Graphing/Chart.php b/library/Graphite/Graphing/Chart.php index ded8ae8..bee5e7d 100644 --- a/library/Graphite/Graphing/Chart.php +++ b/library/Graphite/Graphing/Chart.php @@ -107,9 +107,9 @@ class Chart $response ->setHeader('Content-Type', 'image/png', true) ->setHeader('Content-Disposition', 'inline; filename="graph.png"', true) - ->setHeader('Cache-Control', null, true) - ->setHeader('Expires', null, true) - ->setHeader('Pragma', null, true) + ->setHeader('Cache-Control', '', true) + ->setHeader('Expires', '', true) + ->setHeader('Pragma', '', true) ->setBody($image) ->sendResponse(); diff --git a/library/Graphite/Graphing/GraphiteWebClient.php b/library/Graphite/Graphing/GraphiteWebClient.php index b06b6ce..982a2af 100644 --- a/library/Graphite/Graphing/GraphiteWebClient.php +++ b/library/Graphite/Graphing/GraphiteWebClient.php @@ -2,10 +2,10 @@ namespace Icinga\Module\Graphite\Graphing; +use GuzzleHttp\Client; +use GuzzleHttp\ClientInterface; +use GuzzleHttp\Psr7\Request; use Icinga\Web\Url; -use iplx\Http\Client; -use iplx\Http\ClientInterface; -use iplx\Http\Request; /** * HTTP interface to Graphite Web diff --git a/library/Graphite/Graphing/MetricsQuery.php b/library/Graphite/Graphing/MetricsQuery.php index da05c17..93d0c90 100644 --- a/library/Graphite/Graphing/MetricsQuery.php +++ b/library/Graphite/Graphing/MetricsQuery.php @@ -71,7 +71,7 @@ class MetricsQuery implements Queryable, Filterable, Fetchable try { $this->base = $target instanceof MacroTemplate ? $target : new MacroTemplate((string) $target); } catch (InvalidArgumentException $e) { - throw new InvalidArgumentException('Bad target', $e); + throw new InvalidArgumentException('Bad target', $e->getCode(), $e); } return $this; diff --git a/library/Graphite/Graphing/Template.php b/library/Graphite/Graphing/Template.php index a030fb7..0950fed 100644 --- a/library/Graphite/Graphing/Template.php +++ b/library/Graphite/Graphing/Template.php @@ -203,6 +203,7 @@ class Template } } unset($_); + assert(isset($nextCurveName), 'loop did not initialize variable $nextCurveName'); $allowedNextCurveMetricsPerCurrentCurveName = []; foreach ($currentCombination as $currentCurveName => $currentCurveMetric) { diff --git a/library/Graphite/ProvidedHook/Icingadb/HostDetailExtension.php b/library/Graphite/ProvidedHook/Icingadb/HostDetailExtension.php index 31e4e6c..94d5547 100644 --- a/library/Graphite/ProvidedHook/Icingadb/HostDetailExtension.php +++ b/library/Graphite/ProvidedHook/Icingadb/HostDetailExtension.php @@ -23,8 +23,8 @@ class HostDetailExtension extends HostDetailExtensionHook } $graphs = (string) Graphs::forIcingadbObject($host) - ->setWidth(440) - ->setHeight(220) + ->setWidth('440') + ->setHeight('220') ->setClasses(['object-detail-view']) ->setPreloadDummy() ->setShowNoGraphsFound(false) diff --git a/library/Graphite/ProvidedHook/Icingadb/ServiceDetailExtension.php b/library/Graphite/ProvidedHook/Icingadb/ServiceDetailExtension.php index 63c2b79..0f4f33a 100644 --- a/library/Graphite/ProvidedHook/Icingadb/ServiceDetailExtension.php +++ b/library/Graphite/ProvidedHook/Icingadb/ServiceDetailExtension.php @@ -23,8 +23,8 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook } $graphs = (string) Graphs::forIcingadbObject($service) - ->setWidth(440) - ->setHeight(220) + ->setWidth('440') + ->setHeight('220') ->setClasses(['object-detail-view']) ->setPreloadDummy() ->setShowNoGraphsFound(false) diff --git a/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php b/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php index d6a4673..23912a7 100644 --- a/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php +++ b/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php @@ -20,8 +20,8 @@ class DetailviewExtension extends DetailviewExtensionHook } $graphs = (string) Graphs::forMonitoredObject($object) - ->setWidth(440) - ->setHeight(220) + ->setWidth('440') + ->setHeight('220') ->setClasses(['object-detail-view']) ->setPreloadDummy() ->setShowNoGraphsFound(false) diff --git a/library/Graphite/Web/Controller/IcingadbGraphiteController.php b/library/Graphite/Web/Controller/IcingadbGraphiteController.php index 36bc026..58c2382 100644 --- a/library/Graphite/Web/Controller/IcingadbGraphiteController.php +++ b/library/Graphite/Web/Controller/IcingadbGraphiteController.php @@ -28,8 +28,8 @@ class IcingadbGraphiteController extends CompatController /** @var bool Whether to use icingadb as the backend */ protected $useIcingadbAsBackend; - /** @var string[] Graph parameters */ - protected $graphParams = ['graphs_limit', 'graph_range', 'graph_start', 'graph_end', 'legacyParams']; + /** @var string[] Preserved graph parameters */ + protected $preservedParams = ['graphs_limit', 'graph_range', 'graph_start', 'graph_end', 'legacyParams', 'format']; /** @var Filter\Rule Filter from query string parameters */ private $filter; @@ -52,59 +52,4 @@ class IcingadbGraphiteController extends CompatController return $this->filter; } - - /** - * Create and return the LimitControl - * - * This automatically shifts the limit URL parameter from {@link $params}. - * - * @return LimitControl - */ - public function createLimitControl(): LimitControl - { - $limitControl = new LimitControl(Url::fromRequest()); - $limitControl->setDefaultLimit($this->getPageSize(null)); - - $this->params->shift($limitControl->getLimitParam()); - - return $limitControl; - } - - /** - * Create and return the PaginationControl - * - * This automatically shifts the pagination URL parameters from {@link $params}. - * - * @return PaginationControl - */ - public function createPaginationControl(Paginatable $paginatable): PaginationControl - { - $paginationControl = new PaginationControl($paginatable, Url::fromRequest()); - $paginationControl->setDefaultPageSize($this->getPageSize(null)); - $paginationControl->setAttribute('id', $this->getRequest()->protectId('pagination-control')); - - $this->params->shift($paginationControl->getPageParam()); - $this->params->shift($paginationControl->getPageSizeParam()); - - return $paginationControl->apply(); - } - - /** - * Create and return the SortControl - * - * This automatically shifts the sort URL parameter from {@link $params}. - * - * @param Query $query - * @param array $columns Possible sort columns as sort string-label pairs - * - * @return SortControl - */ - public function createSortControl(Query $query, array $columns): SortControl - { - $sortControl = SortControl::create($columns); - - $this->params->shift($sortControl->getSortParam()); - - return $sortControl->apply($query); - } } diff --git a/library/Graphite/Web/Controller/MonitoringAwareController.php b/library/Graphite/Web/Controller/MonitoringAwareController.php index dca2ebd..d4f1a07 100644 --- a/library/Graphite/Web/Controller/MonitoringAwareController.php +++ b/library/Graphite/Web/Controller/MonitoringAwareController.php @@ -22,6 +22,9 @@ abstract class MonitoringAwareController extends Controller /** @var bool Whether to use icingadb as the backend */ protected $useIcingadbAsBackend = false; + /** @var MonitoringBackend */ + protected $backend; + /** * Restrict the given monitored object query for the currently authenticated user * diff --git a/library/Graphite/Web/Widget/GraphImage.php b/library/Graphite/Web/Widget/GraphImage.php index af64e69..e99bf09 100644 --- a/library/Graphite/Web/Widget/GraphImage.php +++ b/library/Graphite/Web/Widget/GraphImage.php @@ -126,7 +126,7 @@ class GraphImage extends AbstractWidget // Try to render a higher time range, but give up // once our default (1h) has been reached (non successfully). if ($diff < 3600) { - $url->setParam('from', $until - $diff * 2); + $url->setParam('from', sprintf('%F', ($until - $diff * 2))); continue; } } diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index e18b8da..e49a0eb 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -134,7 +134,7 @@ abstract class Graphs extends AbstractWidget * * @param MonitoredObject $object * - * @return static + * @return ?static */ public static function forMonitoredObject(MonitoredObject $object) { @@ -304,17 +304,17 @@ abstract class Graphs extends AbstractWidget $actheight = $this->height; } $actwidth = $this->width; - $actwidthfix = ""; + $explicitWidth = false; if (array_key_exists("width", $urlParams)) { $actwidth = $urlParams["width"]->resolve(['width']); - $actwidthfix = "width: {$actwidth}px; "; + $explicitWidth = $actwidth; } if ($this->renderInline) { $chart->setFrom($this->start) ->setUntil($this->end) - ->setWidth($actwidth) - ->setHeight($actheight) + ->setWidth((int) $actwidth) + ->setHeight((int) $actheight) ->setBackgroundColor('white') ->setForegroundColor('black') ->setMajorGridLineColor('grey') @@ -331,7 +331,7 @@ abstract class Graphs extends AbstractWidget ->setParam('height', $actheight); if (! $this->compact) { - $imageUrl->setParam('legend', 1); + $imageUrl->setParam('legend', '1'); } if ($this->preloadDummy) { @@ -344,8 +344,12 @@ abstract class Graphs extends AbstractWidget $img = '<img id="graphiteImg-' . md5((string) $imageUrl) . '"' . " src=\"$src\" data-actualimageurl=\"$imageUrl\" class=\"detach graphiteImg\"" - . " alt=\"\" width=\"$actwidth\" height=\"$actheight\"" - . " style=\"min-width: {$actwidth}px; $actwidthfix min-height: {$actheight}px;\">"; + . " alt=\"\" width=\"$actwidth\" height=\"$actheight\""; + if ($explicitWidth !== false) { + $img .= " data-width=\"$explicitWidth\""; + } + + $img .= '>'; } $currentGraphs[] = [$img, $metricVariables, $bestPos]; diff --git a/library/Graphite/Web/Widget/IcingadbGraphs.php b/library/Graphite/Web/Widget/IcingadbGraphs.php index e038e92..82bfe53 100644 --- a/library/Graphite/Web/Widget/IcingadbGraphs.php +++ b/library/Graphite/Web/Widget/IcingadbGraphs.php @@ -4,11 +4,9 @@ namespace Icinga\Module\Graphite\Web\Widget; -use Icinga\Data\Filter\Filter; use Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb\IcingadbHost; use Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb\IcingadbService; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Widget\EmptyState; use Icinga\Module\Icingadb\Model\Host; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; @@ -16,7 +14,7 @@ use ipl\Html\HtmlDocument; use ipl\Html\HtmlString; use ipl\Orm\ResultSet; use ipl\Stdlib\BaseFilter; -use ipl\Web\Filter\QueryString; +use ipl\Web\Widget\EmptyState; use ipl\Web\Widget\Link; /** @@ -69,9 +67,10 @@ class IcingadbGraphs extends BaseHtmlElement } $hostUrl = Links::host($hostObj); + $baseFilter = $this->getBaseFilter(); - if ($this->hasBaseFilter()) { - $hostUrl->addFilter(Filter::fromQueryString(QueryString::render($this->getBaseFilter()))); + if ($baseFilter !== null) { + $hostUrl->setFilter($baseFilter); } $hostLink = new Link( @@ -84,8 +83,8 @@ class IcingadbGraphs extends BaseHtmlElement if ($graph->getObjectType() === 'service') { $serviceUrl = Links::service($object, $hostObj); - if ($this->hasBaseFilter()) { - $serviceUrl->addFilter(Filter::fromQueryString(QueryString::render($this->getBaseFilter()))); + if ($baseFilter !== null) { + $serviceUrl->setFilter($baseFilter); } $serviceLink = new Link( |