Add power fault check to checkstop handler

If a power fault is being reported during a
checkstop condition we will not call the
analyzer.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I9813a55b80eb1b94c6ad2d5cddb2e56b1daa67f4
diff --git a/util/dbus.cpp b/util/dbus.cpp
index f9370d4..ca5ccc4 100644
--- a/util/dbus.cpp
+++ b/util/dbus.cpp
@@ -530,5 +530,34 @@
     return true;
 }
 
+/** @brief Determine if power fault was detected */
+bool powerFault()
+{
+    // power fault based on pgood property
+    int32_t pgood = 0; // assume fault or unknown
+
+    constexpr auto interface = "org.openbmc.control.Power";
+
+    DBusService service;
+    DBusPath path;
+
+    // find a dbus service and object path that implements the interface
+    if (0 == find(interface, path, service))
+    {
+        DBusValue value;
+
+        // chassis pgood is implemented as a property
+        constexpr auto property = "pgood";
+
+        if (0 == getProperty(interface, path, service, property, value))
+        {
+            // return value is a variant, int32 == 1 for pgood OK
+            pgood = std::get<int32_t>(value);
+        }
+    }
+
+    return pgood != 1 ? true : false; // if not pgood then power fault
+}
+
 } // namespace dbus
 } // namespace util