summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Clegg <andyc@graphcore.ai>2022-07-25 14:20:30 +0100
committerAlexander Amelkin <mocbuhtig@amelkin.msk.ru>2022-08-05 18:57:19 +0300
commita1dc78c4566734075c433ca61e71bd18c7058c6d (patch)
treeb32af68fa2689b83da0e054780b73f3f935ebd0f
parent4d25a93f4922885c3d557bf4f9a83968ad2edee9 (diff)
downloadipmitool-a1dc78c4566734075c433ca61e71bd18c7058c6d.tar.gz
sel: Fix the deasserted thresholds inequality
The choice of > or < when printing the threshold inequality currently only depends on whether it is an upper or lower threshold. This is correct when the event is asserted, but when the event is deasserted the inequality is reversed and therefore the current code can give confusing results, e.g.: ``` Temperature ps1_inlet_temp | Upper Non-critical going high | Deasserted | Reading 43.94 > Threshold 44.88 degrees C ``` This commit fixes that. See ipmitool/ipmitool#349 Signed-off-by: Andy Clegg <andyc@graphcore.ai>
-rw-r--r--lib/ipmi_sel.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c
index 4440fda..31c0eea 100644
--- a/lib/ipmi_sel.c
+++ b/lib/ipmi_sel.c
@@ -1955,8 +1955,20 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt)
(trigger_reading==(int)trigger_reading) ? 0 : 2,
trigger_reading);
if (threshold_reading_provided) {
+ /* According to Table 29-6, Event Data byte 1 contains,
+ * among other info, the offset from the Threshold type
+ * code. According to Table 42-2, all even offsets
+ * are 'going low', and all odd offsets are 'going high'
+ */
+ bool going_high =
+ (evt->sel_type.standard_type.event_data[0]
+ & EVENT_OFFSET_MASK) % 2;
+ if (evt->sel_type.standard_type.event_dir) {
+ /* Event is de-asserted so the inequality is reversed */
+ going_high = !going_high;
+ }
printf(" %s Threshold %.*f %s",
- ((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
+ going_high ? ">" : "<",
(threshold_reading==(int)threshold_reading) ? 0 : 2,
threshold_reading,
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,