From ed6150cc7ecd7cf923d2ddc2efb56e491d104a8d Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 20 Oct 2017 08:27:16 +0200 Subject: [PATCH] changed crosshair from constructor to setter --- histou/grafana/dashboard/dashboard.php | 15 ++++++++++++--- .../dashboard/dashboardelasticsearch.php | 4 ++-- histou/grafana/dashboard/dashboardfactory.php | 8 ++++---- .../grafana/dashboard/dashboardinfluxdb.php | 4 ++-- templates/default/check_sakuli.php | 19 ++++++++++--------- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/histou/grafana/dashboard/dashboard.php b/histou/grafana/dashboard/dashboard.php index 97d79e9..9ad9e71 100644 --- a/histou/grafana/dashboard/dashboard.php +++ b/histou/grafana/dashboard/dashboard.php @@ -63,10 +63,9 @@ abstract class Dashboard @param string $title name of the dashboard. @return null **/ - public function __construct($title, $sharedCrosshair) + public function __construct($title) { $this->data['title'] = $title; - $this->data['sharedCrosshair'] = $sharedCrosshair; } /** @@ -86,13 +85,23 @@ public function toArray() /** Setter for Editable. - @param boolean $editable true7false. + @param boolean $editable. @return null **/ public function setEditable($editable) { $this->data['editable'] = $editable; } + + /** + Enable sharedCrosshair. + @param boolean $sharedCrosshair. + @return null + **/ + public function setSharedCrosshair($sharedCrosshair) + { + $this->data['sharedCrosshair'] = $sharedCrosshair; + } /** Setter Everything. diff --git a/histou/grafana/dashboard/dashboardelasticsearch.php b/histou/grafana/dashboard/dashboardelasticsearch.php index e51ecd3..5db5b48 100644 --- a/histou/grafana/dashboard/dashboardelasticsearch.php +++ b/histou/grafana/dashboard/dashboardelasticsearch.php @@ -27,9 +27,9 @@ class DashboardElasticsearch extends Dashboard @param string $title name of the dashboard. @return null **/ - public function __construct($title, $sharedCrosshair) + public function __construct($title) { - parent::__construct($title,$sharedCrosshair); + parent::__construct($title); } public function addAnnotation($name, $query, $title, $text, $tags, $iconColor = '#751975', $lineColor = '#751975', $datasource = ELASTICSEARCH_INDEX, $enabled = SHOW_ANNOTATION, $iconSize = 13) diff --git a/histou/grafana/dashboard/dashboardfactory.php b/histou/grafana/dashboard/dashboardfactory.php index 798194d..564a2bb 100644 --- a/histou/grafana/dashboard/dashboardfactory.php +++ b/histou/grafana/dashboard/dashboardfactory.php @@ -25,14 +25,14 @@ class DashboardFactory Returns depending on the Database_Type a dashboard. @returns a dashboard **/ - public static function generateDashboard($title, $sharedCrosshair=false) + public static function generateDashboard($title) { if (DATABASE_TYPE == INFLUXDB) { - return new \histou\grafana\dashboard\DashboardInfluxDB($title, $sharedCrosshair); + return new \histou\grafana\dashboard\DashboardInfluxDB($title); } elseif (DATABASE_TYPE == ELASTICSEARCH) { - return new \histou\grafana\dashboard\DashboardElasticsearch($title, $sharedCrosshair); + return new \histou\grafana\dashboard\DashboardElasticsearch($title); } else { throw new \InvalidArgumentException("The given Database is unkown:".DATABASE_TYPE); } - } + } } diff --git a/histou/grafana/dashboard/dashboardinfluxdb.php b/histou/grafana/dashboard/dashboardinfluxdb.php index a74617c..6f67a1a 100644 --- a/histou/grafana/dashboard/dashboardinfluxdb.php +++ b/histou/grafana/dashboard/dashboardinfluxdb.php @@ -26,9 +26,9 @@ class DashboardInfluxDB extends Dashboard @param string $title name of the dashboard. @return null **/ - public function __construct($title, $sharedCrosshair) + public function __construct($title) { - parent::__construct($title,$sharedCrosshair); + parent::__construct($title); } public function addAnnotation($name, $query, $title, $text, $tags, $iconColor = '#751975', $lineColor = '#751975', $datasource = INFLUXDB_DB, $enabled = SHOW_ANNOTATION, $iconSize = 13) diff --git a/templates/default/check_sakuli.php b/templates/default/check_sakuli.php index edc5ada..b4d20c4 100644 --- a/templates/default/check_sakuli.php +++ b/templates/default/check_sakuli.php @@ -19,8 +19,9 @@ $genTemplate = function ($perfData) { $caseColors = array ('#DEEBF7','#C6DBEF','#9ECAE1','#6BAED6','#4292C6','#2171B5','#08519C','#08306B'); $stepColors = array ('#9E0142','#D53E4F','#F46D43','#FDAE61','#FEE08B','#E6F598','#ABDDA4','#66C2A5','#3288BD','#5E4FA2'); - - $dashboard = \histou\grafana\dashboard\DashboardFactory::generateDashboard($perfData['host'].' '.$perfData['service'], true); + + $dashboard = \histou\grafana\dashboard\DashboardFactory::generateDashboard($perfData['host'].' '.$perfData['service']); + $dashboard->setSharedCrosshair(true); $dashboard->addDefaultAnnotations($perfData['host'], $perfData['service']); $dashboard->addAnnotation( "errors", @@ -69,8 +70,8 @@ continue; } } - - + + //Suite Row $suiteRow = new \histou\grafana\Row("Suite-Runtime"); //Suite Panel @@ -101,9 +102,9 @@ $suiteStat->addRangeToTextElement(1.5, 2.5, 'Crit'); $suiteStat->addRangeToTextElement(2.5, 3.5, 'Unkn'); $suiteRow->addPanel($suiteStat); - + $dashboard->addRow($suiteRow); - + //Case Row $caseRow = new \histou\grafana\Row("Case-Runtime"); $caseRow->setCustomProperty("repeat", $templateName); @@ -145,7 +146,7 @@ $c = ($c + 1) % (sizeof($stepColors) - 1); } $caseRow->addPanel($casePanel); - + //Case Stat Panel $caseStat = \histou\grafana\singlestatpanel\SinglestatPanelFactory::generatePanel(""); $caseStat->setSpan(1); @@ -157,8 +158,8 @@ $caseStat->addRangeToTextElement(1.5, 2.5, 'Crit'); $caseStat->addRangeToTextElement(2.5, 3.5, 'Unkn'); $caseRow->addPanel($caseStat); - + $dashboard->addRow($caseRow); - + return $dashboard; };