monitoring: Normalize custom variable names not until they're displayed

This commit is contained in:
Johannes Meyer 2015-09-30 13:23:54 +02:00
parent 13575eb962
commit 62d96a154e
3 changed files with 7 additions and 6 deletions

View File

@ -10,7 +10,7 @@ foreach ($object->customvars as $name => $value) {
printf(
'<tr><th>%s</th><td class="customvar">%s</td></tr>' . "\n",
$this->escape($name),
$this->escape(ucwords(str_replace('_', ' ', strtolower($name)))),
$this->customvar($value)
);
}

View File

@ -60,8 +60,9 @@ class Macro
if (isset(self::$icingaMacros[$macro]) && isset($object->{self::$icingaMacros[$macro]})) {
return $object->{self::$icingaMacros[$macro]};
}
if (isset($object->customvars[$macro])) {
return $object->customvars[$macro];
$customVar = strtolower($macro);
if (isset($object->customvars[$customVar])) {
return $object->customvars[$customVar];
}
return $macro;

View File

@ -239,7 +239,7 @@ abstract class MonitoredObject implements Filterable
foreach ($this->customvars as $name => $value) {
if (! is_object($value)) {
$row->{'_' . $this->getType() . '_' . strtolower(str_replace(' ', '_', $name))} = $value;
$row->{'_' . $this->getType() . '_' . $name} = $value;
}
}
}
@ -477,8 +477,8 @@ abstract class MonitoredObject implements Filterable
$this->customvars = array();
$customvars = $query->getQuery()->fetchAll();
foreach ($customvars as $name => $cv) {
$name = ucwords(str_replace('_', ' ', strtolower($cv->varname)));
foreach ($customvars as $cv) {
$name = strtolower($cv->varname);
if ($blacklistPattern && preg_match($blacklistPattern, $cv->varname)) {
$this->customvars[$name] = '***';
} elseif ($cv->is_json) {