/**
     This creates a target with an value.
     **/
 public function genTargetSimple($host, $service, $command, $performanceLabel, $useRegex = false)
 {
     if ($useRegex) {
         $target = $this->createTarget(array('host' => array('value' => \histou\helper\str::genRegex($host), 'operator' => '=~'), 'service' => array('value' => \histou\helper\str::genRegex($service), 'operator' => '=~'), 'command' => array('value' => \histou\helper\str::genRegex($command), 'operator' => '=~'), 'performanceLabel' => array('value' => \histou\helper\str::genRegex($performanceLabel), 'operator' => '=~')));
     } else {
         $target = $this->createTarget(array('host' => array('value' => $host), 'service' => array('value' => $service), 'command' => array('value' => $command), 'performanceLabel' => array('value' => $performanceLabel)));
     }
     return $this->addXToTarget($target, array('value'));
 }
Exemple #2
0
 //Case Row
 $caseRow = new \histou\grafana\Row("Case-Runtime");
 $caseRow->setCustomProperty("repeat", $templateName);
 //Case Graph Panel
 $casePanel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel($perfData['service'] . " (Sakuli case #{$templateVariableString}) on " . $perfData['host']);
 $casePanel->setLeftUnit("s");
 $casePanel->setSpan(11);
 $casePanel->setLeftYAxisMinMax(0);
 $casePanel->fillBelowLine("/^(?!warning|critical).*\$/", 5);
 $casePanel->setLegend(true, true, true, true, false, false, true, true, true, true);
 $target1 = $casePanel->createTarget(array('host' => array('value' => $perfData['host'], 'operator' => '='), 'service' => array('value' => $perfData['service'], 'operator' => '='), 'command' => array('value' => $perfData['command'], 'operator' => '='), 'performanceLabel' => array('value' => \histou\helper\str::genRegex('c_' . $templateVariableString . '_[^_].*'), 'operator' => '=~')));
 $target1 = $casePanel->addXToTarget($target1, array('value'), '', '');
 $target1['alias'] = '$tag_performanceLabel';
 $target1['groupBy'] = array(array("params" => array("\$interval"), "type" => "time"), array("params" => array("performanceLabel"), "type" => "tag"), array("params" => array("null"), "type" => "fill"));
 $casePanel->addTarget($target1);
 $target = $casePanel->createTarget(array('host' => array('value' => $perfData['host'], 'operator' => '='), 'service' => array('value' => $perfData['service'], 'operator' => '='), 'command' => array('value' => $perfData['command'], 'operator' => '='), 'performanceLabel' => array('value' => \histou\helper\str::genRegex('s_' . $templateVariableString . '.*'), 'operator' => '=~')));
 $target = $casePanel->addXToTarget($target, array('value'), '', '');
 $target['alias'] = '$tag_performanceLabel';
 $target['groupBy'] = array(array("params" => array("\$interval"), "type" => "time"), array("params" => array("performanceLabel"), "type" => "tag"), array("params" => array("null"), "type" => "fill"));
 $casePanel->addTarget($target);
 $casePanel->stack('/s_\\d\\d\\d_.*/');
 $casePanel->addTarget($casePanel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], "c_{$templateVariableString}" . "__warning", '#FFFC15', 'warning'));
 $casePanel->addTarget($casePanel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], "c_{$templateVariableString}" . "__critical", '#FF3727', 'critical'));
 $c = 0;
 for ($i = 0; $i < $maxSteps; $i++) {
     $casePanel->addRegexColor(sprintf('/s_\\d\\d\\d_%03d_.*/', $i), $stepColors[$c]);
     $c = ($c + 1) % (sizeof($stepColors) - 1);
 }
 $caseRow->addPanel($casePanel);
 //Case Stat Panel
 $caseStat = \histou\grafana\singlestatpanel\SinglestatPanelFactory::generatePanel("");
 /**
     This creates a target for an forecast.
     @return Returns a target if a forcast config exists, null otherwise.
     **/
 public function genForecastTarget($host, $service, $command, $performanceLabel, $color = '#000', $alias = '', $useRegex = false, $addMethodToName = false)
 {
     $forecastConfig = \histou\template\ForecastTemplate::$config;
     if (!$forecastConfig || !array_key_exists($performanceLabel, $forecastConfig)) {
         return null;
     }
     array_push(\histou\grafana\dashboard\Dashboard::$forecast, $forecastConfig[$performanceLabel]['forecast']);
     if ($alias == '') {
         $alias = $performanceLabel . '-forecast';
     }
     if ($addMethodToName) {
         $alias .= '-' . $forecastConfig[$performanceLabel]['method'];
     }
     if ($useRegex) {
         $target = $this->createTarget(array('host' => array('value' => \histou\helper\str::genRegex($host), 'operator' => '=~'), 'service' => array('value' => \histou\helper\str::genRegex($service), 'operator' => '=~'), 'performanceLabel' => array('value' => \histou\helper\str::genRegex($performanceLabel), 'operator' => '=~')), FORECAST_DATASOURCE_NAME);
     } else {
         $target = $this->createTarget(array('host' => array('value' => $host), 'service' => array('value' => $service), 'performanceLabel' => array('value' => $performanceLabel)), FORECAST_DATASOURCE_NAME);
     }
     $target = $this->addXToTarget($target, array('value'), $alias, $color, true);
     $this->addToSeriesOverrides(array('alias' => $alias, 'legend' => false, 'lines' => false, 'points' => true, 'pointradius' => 1));
     return $target;
 }