control: Add cache maps to fan control dump
Add the _objects, _parameters, and _servTree maps to the fan control
JSON dump file.
A condensed example is:
{
"flight_recorder": [
"Oct 06 05:59:01.183998: main: Startup"
],
"parameters": null,
"objects": {
"/xyz/openbmc_project/sensors/temperature/vpcie_dcm1_rail_temperature": {
"org.freedesktop.DBus.Introspectable": null,
"org.freedesktop.DBus.Peer": null,
"org.freedesktop.DBus.Properties": null,
"xyz.openbmc_project.Association.Definitions": {
"Associations": false
},
"xyz.openbmc_project.Sensor.Value": {
"MaxValue": 250.0,
"MinValue": -50.0,
"Unit": "xyz.openbmc_project.Sensor.Value.Unit.DegreesC",
"Value": 60.0
},
"xyz.openbmc_project.State.Decorator.Availability": {
"Available": true
},
"xyz.openbmc_project.State.Decorator.OperationalStatus": {
"Functional": true
}
},
},
"services": {
"/xyz/openbmc_project/sensors/temperature/vpcie_dcm1_rail_temperature": {
"xyz.openbmc_project.Power.Regulators": [
true,
[
"xyz.openbmc_project.Sensor.Value"
]
]
},
}
}
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Id3351127e07bcf1094d1e0a7891625632afa8d5b
diff --git a/control/fanctl.cpp b/control/fanctl.cpp
index 6822b5d..34677f1 100644
--- a/control/fanctl.cpp
+++ b/control/fanctl.cpp
@@ -525,19 +525,18 @@
/**
* @function dump the FlightRecorder log data
*/
-void dumpFlightRecorder()
+void dumpFanControl()
{
try
{
SDBusPlus::callMethod(systemdService, systemdPath, systemdMgrIface,
"KillUnit", phosphorServiceName, "main", SIGUSR1);
- std::cout << "FlightRecorder log written to: /tmp/fan_control_dump.json"
+ std::cout << "Fan control dump written to: /tmp/fan_control_dump.json"
<< std::endl;
}
catch (const phosphor::fan::util::DBusPropertyError& e)
{
- std::cerr << "Unable to dump flight recorder log: " << e.what()
- << std::endl;
+ std::cerr << "Unable to dump fan control: " << e.what() << std::endl;
}
}
@@ -644,7 +643,7 @@
}
else if (app.got_subcommand("dump"))
{
- dumpFlightRecorder();
+ dumpFanControl();
}
}
catch (const std::exception& e)
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 10bb84d..01365e7 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -106,6 +106,7 @@
{
json data;
FlightRecorder::instance().dump(data);
+ dumpCache(data);
std::ofstream file{Manager::dumpFile};
if (!file)
@@ -119,6 +120,35 @@
debugDumpEventSource.reset();
}
+void Manager::dumpCache(json& data)
+{
+ auto& objects = data["objects"];
+ for (const auto& [path, interfaces] : _objects)
+ {
+ auto& interfaceJSON = objects[path];
+
+ for (const auto& [interface, properties] : interfaces)
+ {
+ auto& propertyJSON = interfaceJSON[interface];
+ for (const auto& [propName, propValue] : properties)
+ {
+ std::visit(
+ [&obj = propertyJSON[propName]](auto&& val) { obj = val; },
+ propValue);
+ }
+ }
+ }
+
+ auto& parameters = data["parameters"];
+ for (const auto& [name, value] : _parameters)
+ {
+ std::visit([&obj = parameters["name"]](auto&& val) { obj = val; },
+ value);
+ }
+
+ data["services"] = _servTree;
+}
+
void Manager::load()
{
if (_loadAllowed)
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index 92f837e..22b5630 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -587,6 +587,13 @@
* @brief Callback from debugDumpEventSource to dump debug data
*/
void dumpDebugData(sdeventplus::source::EventBase&);
+
+ /**
+ * @brief Dump the _objects, _servTree, and _parameters maps to JSON
+ *
+ * @param[out] data - The JSON that will be filled in
+ */
+ void dumpCache(json& data);
};
} // namespace phosphor::fan::control::json