]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Fix modified custom attribute update query problems
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 24 Sep 2015 09:45:44 +0000 (11:45 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 24 Sep 2015 09:45:44 +0000 (11:45 +0200)
fixes #10190

lib/db_ido/dbconnection.cpp
lib/db_ido/dbobject.cpp

index eca07b8027dba70b423c17bda4a601d73b856f8b..ad7153f11fdd1dfecd725e9bc169db249ab611dd 100644 (file)
@@ -171,36 +171,6 @@ void DbConnection::ProgramStatusHandler(void)
        InsertRuntimeVariable("total_scheduled_services", std::distance(ConfigType::GetObjectsByType<Service>().first, ConfigType::GetObjectsByType<Service>().second));
        InsertRuntimeVariable("total_hosts", std::distance(ConfigType::GetObjectsByType<Host>().first, ConfigType::GetObjectsByType<Host>().second));
        InsertRuntimeVariable("total_scheduled_hosts", std::distance(ConfigType::GetObjectsByType<Host>().first, ConfigType::GetObjectsByType<Host>().second));
-
-       Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
-
-       if (!vars)
-               return;
-
-       Log(LogDebug, "DbConnection", "Dumping global vars for icinga application");
-
-       ObjectLock olock(vars);
-
-       BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
-               if (!kv.first.IsEmpty()) {
-                       Log(LogDebug, "DbConnection")
-                           << "icinga application customvar key: '" << kv.first << "' value: '" << kv.second << "'";
-
-                       Dictionary::Ptr fields4 = new Dictionary();
-                       fields4->Set("varname", Convert::ToString(kv.first));
-                       fields4->Set("varvalue", Convert::ToString(kv.second));
-                       fields4->Set("config_type", 1);
-                       fields4->Set("has_been_modified", 0);
-                       fields4->Set("instance_id", 0); /* DbConnection class fills in real ID */
-
-                       DbQuery query4;
-                       query4.Table = "customvariables";
-                       query4.Type = DbQueryInsert;
-                       query4.Category = DbCatConfig;
-                       query4.Fields = fields4;
-                       DbObject::OnQuery(query4);
-               }
-       }
 }
 
 void DbConnection::CleanUpHandler(void)
index 3cb2470563b31c101fa92df7b977147565f43075..c1aebbcb913ff3d5f66952b99aabb138a054e7be 100644 (file)
@@ -198,9 +198,15 @@ void DbObject::SendVarsConfigUpdate(void)
 
                        DbQuery query;
                        query.Table = "customvariables";
-                       query.Type = DbQueryInsert;
+                       query.Type = DbQueryInsert | DbQueryUpdate;
                        query.Category = DbCatConfig;
                        query.Fields = fields;
+
+                       query.WhereCriteria = new Dictionary();
+                       query.WhereCriteria->Set("object_id", obj);
+                       query.WhereCriteria->Set("varname", kv.first);
+                       query.Object = this;
+
                        OnQuery(query);
                }
        }
@@ -259,7 +265,7 @@ void DbObject::SendVarsStatusUpdate(void)
 
                        query.WhereCriteria = new Dictionary();
                        query.WhereCriteria->Set("object_id", obj);
-                       query.WhereCriteria->Set("varname", Convert::ToString(kv.first));
+                       query.WhereCriteria->Set("varname", kv.first);
                        query.Object = this;
 
                        OnQuery(query);