MCPcopy Create free account
hub / github.com/Icinga/icinga2 / SendVarsStatusUpdate

Method SendVarsStatusUpdate

lib/db_ido/dbobject.cpp:294–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void DbObject::SendVarsStatusUpdate()
295{
296 ConfigObject::Ptr obj = GetObject();
297
298 CustomVarObject::Ptr custom_var_object = dynamic_pointer_cast<CustomVarObject>(obj);
299
300 if (!custom_var_object)
301 return;
302
303 Dictionary::Ptr vars = custom_var_object->GetVars();
304
305 if (vars) {
306 std::vector<DbQuery> queries;
307 ObjectLock olock (vars);
308
309 for (const Dictionary::Pair& kv : vars) {
310 if (kv.first.IsEmpty())
311 continue;
312
313 String value;
314 int is_json = 0;
315
316 if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>()) {
317 value = JsonEncode(kv.second);
318 is_json = 1;
319 } else
320 value = kv.second;
321
322 DbQuery query;
323 query.Table = "customvariablestatus";
324 query.Type = DbQueryInsert | DbQueryUpdate;
325 query.Category = DbCatState;
326
327 query.Fields = new Dictionary({
328 { "varname", kv.first },
329 { "varvalue", value },
330 { "is_json", is_json },
331 { "status_update_time", DbValue::FromTimestamp(Utility::GetTime()) },
332 { "object_id", obj },
333 { "instance_id", 0 } /* DbConnection class fills in real ID */
334 });
335
336 query.WhereCriteria = new Dictionary({
337 { "object_id", obj },
338 { "varname", kv.first }
339 });
340
341 queries.emplace_back(std::move(query));
342 }
343
344 OnMultipleQueries(queries);
345 }
346}
347
348double DbObject::GetLastConfigUpdate() const
349{

Callers 1

VarsChangedHandlerMethod · 0.80

Calls 1

IsEmptyMethod · 0.45

Tested by

no test coverage detected