mirror of https://github.com/Icinga/icinga2.git
DB IDO: Fix modified custom attribute update query problems
fixes #10190
This commit is contained in:
parent
0b4a176b25
commit
f0bdd4cf21
|
@ -167,36 +167,6 @@ void DbConnection::ProgramStatusHandler(void)
|
||||||
InsertRuntimeVariable("total_scheduled_services", std::distance(DynamicType::GetObjectsByType<Service>().first, DynamicType::GetObjectsByType<Service>().second));
|
InsertRuntimeVariable("total_scheduled_services", std::distance(DynamicType::GetObjectsByType<Service>().first, DynamicType::GetObjectsByType<Service>().second));
|
||||||
InsertRuntimeVariable("total_hosts", std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::GetObjectsByType<Host>().second));
|
InsertRuntimeVariable("total_hosts", std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::GetObjectsByType<Host>().second));
|
||||||
InsertRuntimeVariable("total_scheduled_hosts", std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::GetObjectsByType<Host>().second));
|
InsertRuntimeVariable("total_scheduled_hosts", std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::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)
|
void DbConnection::CleanUpHandler(void)
|
||||||
|
|
|
@ -195,9 +195,15 @@ void DbObject::SendVarsConfigUpdate(void)
|
||||||
|
|
||||||
DbQuery query;
|
DbQuery query;
|
||||||
query.Table = "customvariables";
|
query.Table = "customvariables";
|
||||||
query.Type = DbQueryInsert;
|
query.Type = DbQueryInsert | DbQueryUpdate;
|
||||||
query.Category = DbCatConfig;
|
query.Category = DbCatConfig;
|
||||||
query.Fields = fields;
|
query.Fields = fields;
|
||||||
|
|
||||||
|
query.WhereCriteria = new Dictionary();
|
||||||
|
query.WhereCriteria->Set("object_id", obj);
|
||||||
|
query.WhereCriteria->Set("varname", kv.first);
|
||||||
|
query.Object = this;
|
||||||
|
|
||||||
OnQuery(query);
|
OnQuery(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +262,7 @@ void DbObject::SendVarsStatusUpdate(void)
|
||||||
|
|
||||||
query.WhereCriteria = new Dictionary();
|
query.WhereCriteria = new Dictionary();
|
||||||
query.WhereCriteria->Set("object_id", obj);
|
query.WhereCriteria->Set("object_id", obj);
|
||||||
query.WhereCriteria->Set("varname", Convert::ToString(kv.first));
|
query.WhereCriteria->Set("varname", kv.first);
|
||||||
query.Object = this;
|
query.Object = this;
|
||||||
|
|
||||||
OnQuery(query);
|
OnQuery(query);
|
||||||
|
|
Loading…
Reference in New Issue