mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-06-08 16:23:22 -04:00
Allow multiple templates per check command
This commit is contained in:
parent
94345381ba
commit
6be7a01cec
2 changed files with 7 additions and 14 deletions
|
|
@ -85,8 +85,8 @@ class Templates
|
|||
*/
|
||||
public function loadIni($path)
|
||||
{
|
||||
/** @var string[][][] $rawTemplates */
|
||||
$rawTemplates = [];
|
||||
/** @var string[][][] $templates */
|
||||
$templates = [];
|
||||
|
||||
foreach (Config::fromIni($path) as $section => $options) {
|
||||
/** @var ConfigObject $options */
|
||||
|
|
@ -96,13 +96,10 @@ class Templates
|
|||
throw new ConfigurationError('Bad section name "%s" in file "%s"', $section, $path);
|
||||
}
|
||||
|
||||
$rawTemplates[$matches[1]][$matches[2]] = $options->toArray();
|
||||
$templates[$matches[1]][$matches[2]] = $options->toArray();
|
||||
}
|
||||
|
||||
/** @var Template[] $templates */
|
||||
$templates = [];
|
||||
|
||||
foreach ($rawTemplates as $templateName => $template) {
|
||||
foreach ($templates as $templateName => $template) {
|
||||
if (! isset($template['graph']['check_command'])) {
|
||||
throw new ConfigurationError(
|
||||
'Icinga check command for template "%s" in file "%s" missing', $templateName, $path
|
||||
|
|
@ -265,13 +262,13 @@ class Templates
|
|||
}
|
||||
}
|
||||
|
||||
$templates[$checkCommand] = (new Template())
|
||||
$templates[$templateName] = (new Template())
|
||||
->setCurves($curves)
|
||||
->setUrlParams($urlParams);
|
||||
}
|
||||
|
||||
foreach ($templates as $checkCommand => $template) {
|
||||
$this->templates[$checkCommand] = $template;
|
||||
foreach ($templates as $templateName => $template) {
|
||||
$this->templates[$templateName] = $template;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -137,10 +137,6 @@ abstract class Graphs extends AbstractWidget
|
|||
}
|
||||
|
||||
$result[] = '</div>';
|
||||
|
||||
// A monitored object has only one check command per definition of Icinga 2.
|
||||
// And there is at most one graph template per check command per our definition.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue