Skip to content

Commit

Permalink
changed crosshair from constructor to setter
Browse files Browse the repository at this point in the history
  • Loading branch information
Griesbacher committed Oct 20, 2017
1 parent 2a3fec6 commit ed6150c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
15 changes: 12 additions & 3 deletions histou/grafana/dashboard/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions histou/grafana/dashboard/dashboardelasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions histou/grafana/dashboard/dashboardfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
4 changes: 2 additions & 2 deletions histou/grafana/dashboard/dashboardinfluxdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 10 additions & 9 deletions templates/default/check_sakuli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -69,8 +70,8 @@
continue;
}
}


//Suite Row
$suiteRow = new \histou\grafana\Row("Suite-Runtime");
//Suite Panel
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
};

0 comments on commit ed6150c

Please sign in to comment.