}
if (method == "push_crs") {
- Host::Ptr host = Host::GetByName(identity);
+ Dictionary::Ptr params = message->Get("params");
- if (!host) {
- Log(LogWarning, "agent", "Ignoring check results for host '" + identity + "'.");
+ if (!params)
return;
+
+ Dictionary::Ptr inventoryDescr = make_shared<Dictionary>();
+ inventoryDescr->Set("identity", identity);
+ inventoryDescr->Set("crs", params);
+
+ String inventoryFile = GetInventoryDir() + SHA256(identity);
+ String inventoryTempFile = inventoryFile + ".tmp";
+
+ std::ofstream fp(inventoryTempFile.CStr(), std::ofstream::out | std::ostream::trunc);
+ fp << JsonSerialize(inventoryDescr);
+ fp.close();
+
+#ifdef _WIN32
+ _unlink(inventoryFile.CStr());
+#endif /* _WIN32 */
+
+ if (rename(inventoryTempFile.CStr(), inventoryFile.CStr()) < 0) {
+ BOOST_THROW_EXCEPTION(posix_error()
+ << boost::errinfo_api_function("rename")
+ << boost::errinfo_errno(errno)
+ << boost::errinfo_file_name(inventoryTempFile));
}
- Dictionary::Ptr params = message->Get("params");
+ Host::Ptr host = Host::GetByName(identity);
- if (!params)
+ if (!host) {
+ Log(LogWarning, "agent", "Ignoring check results for host '" + identity + "'.");
return;
+ }
Value hostcr = Deserialize(params->Get("host"), true);
CheckResult::Ptr cr = servicecr;
service->ProcessCheckResult(cr);
}
-
- Dictionary::Ptr inventoryDescr = make_shared<Dictionary>();
- inventoryDescr->Set("identity", identity);
- inventoryDescr->Set("crs", params);
-
- String inventoryFile = GetInventoryDir() + SHA256(identity);
- String inventoryTempFile = inventoryFile + ".tmp";
-
- std::ofstream fp(inventoryTempFile.CStr(), std::ofstream::out | std::ostream::trunc);
- fp << JsonSerialize(inventoryDescr);
- fp.close();
-
-#ifdef _WIN32
- _unlink(inventoryFile.CStr());
-#endif /* _WIN32 */
-
- if (rename(inventoryTempFile.CStr(), inventoryFile.CStr()) < 0) {
- BOOST_THROW_EXCEPTION(posix_error()
- << boost::errinfo_api_function("rename")
- << boost::errinfo_errno(errno)
- << boost::errinfo_file_name(inventoryTempFile));
- }
}
}