public function init() { $_GET['host'] = 'host'; \histou\Basic::parsIni('histou.ini.example'); \histou\Basic::parsArgs(); }
public static function testConfig() { //test php command $cmd = static::$phpCommand . " -h 2>&1"; $process = proc_open($cmd, \histou\Basic::$descriptorSpec, $pipes); if (!is_resource($process)) { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard("# Error: Could not start: {$cmd}")); // @codeCoverageIgnore return 1; // @codeCoverageIgnore } stream_get_contents($pipes[1]); fclose($pipes[1]); $returnCode = proc_close($process); if ($returnCode != 0) { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard("# '" . $cmd . "' did not return with returncode 0. Maybe the phpCommand is not set properly."), 1); return 1; } return 0; }
public function testReturnData() { $this->init(); \histou\Debug::enable(); $dashboard = new \histou\grafana\dashboard\DashboardInfluxDB('foo'); ob_start(); \histou\Basic::returnData($dashboard); $out1 = ob_get_contents(); ob_end_clean(); $this->assertSame($this->emptyDashboard, $out1); $_GET["callback"] = 1; ob_start(); \histou\Basic::returnData('{"foo":"bar"}'); $out2 = ob_get_contents(); ob_end_clean(); $this->assertSame('1({"foo":"bar"})', $out2); ob_start(); \histou\Basic::returnData(1); $out3 = ob_get_contents(); ob_end_clean(); $this->assertContains("<pre>Don't know what to do with this type: integer", $out3); }
protected function setUp() { spl_autoload_register('__autoload'); \histou\Basic::parsIni('histou.ini.example'); }
public function init() { $_GET['host'] = 'host'; \histou\Basic::parsArgs(); }
foreach ($forecastTemplates as $ftemplate) { \histou\Debug::add($ftemplate); } \histou\Debug::add("Is the first ForecastTemplate valid: " . \histou\Debug::printBoolean($fValid) . "\n"); if ($fValid) { $forecastTemplate = $forecastTemplates[0]; $className = get_class($forecastTemplate); if ($className == 'histou\\template\\Rule') { $forecast = \histou\template\loader::loadForecastTemplate($forecastTemplate->getFileName(), true); } if (isset($forecast)) { $forecast->setForecastDurations(); } } if (isset($template) && !empty($template)) { $className = get_class($template); if ($className == 'histou\\template\\Rule') { $dashboard = \histou\template\loader::loadTemplate($template->getFileName(), true)->generateDashboard($perfData); } elseif ($className == 'histou\\template\\Template' || $className == 'histou\\template\\SimpleTemplate') { $dashboard = $template->generateDashboard($perfData); } else { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard("# unkown class {$className}"), 1); } if ($dashboard == null) { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# Template did not return a dashboard!'), 1); } else { \histou\Basic::returnData($dashboard, 0); } } else { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# No template found!'), 1); }
@author Philip Griesbacher <*****@*****.**> @license http://opensource.org/licenses/gpl-license.php GNU Public License @link https://github.com/Griesbacher/histou **/ require_once 'histou/bootstrap.php'; set_error_handler(function ($errno, $errstr, $errfile, $errline, array $errcontext) { // error was suppressed with the @-operator if (0 === error_reporting()) { return false; } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }); //Set path to config file \histou\Basic::parsIni('histou.ini'); //Parse commandline and get parameter \histou\Basic::parsArgs(); // load ForecastTemplates $forecastTemplateFiles = \histou\Folder::loadFolders(array(FORECAST_TEMPLATE_FOLDER)); $forcastTemplateCache = new \histou\template\cache('cli'); $forecastTemplates = $forcastTemplateCache->loadTemplates($forecastTemplateFiles, '\\histou\\template\\loader::loadForecastTemplate'); if (\histou\Basic::$request) { $result = "["; foreach (\histou\Basic::$request as $index => $value) { \histou\template\Rule::setCheck($value['host'], $value['service'], $value['command'], $value['perf_labels']); usort($forecastTemplates, '\\histou\\template\\Template::compare'); $fValid = $forecastTemplates[0]->isValid(); \histou\Debug::add("ForecastTemplate order:"); foreach ($forecastTemplates as $ftemplate) { \histou\Debug::add($ftemplate); } \histou\Debug::add("Is the first ForecastTemplate valid: " . \histou\Debug::printBoolean($fValid) . "\n");