add health_metric implementation
Add the interface and implementation for the health_metric to be used
in the rewrite for phosphor-health-monitor.
This change is in relation to following design and D-Bus interface
update -
https://gerrit.openbmc.org/c/openbmc/docs/+/64917
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/64914
gtest added for UT.
Change-Id: Iffcc52f9dff712890377b1222fd7e7d5d6661eaf
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/health_utils.cpp b/health_utils.cpp
new file mode 100644
index 0000000..163fc8c
--- /dev/null
+++ b/health_utils.cpp
@@ -0,0 +1,23 @@
+#include "health_utils.hpp"
+
+#include <phosphor-logging/lg2.hpp>
+
+PHOSPHOR_LOG2_USING;
+
+namespace phosphor::health::utils
+{
+
+void startUnit(sdbusplus::bus_t& bus, const std::string& sysdUnit)
+{
+ if (sysdUnit.empty())
+ {
+ return;
+ }
+ sdbusplus::message_t msg = bus.new_method_call(
+ "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager", "StartUnit");
+ msg.append(sysdUnit, "replace");
+ bus.call_noreply(msg);
+}
+
+} // namespace phosphor::health::utils