monitor: journal message for fan Actual Speed wrong
Problem: Actual speed is formatted with the wrong format type.
Solution: By using the format library, it is not necessary to specify a
format for the result, and speed is correctly displayed.
Tested: Ran with simulation.
In terminal connected to simiulator:
systemctl disable
phosphor-dbus-monitor.service obmcutil poweron
changed the fan speed in /sys/class/hwmon/hwmon9/fan1_target using an
echo command:
echo 8000 > fan1_target
After jrnl showed the fan had been disabled, setting fan to
nonfunctional showed expected speed:
"Setting fan /system/chassis/motherboard/fan5 to nonfunctional Sensor:
/xyz/openbmc_project/sensors/fan_tach/fan5_0 Actual speed: 8000.0 Target speed:
11200"
Changed the fan speed back:
echo 11200 > fan1_target
journal entry for setting fan back to functional was seen.
"Setting fan /system/chassis/motherboard/fan2 back to functional"
Signed-off-by: Jay Meyer <jaymeyer@us.ibm.com>
Change-Id: I26bf717694ff8a60851dde1a5052945e4336dfa0
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 9fbe081..4b84fff 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -19,6 +19,8 @@
#include "types.hpp"
#include "utility.hpp"
+#include <fmt/format.h>
+
#include <phosphor-logging/log.hpp>
#include <algorithm>
@@ -175,8 +177,8 @@
// the fan can go back to functional
if (!_functional && !tooManySensorsNonfunctional())
{
- log<level::INFO>("Setting a fan back to functional",
- entry("FAN=%s", _name.c_str()));
+ log<level::INFO>(
+ fmt::format("Setting fan {} back to functional", _name).c_str());
updateInventory(true);
}
@@ -186,11 +188,13 @@
// the whole fan nonfunctional.
if (_functional && tooManySensorsNonfunctional())
{
- log<level::ERR>("Setting a fan to nonfunctional",
- entry("FAN=%s", _name.c_str()),
- entry("TACH_SENSOR=%s", sensor.name().c_str()),
- entry("ACTUAL_SPEED=%lld", sensor.getInput()),
- entry("TARGET_SPEED=%lld", sensor.getTarget()));
+ log<level::ERR>(fmt::format("Setting fan {} to nonfunctional "
+ "Sensor: {} "
+ "Actual speed: {} "
+ "Target speed: {}",
+ _name, sensor.name(), sensor.getInput(),
+ sensor.getTarget())
+ .c_str());
updateInventory(false);
}