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

Method CustomVariablesAccessor

lib/livestatus/hoststable.cpp:1058–1087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1056}
1057
1058Value HostsTable::CustomVariablesAccessor(const Value& row)
1059{
1060 Host::Ptr host = static_cast<Host::Ptr>(row);
1061
1062 if (!host)
1063 return Empty;
1064
1065 Dictionary::Ptr vars = host->GetVars();
1066
1067 ArrayData result;
1068
1069 if (vars) {
1070 ObjectLock olock(vars);
1071 for (const Dictionary::Pair& kv : vars) {
1072 Value val;
1073
1074 if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
1075 val = JsonEncode(kv.second);
1076 else
1077 val = kv.second;
1078
1079 result.push_back(new Array({
1080 kv.first,
1081 val
1082 }));
1083 }
1084 }
1085
1086 return new Array(std::move(result));
1087}
1088
1089Value HostsTable::CVIsJsonAccessor(const Value& row)
1090{

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.80

Tested by

no test coverage detected