metrics-ipmi-blobs: Support ECC Error Counts
Export the ECC Error Cournter from
http://github.com/openbmc/phosphor-ecc to ipmi blob.
Tested:
The blob output is updated if MemoryECC dbus object exists compared to
the blob output if MemoryECC doesn't exists.
Change-Id: I2c63dbcd0970afc587f5c2ee01f8c261909f0b08
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/subprojects/metrics-ipmi-blobs/util.cpp b/subprojects/metrics-ipmi-blobs/util.cpp
index 5bfc9c8..0e14698 100644
--- a/subprojects/metrics-ipmi-blobs/util.cpp
+++ b/subprojects/metrics-ipmi-blobs/util.cpp
@@ -348,4 +348,52 @@
return true;
}
+bool getECCErrorCounts(EccCounts& eccCounts)
+{
+ std::vector<
+ std::pair<std::string, std::variant<uint64_t, uint8_t, std::string>>>
+ values;
+ try
+ {
+ auto bus = sdbusplus::bus::new_default_system();
+ auto m =
+ bus.new_method_call("xyz.openbmc_project.memory.ECC",
+ "/xyz/openbmc_project/metrics/memory/BmcECC",
+ "org.freedesktop.DBus.Properties", "GetAll");
+ m.append("xyz.openbmc_project.Memory.MemoryECC");
+ auto reply = bus.call(m);
+ reply.read(values);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ return false;
+ }
+ bool hasCorrectable = false;
+ bool hasUncorrectable = false;
+ for (const auto& [key, value] : values)
+ {
+ if (key == "ceCount")
+ {
+ eccCounts.correctableErrCount =
+ static_cast<int32_t>(std::get<uint64_t>(value));
+ hasCorrectable = true;
+ if (hasUncorrectable)
+ {
+ return true;
+ }
+ }
+ if (key == "ueCount")
+ {
+ eccCounts.uncorrectableErrCount =
+ static_cast<int32_t>(std::get<uint64_t>(value));
+ hasUncorrectable = true;
+ if (hasCorrectable)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
} // namespace metric_blob