Esempio n. 1
0
 public function testFilterPerfdata()
 {
     define('HOST', 'localhost.localdomain');
     define('SERVICE', 'load');
     $elastic = new \histou\database\Elasticsearch('url');
     $perfData = $elastic->filterPerfdata(json_decode($this->elasticResult, true), HOST, SERVICE);
     $this->assertSame(HOST, $perfData['host']);
     $this->assertSame(SERVICE, $perfData['service']);
     $this->assertSame('load', $perfData['command']);
     $this->assertSame(3, sizeof($perfData['perfLabel']));
     $error = $elastic->filterPerfdata(json_decode($this->emptyResult, true), HOST, SERVICE);
     $this->assertSame("No data found", $error);
     $error = $elastic->filterPerfdata(json_decode($this->timeout, true), HOST, SERVICE);
     $this->assertSame("Timedout", $error);
 }
Esempio n. 2
0
if (!\histou\Basic::$disablePerfdataLookup) {
    // database load perfdata
    $database = null;
    if (DATABASE_TYPE == INFLUXDB) {
        $database = new \histou\database\Influxdb(URL);
    } elseif (DATABASE_TYPE == ELASTICSEARCH) {
        $database = new \histou\database\Elasticsearch(URL);
    } else {
        \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# Unsupported database'), 1);
    }
    $request = $database->fetchPerfData();
    if (empty($request)) {
        \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# Database not reachable or empty result'), 1);
        exit(0);
    }
    $perfData = $database->filterPerfdata($request, HOST, SERVICE);
    $perfDataSize = sizeof($perfData);
    if ($perfDataSize < 4) {
        if ($perfDataSize == 1) {
            \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# Database Error: ' . $perfData), 1);
            exit(1);
        } else {
            \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# Host / Service not found in Database'), 1);
            exit(1);
        }
    }
}
// load templates
$templateFiles = \histou\Folder::loadFolders(array(CUSTOM_TEMPLATE_FOLDER, DEFAULT_TEMPLATE_FOLDER));
$templateCache = new \histou\template\cache('templates');
$templates = $templateCache->loadTemplates($templateFiles, '\\histou\\template\\loader::loadTemplate');