monitor: Capture BMC dumps on fan/ambient shutdowns

When fan-monitor or sensor-monitor generates an EPOW, this change
creates a BMC dump after the system is powered off and all error logs
are created.

Change-Id: Iacdd2d2b388e79988e2536d52497f0e697e1d444
Signed-off-by: Mike Capps <mikepcapps@gmail.com>
diff --git a/monitor/power_off_action.hpp b/monitor/power_off_action.hpp
index f0e7531..cada348 100644
--- a/monitor/power_off_action.hpp
+++ b/monitor/power_off_action.hpp
@@ -2,6 +2,7 @@
 
 #include "logging.hpp"
 #include "power_interface.hpp"
+#include "sdbusplus.hpp"
 
 #include <fmt/format.h>
 
@@ -96,6 +97,24 @@
 
   protected:
     /**
+     * @brief Create a BMC Dump
+     */
+    void createBmcDump() const
+    {
+        try
+        {
+            util::SDBusPlus::callMethod(
+                "xyz.openbmc_project.Dump.Manager",
+                "/xyz/openbmc_project/dump/bmc",
+                "xyz.openbmc_project.Dump.Create", "CreateDump",
+                std::vector<std::pair<std::string,
+                                      std::variant<std::string, uint64_t>>>());
+        }
+        catch (const sdbusplus::exception::exception&)
+        {}
+    }
+
+    /**
      * @brief The name of the action, which is set by the
      *        derived class.
      */
@@ -185,7 +204,6 @@
      */
     void powerOff()
     {
-
         if (_prePowerOffFunc)
         {
             _prePowerOffFunc();
@@ -194,6 +212,8 @@
         getLogger().log(
             fmt::format("Action '{}' executing hard power off", name()));
         _powerIface->hardPowerOff();
+
+        createBmcDump();
     }
 
   private:
@@ -284,6 +304,8 @@
         getLogger().log(
             fmt::format("Action '{}' executing soft power off", name()));
         _powerIface->softPowerOff();
+
+        createBmcDump();
     }
 
   private:
@@ -391,6 +413,7 @@
         }
 
         _powerIface->hardPowerOff();
+        createBmcDump();
     }
 
     /**