<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Matt,<div><br></div><div>I implemented "Inactive the host sensors" in phosphor-hwmon use below approaching:</div><div>1. Add one option in Sensors configuration, phosphor-hwmon will parse this option and add host sensors to _hostSensors list.</div><div>2. In mainloop::read() before going to loop to read the sensors in the reading list. Query dbus to get CurrentHostState property.</div><div>This property belongs to service "xyz.openbmc_project.State.Host".</div><div>Based on the status of this property, identify host status.</div><div>If the host is off, remove the host sensors from _state list and dbus. I expected the users wouldn't see the host sensors on the BMC Web when the host is off.</div><div>If the host is on, add the host sensors back to _state list and also dbus.</div><div><br></div><div>The code is working. But I have two issues with this approaching:</div><div><br></div><div>1. Too many transactions to get dbus property CurrentHostState.</div><div>In my case, I have 6 services to monitor the sensors which concern the host.</div><div>With the current interval 1 second of phosphor-hwmon, I have 6 transactions to get CurrentHostState per seconds.</div><div>2. When I call "ipmitool power off" the host, there is a gap between the time I trigger GPIO to power off the chassis and the time Dbus property CurrentHostState is updated.</div><div>In this gap, the phosphor-hwmon is still reading sensors. And this causes the threshold warnings or errors. I want to avoid this.</div><div><br></div><div>Do you have any suggestions to avoid these issues?</div><div><br></div><div>Others question:</div><div>I saw that phosphor-hwmon is registering an event to smbus and trigger the event after each 1 second to read sensors.</div><div>Can I change the phosphor-hwmon code to integrate one dbus signal event?</div><div>Which will be triggered when there is changing in dbus property.</div><div><br></div><div>I knew how to create a service which adds the call back function when there is change in dbus property.</div><div>But don't know how to intergrace it to hwmon.</div><div><br></div><div>Regards.</div><div>Thu Nguyen.</div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 23, 2020 at 5:45 AM Thu Ba Nguyen <<a href="mailto:tbnguyen1985@gmail.com">tbnguyen1985@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Just remove all of added code, rebase the phosphor-hwmon source to commit </div><div>"5906173 (12 months ago) Brad Bishop: build: add support for building with meson"</div><div><br></div><div>Add the include:</div><div><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:18px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(197,134,192)">#include</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:18px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(86,156,214)"> </span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:18px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(206,145,120)"><sdbusplus/asio/connection.hpp></span><br></div><div>I can see the error </div><div><div>| /openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot-native/usr/bin/arm-openbmc-linux-gnueabi/../../libexec/arm-openbmc-linux-gnueabi/gcc/arm-openbmc-linux-gnueabi/10.1.0/ld: phosphor_hwmon_readd-readd.<span style="background-color:rgb(255,0,0)">o</span><span style="background-color:rgb(255,0,0)">: undefined reference to symbol 'pthread_key_delete@@GLIBC_2.4'</span></div><div>| /openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot-native/usr/bin/arm-openbmc-linux-gnueabi/../../libexec/arm-openbmc-linux-gnueabi/gcc/arm-openbmc-linux-gnueabi/10.1.0/ld: /openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi<span style="background-color:rgb(255,0,0)">/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot/lib/libpthread.so.0: error adding symbols: DSO missing from command line</span></div><div>| collect2: error: ld returned 1 exit status</div><div>| make[2]: *** [Makefile:643: phosphor-hwmon-readd] Error 1</div><div>| make[2]: Leaving directory '/openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/build'</div><div>| make[1]: *** [Makefile:801: all-recursive] Error 1</div><div>| make[1]: Leaving directory '/openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/build'</div><div>| make: *** [Makefile:524: all] Error 2</div><div>| ERROR: oe_runmake failed</div><div>| WARNING: exit code 1 from a shell command.</div><div>| ERROR: Execution of '/openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/temp/run.do_compile.2045' failed with exit code 1:</div><div>| Makefile:800: target 'check-valgrind-recursive' given more than once in the same rule</div><div>| Makefile:800: target 'check-valgrind-memcheck-recursive' given more than once in the same rule</div><div>| Makefile:800: target 'check-valgrind-helgrind-recursive' given more than once in the same rule</div><div>| Makefile:800: target 'check-valgrind-drd-recursive' given more than once in the same rule</div><div>| Makefile:800: target 'check-valgrind-sgcheck-recursive' given more than once in the same rule</div><div>| make all-recursive</div></div><div><br></div><div>I think we should add thread lib.</div><div><br></div><div>Regards.</div><div>Thu Nguyen.</div><div dir="ltr"></div><div dir="ltr"><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:18px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(206,145,120)"><br></span></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 22, 2020 at 10:51 PM Matt Spinler <<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
<br>
On 10/22/2020 9:49 AM, Thu Ba Nguyen wrote:<br>
> I started on supporting enable/disable host sensors. Everythings is <br>
> fine until I...<br>
> This Message Is From an External Sender<br>
> This message came from outside your organization.<br>
><br>
> I started on supporting enable/disable host sensors.<br>
> Everythings is fine until I add code to monitor host status as below.<br>
> bool MainLoop::isHostOn(void)<br>
> {<br>
> char buff[128];<br>
> if (!powerMatch)<br>
> {<br>
> log<level::ERR>("Power Match Not Created");<br>
> }<br>
> sprintf(buff, "isHostOn powerStatusOn: %d\n",powerStatusOn);<br>
> log<level::INFO>(buff);<br>
> return powerStatusOn;<br>
> }<br>
> std::shared_ptr<sdbusplus::bus::match::match><br>
> MainLoop::startHostStateMonitor(void) {<br>
> return std::make_shared<sdbusplus::bus::match::match>(<br>
> *conn,<br>
> "type='signal',interface='org.freedesktop.DBus.Properties',"<br>
> "member='PropertiesChanged',arg0='xyz.openbmc_project.State.Host'",<br>
> [](sdbusplus::message::message &msg) {<br>
> std::string interfaceName;<br>
> boost::container::flat_map<std::string, std::variant<std::string>><br>
> propertiesChanged;<br>
> try {<br>
> msg.read(interfaceName, propertiesChanged);<br>
> } catch (std::exception &e) {<br>
> log<level::ERR>("Unable to read host state\n");<br>
> return;<br>
> }<br>
> // We only want to check for CurrentHostState<br>
> if (propertiesChanged.begin()->first != "CurrentHostState") {<br>
> return;<br>
> }<br>
> auto findState = propertiesChanged.find(powProperty);<br>
> if (findState != propertiesChanged.end())<br>
> {<br>
> powerStatusOn = boost::ends_with(<br>
> std::get<std::string>(findState->second), "Running");<br>
> }<br>
> powerMatch = true;<br>
> });<br>
> }<br>
> void MainLoop::read()<br>
> {<br>
> // TODO: Issue#3 - Need to make calls to the dbus sensor cache here to<br>
> // ensure the objects all exist?<br>
> /* Host changed state from On to Off */<br>
> if (!isHostOn() && (lastPowerState == HOST_ON ||<br>
> lastPowerState == HOST_NA)) {<br>
> removeHostSensors();<br>
> lastPowerState = HOST_OFF;<br>
> }<br>
> /* Host changed state from Off to On */<br>
> if (isHostOn() && lastPowerState == HOST_OFF) {<br>
> addDroppedHostSensors();<br>
> lastPowerState = HOST_ON;<br>
> }<br>
> When build openBMC I got error:<br>
> tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot/lib/libpthread.so.0: <br>
> error adding symbols: DSO missing from command line<br>
> | collect2: error: ld returned 1 exit status<br>
> | make[2]: *** [Makefile:643: phosphor-hwmon-readd] Error 1<br>
><br>
> It seems I need adding the threads lib to defend lib.<br>
> Any suggestion to add threads lib to build configuration?<br>
><br>
<br>
That must be because you're using that single boost function? While you <br>
could add the dependency,<br>
the ideal thing to do since this repo already uses <br>
phosphor-dbus-interfaces is to use the function:<br>
<br>
/** @brief Convert a string to an appropriate enum value.<br>
* @param[in] s - The string to convert in the form of<br>
* "xyz.openbmc_project.State.Host.<value name>"<br>
* @return - The enum value.<br>
*/<br>
static HostState convertHostStateFromString(const std::string& s);<br>
<br>
to convert it to the actual HostState enum to check against:<br>
<br>
enum class HostState<br>
{<br>
Off,<br>
Running,<br>
Quiesced,<br>
DiagnosticMode,<br>
};<br>
<br>
This is all in xyz/openbmc_project/State/Host/server.hpp provided by <br>
phosphor-dbus-interfaces.<br>
<br>
> Thanks.<br>
> Thu.<br>
><br>
> On Wed, Oct 21, 2020 at 11:54 PM Thu Ba Nguyen <<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a> <br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>> wrote:<br>
><br>
> Hi Vijay,<br>
><br>
> I took a look on entity-manager and openbmc source.<br>
> Don't have many companies using entity-manager model to support<br>
> sensors.<br>
><br>
> Regards<br>
> Thu Nguyen.<br>
><br>
><br>
> On Wed, Oct 21, 2020 at 7:15 AM Vijay Khemka <<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a><br>
> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a>>> wrote:<br>
><br>
> *From: *openbmc<br>
> <openbmc-bounces+vijaykhemka=<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a>>> on behalf of Thu Ba Nguyen<br>
> <<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>><br>
> *Date: *Monday, October 19, 2020 at 11:23 AM<br>
> *To: *Ed Tanous <<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a> <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a>>><br>
> *Cc: *OpenBMC Maillist <<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a>>><br>
> *Subject: *Re: Enable/Disable some sensors when Host On/Off<br>
><br>
> Hi Ed Tanous,<br>
><br>
> > Thanks for your info,<br>
><br>
> > But in your platform we are using phosphor-hwmon to manage<br>
> sensors.<br>
><br>
> > We don't use entity-manager.<br>
><br>
> > As I knew we can't use both entity-manager and<br>
> phosphor-hwmon for one project.<br>
><br>
> You can use both but for different sensors. You can decide<br>
> what sensors to configure<br>
><br>
> via EM/dbus-sensors and which one for phosphor-hwmon.<br>
><br>
> Regards<br>
><br>
> Thu Nguyen.<br>
><br>
<br>
</blockquote></div>
</blockquote></div>