fanctl: support dump of FlightRecorder log data
New command sends SIGUSR1 to fan-control to dump FlightRecorder data.
Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Change-Id: I3dc70ad0c1152f912b477146071c96cb824297b1
diff --git a/control/fanctl.cpp b/control/fanctl.cpp
index b3707d3..6df14f0 100644
--- a/control/fanctl.cpp
+++ b/control/fanctl.cpp
@@ -523,6 +523,25 @@
}
/**
+ * @function dump the FlightRecorder log data
+ */
+void dumpFlightRecorder()
+{
+ try
+ {
+ SDBusPlus::callMethod(systemdService, systemdPath, systemdMgrIface,
+ "KillUnit", phosphorServiceName, "main", SIGUSR1);
+ std::cout << "FlightRecorder log written to: /tmp/fan_control.txt"
+ << std::endl;
+ }
+ catch (const phosphor::fan::util::DBusPropertyError& e)
+ {
+ std::cerr << "Unable to dump flight recorder log: " << e.what()
+ << std::endl;
+ }
+}
+
+/**
* @function setup the CLI object to accept all options
*/
void initCLI(CLI::App& app, uint64_t& target, std::vector<std::string>& fanList)
@@ -573,6 +592,13 @@
auto cmdResume = commands->add_subcommand("resume", strHelp);
cmdResume->set_help_flag("-h, --help", strHelp);
cmdResume->require_option(0);
+
+ // Dump method
+ auto cmdDump = commands->add_subcommand(
+ "dump", "Dump the FlightRecorder diagnostic log");
+ cmdDump->set_help_flag("-h, --help",
+ "Dump the FlightRecorder diagnostic log");
+ cmdDump->require_option(0);
}
/**
@@ -616,6 +642,10 @@
{
status();
}
+ else if (app.got_subcommand("dump"))
+ {
+ dumpFlightRecorder();
+ }
}
catch (const std::exception& e)
{