[icinga-checkins] icinga.org: icingaweb2/feature/setup-wizard-7163: MonitoredObject: decode structured customvars

git at icinga.org git at icinga.org
Tue Nov 11 10:19:52 CET 2014


Module: icingaweb2
Branch: feature/setup-wizard-7163
Commit: 74e60ec0f6f30ac4d388f766a5cdaf07b15dffc5
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=74e60ec0f6f30ac4d388f766a5cdaf07b15dffc5

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Nov  6 16:15:16 2014 +0100

MonitoredObject: decode structured customvars

fixes #7569

---

 .../library/Monitoring/Object/MonitoredObject.php    |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
index 36b3671..ecd1a9c 100644
--- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
+++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
@@ -283,7 +283,8 @@ abstract class MonitoredObject
 
         $query = $this->backend->select()->from('customvar', array(
             'varname',
-            'varvalue'
+            'varvalue',
+            'is_json'
         ))
             ->where('object_type', $this->type)
             ->where('host_name', $this->host_name);
@@ -293,13 +294,16 @@ abstract class MonitoredObject
 
         $this->customvars = array();
 
-        $customvars = $query->getQuery()->fetchPairs();
-        foreach ($customvars as $name => $value) {
-            $name = ucwords(str_replace('_', ' ', strtolower($name)));
-            if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
-                $value = '***';
+        $customvars = $query->getQuery()->fetchAll();
+        foreach ($customvars as $name => $cv) {
+            $name = ucwords(str_replace('_', ' ', strtolower($cv->varname)));
+            if ($blacklistPattern && preg_match($blacklistPattern, $cv->varname)) {
+                $this->customvars[$name] = '***';
+            } elseif ($cv->is_json) {
+                $this->customvars[$name] = json_decode($cv->varvalue);
+            } else {
+                $this->customvars[$name] = $cv->varvalue;
             }
-            $this->customvars[$name] = $value;
         }
 
         return $this;



More information about the icinga-checkins mailing list