Exemple #1
0
 public function testInvalidDatabase()
 {
     define('INFLUXDB', 'influxdb');
     define('ELASTICSEARCH', 'elasticsearch');
     define("DATABASE_TYPE", 'foo');
     define("ELASTICSEARCH_INDEX", 'bar');
     $this->setExpectedException('\\InvalidArgumentException');
     $d = \histou\grafana\dashboard\DashboardFactory::generateDashboard('d1');
 }
 public function testAddDefaultAnnotations()
 {
     define("ELASTICSEARCH_INDEX", 'nagflux');
     define("DATABASE_TYPE", 'elasticsearch');
     define('INFLUXDB', 'influxdb');
     define('ELASTICSEARCH', 'elasticsearch');
     define('SHOW_ANNOTATION', true);
     $d = \histou\grafana\dashboard\DashboardFactory::generateDashboard('d1');
     //This should do nothing at the moment
     $d->addDefaultAnnotations('name', 'hostname');
     $this->assertSame($d, $d);
 }
 public function testToArrayInfluxdb()
 {
     define("INFLUXDB_DB", 'nagflux');
     define("DATABASE_TYPE", 'influxdb');
     define('INFLUXDB', 'influxdb');
     define('ELASTICSEARCH', 'elasticsearch');
     define('HEIGHT', '100');
     define('SHOW_LEGEND', true);
     define('FORECAST_DATASOURCE_NAME', "nagflux_forecast");
     $d = \histou\grafana\dashboard\DashboardFactory::generateDashboard('d');
     $row = new \histou\grafana\Row("r");
     $gpanel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel("p");
     \histou\template\ForecastTemplate::$config = array('size' => array('method' => 'SimpleLinearRegression', 'forecast' => '20m'), 'time' => array('method' => 'SimpleLinearRegression', 'forecast' => '30m'));
     $target = $gpanel->genForecastTarget('host', 'service', 'command', 'size', '000', '', true, true);
     $target = $gpanel->genForecastTarget('host', 'service', 'command', 'time', '000', '', true, true);
     $a = $d->toArray();
     $expected = array('id' => '1', 'title' => 'd', 'originalTitle' => 'CustomDashboard', 'tags' => array(), 'timezone' => 'browser', 'editable' => true, 'hideControls' => true, 'sharedCrosshair' => false, 'nav' => array(array('type' => 'timepicker', 'enable' => true, 'time_options' => array(0 => '5m', 1 => '15m', 2 => '1h', 3 => '6h', 4 => '12h', 5 => '24h', 6 => '2d', 7 => '7d', 8 => '30d'), 'refresh_intervals' => array(0 => '5s', 1 => '10s', 2 => '30s', 3 => '1m', 4 => '5m', 5 => '15m', 6 => '30m', 7 => '1h', 8 => '2h', 9 => '1d'), 'now' => true, 'collapse' => false, 'notice' => false)), 'time' => array('from' => 'now-8h', 'to' => 'now+30m'), 'templating' => array('list' => array()), 'annotations' => array('enable' => true, 'list' => array()), 'refresh' => '30s', 'version' => '6', 'rows' => array());
     $this->assertSame($expected, $a);
 }
<?php

/**
This template is used for check_mssql_health mode: database-free.
PHP version 5
@category Template_File
@package Histou/templates/default
@author Philip Griesbacher <*****@*****.**>
@license http://opensource.org/licenses/gpl-license.php GNU Public License
@link https://github.com/Griesbacher/histou
**/
$rule = new \histou\template\Rule($host = '.*', $service = '.*', $command = '.*', $perfLabel = array('^db_(.*?)(_log)?_((free)(_pct)?|(allocated_pct))$'));
$genTemplate = function ($perfData) {
    $colors = array('#085DFF', '#07ff78', "#BA43A9", "#C15C17");
    $dashboard = \histou\grafana\dashboard\DashboardFactory::generateDashboard($perfData['host'] . '-' . $perfData['service']);
    $dashboard->addDefaultAnnotations($perfData['host'], $perfData['service']);
    $templateName = 'Database';
    $dashboard->addTemplateForPerformanceLabel($templateName, $perfData['host'], $perfData['service'], $regex = '^db_(.*?)_log_free$', $multiFormat = true, $includeAll = false);
    $tempalteVariableString = $dashboard->genTemplateVariable($templateName);
    $database = "";
    foreach ($perfData['perfLabel'] as $key => $value) {
        if (preg_match(';^db_(.*?)_log_free$;', $key, $hit)) {
            $database = $key;
            break;
        }
    }
    $types = array('pct' => array("free_pct", "allocated_pct", "log_free_pct", "log_allocated_pct"), 'fix' => array("free", "log_free"));
    $numberPanels = 0;
    $row = new \histou\grafana\Row($perfData['service'] . ' ' . $perfData['command']);
    foreach ($types as $type => $labels) {
        $panel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel($perfData['service'] . " {$tempalteVariableString} " . $type);
Exemple #5
0
 /**
     Creates a new Markdown dashboard.
     @param string $message contains the body.
     @return object
     **/
 public static function errorMarkdownDashboard($message)
 {
     $dashboard = \histou\grafana\dashboard\DashboardFactory::generateDashboard('Error');
     $dashboard->addRow(static::genRow($message, \histou\grafana\TextPanel::MARKDOWN, 'ERROR'));
     return $dashboard;
 }