<div dir="ltr"><div class="gmail_default" style="font-family:times new roman,serif">Hi Patrick</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">Though we don't use host-error-monitor at Twitter, we do have a number of discrete sensors implemented. I can provide some details that can hopefully help get you started. <br></div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">I should mention though, the below steps are only applicable if you're using 'dbus-sensors' for your sensors and the phosphor-sel-logger.</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">1. Include the 'intel-ipmi-oem' recipe in your package</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">2. In the 'intel-ipmi-oem' recipe, in the file called sdrutils.hpp, you will find a bunch of enumerated entries for different (threshold based) sensor types such as voltage, current etc. You can add discrete sensor type you want here, for example for CATERRs it probably would be of the type "processor" (0x07)</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">3. You don't  necessarily need to add the discrete sensor to entity-manager (you can if you like). Instead, under dbu-sensors you need to create a service and add an interface for your sensor. We have implemented by adding code in dbus-sensors that has a list of event-only sensors and our code loops through and adds all of them. However to start out, you can just do it for a single discrete sensor by doing the following:<br></div><div class="gmail_default" style="font-family:times new roman,serif;margin-left:40px">a. create a file (say processorerror.cpp) along the same lines as one of the existing sensor types</div><div class="gmail_default" style="font-family:times new roman,serif;margin-left:40px">b. request a service name using "request->name"</div><div class="gmail_default" style="font-family:times new roman,serif;margin-left:40px">c. register your object path and interface <br></div><div class="gmail_default" style="font-family:times new roman,serif">The above file would essentially do nothing other than just create a dbus sensor.<br></div><div class="gmail_default" style="font-family:times new roman,serif;margin-left:40px"><br></div><div class="gmail_default" style="font-family:times new roman,serif">4. Create entries in the CMakeLists.txt file in dbus-sensors to build your .cpp file and make sure it corresponds with the sensor type you created in intel-ipmi-oem in step 2.<br></div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">5. Once the above step is done, if you build an image, you should see the sensor you created (say something like "/xyz/openbmc_project/sensors/processor/Processor_Error" ) if you do "ipmitool sdr elist all". The sensor will be created with a dynamically assigned sensor number just like all the threshold based sensors. However, instead of displaying a value like it would for a threshold sensor it will say "Event-Only". At this point your discrete sensor is created but doesn't really do anything</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">6. Now, in order to generate a SEL, we use the IpmiSelAdd method that is present in the sel-logger service:</div><div class="gmail_default" style="font-family:times new roman,serif"><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"># busctl introspect<span>  </span>xyz.openbmc_project.Logging.IPMI /xyz/openbmc_project/Logging/IPMI</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">NAME<span>                                </span>TYPE<span>      </span>SIGNATURE RESULT/VALUE FLAGS</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><b>org.freedesktop.DBus.Introspectable</b> interface - <span>        </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.Introspect <span>                        </span>method<span>    </span>- <span>        </span>s<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><b>org.freedesktop.DBus.Peer <span>         </span></b> interface - <span>        </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.GetMachineId <span>                      </span>method<span>    </span>- <span>        </span>s<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.Ping <span>                              </span>method<span>    </span>- <span>        </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><b>org.freedesktop.DBus.Properties <span>   </span></b> interface - <span>        </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.Get<span>                                </span>method<span>    </span>ss<span>        </span>v<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.GetAll <span>                            </span>method<span>    </span>s <span>        </span>a{sv}<span>        </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.Set<span>                                </span>method<span>    </span>ssv <span>      </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.PropertiesChanged<span>                  </span>signal<span>    </span>sa{sv}as<span>  </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><b>xyz.openbmc_project.Logging.IPMI<span>   </span></b> interface - <span>        </span>-<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.IpmiSelAdd <span>                        </span>method<span>    </span>ssaybq<span>    </span>q<span>            </span>-</span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">.IpmiSelAddOem<span>                      </span>method<span>    </span>sayy<span>      </span>q<span>            </span>-</span></span></p></div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">As you can see above, the IpmiSelAdd method takes 6 arguments, 'ssaybq' as described in <a href="https://dbus.freedesktop.org/doc/dbus-specification.html#type-system" target="_blank">https://dbus.freedesktop.org/doc/dbus-specification.html#type-system.<br></a></div><div class="gmail_default" style="font-family:times new roman,serif">Looking at the code in phosphor-sel-logger where the IpmiSelAdd method is registered, we can see what the ssaybq arguments correspond to:</div><div class="gmail_default" style="font-family:times new roman,serif"><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">ifaceAddSel->register_method(</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>        </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(180,36,25)">"IpmiSelAdd"</span><span style="font-variant-ligatures:no-common-ligatures">, [](</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">const</span><span style="font-variant-ligatures:no-common-ligatures"> std::string &message, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">const</span><span style="font-variant-ligatures:no-common-ligatures"> std::string &path,</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>                         </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">const</span><span style="font-variant-ligatures:no-common-ligatures"> std::vector<</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">uint8_t</span><span style="font-variant-ligatures:no-common-ligatures">> &selData,</span></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">








</p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>                         </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">const</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">bool</span><span style="font-variant-ligatures:no-common-ligatures"> &assert, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">const</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(47,180,29)">uint16_t</span><span style="font-variant-ligatures:no-common-ligatures"> &genId) {</span></span></p></div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">Based on this, we can directly call the method using busctl to test if a SEL is created for the discrete sensor. For example, for the sensor we created in step 5, we could do the following to generate a SEL:</div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)">busctl call xyz.openbmc_project.Logging.IPMI /xyz/openbmc_project/Logging/IPMI xyz.openbmc_project.Logging.IPMI IpmiSelAdd ssaybq <message string> <sensor object path, i.e "/xyz/openbmc_project/sensors/processor/Processor_Error">  <number of bytes in the event data vector, which in this case would be 3>  <event data vector>  < assert/de-assert yes/no>  <generator id, 0x0020 for bmc></span></div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)"><br></span></div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)"><span style="background-color:rgb(255,255,255)">(the first 4 arguments after 'call' are the service, object, interface and the method)</span><br></span></div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)"><br></span></div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(255,255,255)"><span></span></span>To give you an example, here is what the above command looks like for a discrete sensor for a power button press:</div><div class="gmail_default" style="font-family:times new roman,serif">Command:</div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)"># busctl call xyz.openbmc_project.Logging.IPMI /xyz/openbmc_project/Logging/IPMI xyz.openbmc_project.Logging.IPMI IpmiSelAdd ssaybq "SEL Entry" "/xyz/openbmc_project/sensors/pwr_button/POWER_BUTTON" 3 {0x00,0x01,0x00} yes 0x20</span></div><div class="gmail_default" style="font-family:times new roman,serif"> </div><div class="gmail_default" style="font-family:times new roman,serif">Sel generated:<br></div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)">f | 07/17/20 | 16:49:01 UTC | Button POWER BUTTON | Power Button pressed | Asserted</span></div><div class="gmail_default" style="font-family:times new roman,serif"><span style="background-color:rgb(238,238,238)"><br></span></div><div class="gmail_default" style="font-family:times new roman,serif">7. If you have a service that triggers on an event, you could directly call the above command to generate a SEL in your service file. For example, we have a gpio service that triggers on certain events and we directly call the above command from the service file. In other cases we call a method to generate the SEL in code in the event "handler" function. This might be more relevant for our host-error-monitor case. Here is an example from our code for how we call the IpmiSelAdd method:</div><div class="gmail_default" style="font-family:times new roman,serif"><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">sdbusplus::message::message writeSEL = conn->new_method_call(</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>            </span>ipmiSelService, ipmiSelPath, ipmiSelAddInterface, </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(180,36,25)">"IpmiSelAdd"</span><span style="font-variant-ligatures:no-common-ligatures">);</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>        </span>writeSEL.append(ipmiSelAddMessage, dbusPath, eventData, assert, genId);</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0);min-height:13px"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"></span><br></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>        </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(193,101,28)">try</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>        </span>{</span></span></p><p style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>            </span>conn->call(writeSEL);</span></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures">












</span></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)"><span style="font-variant-ligatures:no-common-ligatures"><span>        </span>}</span></span></p></div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">Here, conn is the "shared_ptr". The other arguments are pretty much the same as described in the busctl command in #6.  Not sure how this would work with host-error-monitor but you can try it with the relevant shared_ptr in host_error_monitor.cpp and it might possibly work.</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">Hope this helps.</div><div class="gmail_default" style="font-family:times new roman,serif"><br></div><div class="gmail_default" style="font-family:times new roman,serif">-Varun <br></div><div class="gmail_default" style="font-family:times new roman,serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 14, 2020 at 3:07 PM Patrick Voelker <<a href="mailto:Patrick_Voelker@phoenix.com" target="_blank">Patrick_Voelker@phoenix.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div>
<p class="MsoNormal">Hi, I’d like to log IPMI SEL events for changes in the signals monitored by OpenBMC/host-error-monitor.  I don’t have much experience with OpenBMC’s sensors yet so I’m not sure what the best approach is and am looking for some guidance.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I haven’t found a good example yet of a IPMI discrete sensor and I don’t want to put IPMI specific information into host-error-monitor to directly add SEL events via phosphor-sel-logger.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Here’s my understanding thus far :<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">* A module needs to instantiate dbus sensors representing the signals being monitored.  This could be done in host-error-monitor or duplicate some of the functionality in dbus-sensors.  Is there a benefit to extending one over the other?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">* One or more IPMI SDRs should be created for the IPMI sensors needed to group all the necessary discrete offsets.  If I’m using entity-manager in my build, is that where I would define this sensor?  If not, is there some other way to accomplish
 this?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">* phosphor-sel-logger then needs to monitor (match) dbus discrete sensor property changes to create appropriate IPMI and redfish logs for the events as they occur.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Does that sound about right? Thanks in advance for your help.<u></u><u></u></p>
</div>
</div>

</blockquote></div>