commit | b3f59464ec93ca2c7742bf38434d1942b4c7feba | [log] [tgz] |
---|---|---|
author | Amithash Prasad <amithash@meta.com> | Mon Jun 02 21:22:13 2025 -0700 |
committer | Patrick Williams <patrick@stwcx.xyz> | Thu Sep 04 18:48:37 2025 +0000 |
tree | 93c9f4c4e1ac42bddfb02f80ad6e320faf98a985 | |
parent | 7d2f323ab5b5ea663e625767f19552325a2f759c [diff] |
Add structured logging for threshold events Add capability to create structured logs for threshold crossing (compatible with Redfish Sensor Events) along with ability to resolve the logs when the threshold event recovers. Tested: Created an inventory with an external sensor named `HostDevTemp` and a virtual sensor named `SPECIAL_SENSOR` configured to consumes this sensor which has set thresholds `"HardShutdownHigh": 50` and `"CriticalHigh": 35`. This would allow us to change the sensor value and watch the service handling the threshold crossing. 1. Change sensor value to 40+ to observe upper critical threshold handling. ``` root@bmc:~# busctl introspect -l xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/3 xyz.openbmc_project.Logging.Entry | grep "AdditionalData\|Message\|Resolved" .AdditionalData property a{ss} 8 "READING_VALUE" "41.0" "SENSOR_NAME" "/xyz/openbmc_project/sensors/temperature/SPECIAL_SENSOR" "THRESHOLD_VALUE" "35.0" "UNITS" "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" <snip> .Message property s "xyz.openbmc_project.Sensor.Threshold.ReadingAboveUpperCriticalThreshold" .Resolved property b false ``` 2. change sensor value to 70+ to observe upper hard-shutdown threshold crossing. ``` root@bmc:~# busctl introspect -l xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/5 xyz.openbmc_project.Logging.Entry | grep "AdditionalData\|Message\|Resolved" .AdditionalData property a{ss} 8 "READING_VALUE" "71.0" "SENSOR_NAME" "/xyz/openbmc_project/sensors/temperature/SPECIAL_SENSOR" "THRESHOLD_VALUE" "50.0" "UNITS" "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" <snip> .Message property s "xyz.openbmc_project.Sensor.Threshold.ReadingAboveUpperHardShutdownThreshold" .Resolved property b false ``` 3. Change sensor value back to 40+. Ensure upper hard-shutdown threshold is marked as resolved. ``` root@bmc:~# busctl introspect -l xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/5 xyz.openbmc_project.Logging.Entry | grep "AdditionalData\|Message\|Resolved" .AdditionalData property a{ss} 8 "READING_VALUE" "71.0" "SENSOR_NAME" "/xyz/openbmc_project/sensors/temperature/SPECIAL_SENSOR" "THRESHOLD_VALUE" "50.0" "UNITS" "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" <snip> .Message property s "xyz.openbmc_project.Sensor.Threshold.ReadingAboveUpperHardShutdownThreshold" .Resolved property b true ``` 4. Change sensor value to 1+. Ensure that the upper critical threshold is marked as resolved. And a new event log is created for the sensors stating that the sensor is now in normal range. ``` root@bmc:~# busctl introspect -l xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/3 xyz.openbmc_project.Logging.Entry | grep "AdditionalData\|Message\|Resolved" .AdditionalData property a{ss} 8 "READING_VALUE" "41.0" "SENSOR_NAME" "/xyz/openbmc_project/sensors/temperature/SPECIAL_SENSOR" "THRESHOLD_VALUE" "35.0" "UNITS" "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" <snip> .Message property s "xyz.openbmc_project.Sensor.Threshold.ReadingAboveUpperCriticalThreshold" .Resolved property b true ``` ``` root@bmc:~# busctl introspect -l xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/6 xyz.openbmc_project.Logging.Entry | grep "AdditionalData\|Message\|Resolved" .AdditionalData property a{ss} 7 "READING_VALUE" "2.0" "SENSOR_NAME" "/xyz/openbmc_project/sensors/temperature/SPECIAL_SENSOR" "UNITS" "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" <snip> .Message property s "xyz.openbmc_project.Sensor.Threshold.SensorReadingNormalRange" .Resolved property b false ``` Change-Id: I660b6a477af38c9314680ce12705c460bae23fd8 Signed-off-by: Amithash Prasad <amithash@meta.com>
phosphor-virtual-sensor reads the configuration file virtual_sensor_config.json
from one of three locations:
/var/lib/phosphor-virtual-sensor
/usr/share/phosphor-virtual-sensor
By default the repository will install a sample config into (3).
There are two types of data in this file.
See virtual_sensor_config.json
in this repository for an example. Sensors added this way can use any expression that is accepted by exprtk.
For example:
{ "Desc": { "Config": "D-Bus" } }
Sensors added this way can only use a set of restricted calculations. Currently supported types are Average
, Maximum
, Minimum
, Sum
and ModifiedMedian
.
The virtual sensor configuration information needs to be added into the relevant hardware configuration file in entity-manager. This method of adding a virtual sensor allows a recipe that builds for different hardware configurations to have different virtual sensors for each configuration.
The virtual sensor configuration in entity manager follows a different format to the JSON in virtual_sensor_config.json
(specified in entity-manager/schemas/VirtualSensor.json).