<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:新細明體;
panose-1:2 2 5 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:"Calibri Light";
panose-1:2 15 3 2 2 2 4 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@新細明體";
panose-1:2 1 6 1 0 1 1 1 1 1;}
@font-face
{font-family:Roboto;}
@font-face
{font-family:微軟正黑體;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"\@微軟正黑體";}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-TW" link="#0563C1" vlink="#954F72" style="text-justify-trim:punctuation">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif">Hi
<span style="color:#212121;background:white">Vijay,<o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Roboto;color:#212121;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif">I found one question in
</span><u><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;color:#2A66D9;background:white">openbmc/phosphor-health-monitor<o:p></o:p></span></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif">The service healthMon via above functions created<b> has not the org.freedesktop.DBus.ObjectManager on the root</b>,<br>
</span><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white">and this will
<u>cause the sensor not be generated correctly</u> via redfish url <i>/redfish/v1/Chassis/chassis/Sensors/CPU</i>,
<i>/redfish/v1/Chassis/chassis/Sensors/Memory<o:p></o:p></i></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white">Because redfish will method GetSubTree to collect sensors via
</span><b><span lang="EN-US" style="font-family:"Calibri Light",sans-serif">org.freedesktop.DBus.ObjectManager</span></b><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white">I found a solution for your reference and show at bellow, you can use sdbusplus/server/manager.hpp which provide a function to add ObjectManager on the root.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white">Hence, I can get CPU, Memory information correctly via redfish url
<i>/redfish/v1/Chassis/chassis/Sensors/CPU</i>, <i>/redfish/v1/Chassis/chassis/Sensors/Memory</i><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow">#include <sdbusplus/server/manager.hpp></span><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white">class HealthMon<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white">{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> public:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> HealthMon() = delete;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> HealthMon(const HealthMon&) = delete;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> HealthMon& operator=(const HealthMon&) = delete;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> HealthMon(HealthMon&&) = delete;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> HealthMon& operator=(HealthMon&&) = delete;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> virtual ~HealthMon() = default;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> /** @brief Constructs HealthMon<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> *<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> * @param[in] bus - Handle to system dbus<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> HealthMon(sdbusplus::bus::bus& bus) : bus(bus)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> // read json file<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> sensorConfigs = getHealthConfig();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> createHealthSensors();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white">
<span style="background:yellow;mso-highlight:yellow">add_manager("/");</span><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> /** @brief Parsing Health config JSON file */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> Json parseConfigFile(std::string configFile);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> /** @brief reading config for each health sensor component */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> void getConfigData(Json& data, HealthConfig& cfg);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> /** @brief Map of the object HealthSensor */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> std::unordered_map<std::string, std::shared_ptr<HealthSensor>><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> healthSensors;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> /** @brief Create sensors for health monitoring */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> void createHealthSensors();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white">
<span style="background:yellow;mso-highlight:yellow">void add_manager(const std::string& path)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"> managers_.emplace_back(<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"> std::make_unique<sdbusplus::server::manager::manager>(<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"> sdbusplus::server::manager::manager(<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"> bus, path.c_str())));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:yellow;mso-highlight:yellow"> }</span><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> private:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> sdbusplus::bus::bus& bus;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> std::vector<HealthConfig> sensorConfigs;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white"> std::vector<HealthConfig> getHealthConfig();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white">
<span style="background:yellow;mso-highlight:yellow">std::vector<std::unique_ptr<sdbusplus::server::manager::manager>> managers_;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:Roboto;background:white">};<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Roboto;background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="background:white">This pic is the add
</span><span lang="EN-US">org.freedesktop.DBus.ObjectManager on the root for reference.</span><span lang="EN-US" style="background:white"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><img width="526" height="212" style="width:5.4791in;height:2.2083in" id="圖片_x0020_1" src="cid:image003.jpg@01D6903E.94B636F0"></span><u><span lang="EN-US" style="font-family:Roboto;color:#2A66D9;background:white"><o:p></o:p></span></u></p>
<p class="MsoNormal"><u><span lang="EN-US" style="font-family:Roboto;color:#2A66D9;background:white"><o:p><span style="text-decoration:none"> </span></o:p></span></u></p>
<p class="MsoNormal"><span lang="EN-US"><img width="529" height="362" style="width:5.5104in;height:3.7708in" id="圖片_x0020_2" src="cid:image004.jpg@01D6903E.94B636F0"></span><u><span lang="EN-US" style="font-family:Roboto;color:#2A66D9;background:white"><o:p></o:p></span></u></p>
<p class="MsoNormal"><u><span lang="EN-US" style="font-family:Roboto;color:#2A66D9;background:white"><o:p><span style="text-decoration:none"> </span></o:p></span></u></p>
<p class="MsoNormal"><strong><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white;font-weight:normal">Best Regards</span></strong><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white">,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Calibri Light",sans-serif;background:white">Bruce<o:p></o:p></span></p>
<p class="MsoNormal"><u><span lang="EN-US" style="font-family:Roboto;color:#2A66D9;background:white"><o:p><span style="text-decoration:none"> </span></o:p></span></u></p>
</div>
</body>
</html>