Beispiel #1
0
 public function testCreatePanel()
 {
     $row = new \histou\grafana\Row('r1', '100px');
     $this->assertSame('r1', $row->toArray()['title']);
     $row->setEditable(false);
     $this->assertSame(false, $row->toArray()['editable']);
     $row->setCustomProperty('foo', 'bar');
     $this->assertSame('bar', $row->toArray()['foo']);
 }
    foreach ($types as $type => $labels) {
        $panel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel($perfData['service'] . " {$tempalteVariableString} " . $type);
        $panel->setSpan(6);
        if ($type == 'fix' && isset($perfData['perfLabel'][$database]['unit'])) {
            $panel->setLeftUnit($perfData['perfLabel'][$database]['unit']);
        } elseif ($type == 'pct') {
            $panel->setLeftUnit('%');
        }
        $currentColorIndex = 0;
        foreach ($labels as $label) {
            if (DATABASE_TYPE == ELASTICSEARCH) {
                //https://github.com/grafana/grafana/issues/4075
                $perfLabel = "db_" . $tempalteVariableString . "\\_" . $label;
            } else {
                $perfLabel = "db_" . $tempalteVariableString . "_" . $label;
            }
            $target = $panel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], $perfLabel);
            $panel->addTarget($panel->genDowntimeTarget($perfData['host'], $perfData['service'], $perfData['command'], $perfLabel));
            $target = $panel->addWarnToTarget($target, $perfLabel, false);
            $target = $panel->addCritToTarget($target, $perfLabel, false);
            $panel->addTarget($target);
            $panel->addRegexColor("/^db_.*?_{$label}-value\$/", $colors[$currentColorIndex++]);
        }
        $panel->addRegexColor('/^db_.*?-warn-?(min|max)?$/', '#FFFC15');
        $panel->addRegexColor('/^db_.*?-crit-?(min|max)?$/', '#FF3727');
        $row->addPanel($panel);
    }
    $row->setCustomProperty("repeat", $templateName);
    $dashboard->addRow($row);
    return $dashboard;
};
Beispiel #3
0
    foreach ($overviewData as $label => $data) {
        $statesPanel->addTarget($statesPanel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], "check_multi_extended::check_multi_extended::{$label}", $data[0], $data[1]));
    }
    $statesPanel->addTarget($statesPanel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], "check_multi::check_multi::plugins", '#085DFF', "Plugins"));
    $statesPanel->setSpan(11);
    $statesPanel->setLeftYAxisMinMax(0);
    $statesRow->addPanel($statesPanel);
    $overallState = \histou\grafana\singlestatpanel\SinglestatPanelFactory::generatePanel("");
    $overallState->setSpan(1);
    $overallState->addTarget($overallState->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], 'check_multi_extended::check_multi_extended::overall_state'));
    $overallState->setColor(array('#99ff66', '#ffc125', '#ee0000'));
    $overallState->setThresholds("1", "2");
    $overallState->addRangeToTextElement(0, 0.5, 'OK');
    $overallState->addRangeToTextElement(0.5, 1.5, 'Warn');
    $overallState->addRangeToTextElement(1.5, 2.5, 'Crit');
    $overallState->addRangeToTextElement(2.5, 3.5, 'Unkn');
    $statesRow->addPanel($overallState);
    $dashboard->addRow($statesRow);
    $row = new \histou\grafana\Row($tempalteVariableStringPerfLabel);
    $panel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel($tempalteVariableStringPerfLabel);
    $target = $panel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], $tempalteVariableStringPerfLabel);
    $target = $panel->addWarnToTarget($target, $tempalteVariableStringPerfLabel);
    $target = $panel->addCritToTarget($target, $tempalteVariableStringPerfLabel);
    $panel->addTarget($target);
    $downtime = $panel->genDowntimeTarget($perfData['host'], $perfData['service'], $perfData['command'], $tempalteVariableStringPerfLabel);
    $panel->addTarget($downtime);
    $row->addPanel($panel);
    $row->setCustomProperty("repeat", $templateNamePerfLabel);
    $dashboard->addRow($row);
    return $dashboard;
};