From 399fd92ec41cd23a9a5cb30f5d41397e5d8c6306 Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Fri, 30 Jun 2017 18:40:30 +0530 Subject: Get the timestamp from the log entry Change-Id: Id00f6e1e6f65c17babc5d06abe1b9fc39a4de8b8 Signed-off-by: Tom Joseph --- selutility.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'selutility.cpp') diff --git a/selutility.cpp b/selutility.cpp index 0107515..3f9d9ab 100644 --- a/selutility.cpp +++ b/selutility.cpp @@ -182,6 +182,38 @@ GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath) return internal::prepareSELEntry(objPath, iter); } +std::chrono::seconds getEntryTimeStamp(const std::string& objPath) +{ + sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; + + auto service = ipmi::getService(bus, logEntryIntf, objPath); + + using namespace std::string_literals; + static const auto propTimeStamp = "Timestamp"s; + + auto methodCall = bus.new_method_call(service.c_str(), + objPath.c_str(), + propIntf, + "Get"); + methodCall.append(logEntryIntf); + methodCall.append(propTimeStamp); + + auto reply = bus.call(methodCall); + if (reply.is_method_error()) + { + log("Error in reading Timestamp from Entry interface"); + elog(); + } + + sdbusplus::message::variant timeStamp; + reply.read(timeStamp); + + std::chrono::milliseconds chronoTimeStamp( + sdbusplus::message::variant_ns::get(timeStamp)); + + return std::chrono::duration_cast(chronoTimeStamp); +} + } // namespace sel } // namespace ipmi -- cgit v1.2.1