[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaService: enum service vars, not host vars

git at icinga.org git at icinga.org
Wed Nov 30 09:34:02 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: 7dd2ac6b83ebb83ed140542572dccb84f950d0ad
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=7dd2ac6b83ebb83ed140542572dccb84f950d0ad

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Nov 30 09:33:29 2016 +0100

IcingaService: enum service vars, not host vars

fixes #13359

---

 library/Director/Db.php                    |   19 +++++++++++++++++++
 library/Director/Objects/IcingaService.php |    2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/library/Director/Db.php b/library/Director/Db.php
index 703d6e4..bec0de3 100644
--- a/library/Director/Db.php
+++ b/library/Director/Db.php
@@ -632,6 +632,25 @@ class Db extends DbConnection
         return $this->db()->fetchAll($select);
     }
 
+    public function fetchDistinctServiceVars()
+    {
+        $select = $this->db()->select()->distinct()->from(
+            array('sv' => 'icinga_service_var'),
+            array(
+                'varname'  => 'sv.varname',
+                'format'   => 'sv.format',
+                'caption'  => 'df.caption',
+                'datatype' => 'df.datatype'
+            )
+        )->joinLeft(
+            array('df' => 'director_datafield'),
+            'df.varname = sv.varname',
+            array()
+        )->order('varname');
+
+        return $this->db()->fetchAll($select);
+    }
+
     public function dbHexFunc($column)
     {
         if ($this->isPgsql()) {
diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php
index 9e6a90f..7564f4b 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -435,7 +435,7 @@ class IcingaService extends IcingaObject
         $serviceVars = array();
 
         if ($connection !== null) {
-            foreach ($connection->fetchDistinctHostVars() as $var) {
+            foreach ($connection->fetchDistinctServiceVars() as $var) {
                 if ($filter->match(PropertiesFilter::$CUSTOM_PROPERTY, $var->varname, $var)) {
                     if ($var->datatype) {
                         $serviceVars[$prefix . 'vars.' . $var->varname] = sprintf(



More information about the icinga-checkins mailing list