Esempio n. 1
0
require_once 'histou/template.php';
require_once 'histou/folder.php';
require_once 'histou/database.php';
require_once 'histou/debug.php';
require_once 'histou/dashboard.php';
//Set path to config file
parsIni('histou.ini');
header("access-control-allow-origin: *");
//Disable warnings
//error_reporting(E_ALL ^ E_WARNING);
//error_reporting(0);
ini_set('default_socket_timeout', DEFAULT_SOCKET_TIMEOUT);
parsArgs();
define("INFLUX_QUERY", sprintf("show series from /%s%s%s.*/", str_replace("/", '\\/', HOST), INFLUX_FIELDSEPERATOR, str_replace('/', '\\/', SERVICE)));
// database load perfdata
$influx = new Influxdb(INFLUX_URL);
$request = $influx->makeRequest(INFLUX_QUERY);
$perfData = $influx->filterPerfdata($request, HOST, SERVICE, '\\' . INFLUX_FIELDSEPERATOR);
$perfDataSize = sizeof($perfData);
if ($perfDataSize < 4) {
    if ($perfDataSize == 1) {
        returnData(Debug::errorMarkdownDashboard('#Influxdb Error: ' . $perfData[0] . ' Query: ' . INFLUX_QUERY), 1);
    } else {
        returnData(Debug::errorMarkdownDashboard('#Host / Service not found in Influxdb'), 1);
    }
}
// load templates
$templates = Folder::loadFolders(array(CUSTOM_TEMPLATE_FOLDER, DEFAULT_TEMPLATE_FOLDER));
Rule::setCheck($perfData['host'], $perfData['service'], $perfData['command'], array_keys($perfData['perfLabel']));
usort($templates, 'Template::compare');
$valid = $templates[0]->isValid();
Esempio n. 2
0
 /**
     Sort function for PerformanceLabels.
     @param string $firstLabel  first.
     @param string $secondLabel second.
     @return int
     **/
 private static function _comparePerfLabel($firstLabel, $secondLabel)
 {
     $first = Influxdb::_getPerfLabelIndex($firstLabel);
     $second = Influxdb::_getPerfLabelIndex($secondLabel);
     if ($first == $second) {
         return 0;
     }
     return $first < $second ? -1 : 1;
 }