From e00036252ba4158fd873d26718bf56d450d55e85 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 12 Oct 2021 12:35:05 -0400 Subject: [PATCH] Revert to using the sensor reading The senser event status is optional, so instead apply the assertion mask to the reading as a means of letting assertion mask hide "don't care" threshold crossing. Change-Id: I23eb741bc4d9edfbdeba5bcf2e2f970959c4fc8d --- pyghmi/ipmi/sdr.py | 64 +++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/pyghmi/ipmi/sdr.py b/pyghmi/ipmi/sdr.py index daa7fcb0..54d83616 100644 --- a/pyghmi/ipmi/sdr.py +++ b/pyghmi/ipmi/sdr.py @@ -532,46 +532,30 @@ class SDREntry(object): output['state_ids'].append( self.assert_trap_value(state + 8)) else: - # get the event status for threshold sensor - rsp = ipmicmd.xraw_command(netfn=4, - command=0x2b, - data=(self.sensor_number,)) - rsp['data'] = bytearray(rsp['data']) - for offset in range(8): - if rsp['data'][1] & (0b1 << offset) & \ - self.assertion_reading_mask[0]: - output['state_ids'].append(self.assert_trap_value(offset)) - if len(rsp['data']) >= 3: - for offset in range(4): - if rsp['data'][2] & (0b1 << offset) & \ - self.assertion_reading_mask[1]: - output['state_ids'].append( - self.assert_trap_value(offset + 8)) - - # if the sensor trigger the event, then read the status and health - if len(output['state_ids']) > 0: - if reading[2] & 0b1: - output['health'] |= const.Health.Warning - output['states'].append(lower + " non-critical threshold") - if reading[2] & 0b10: - output['health'] |= const.Health.Critical - output['states'].append(lower + " critical threshold") - if reading[2] & 0b100: - output['health'] |= const.Health.Failed - output['states'].append(lower - + " non-recoverable threshold") - if reading[2] & 0b1000: - output['health'] |= const.Health.Warning - output['states'].append(upper - + " non-critical threshold") - if reading[2] & 0b10000: - output['health'] |= const.Health.Critical - output['states'].append(upper + " critical threshold") - if reading[2] & 0b100000: - output['health'] |= const.Health.Failed - output['states'].append(upper - + " non-recoverable threshold") - + if reading[2] & 0b1 & self.assertion_reading_mask[0]: + output['health'] |= const.Health.Warning + output['states'].append(lower + " non-critical threshold") + output['state_ids'].append(self.assert_trap_value(1)) + if reading[2] & 0b10 & self.assertion_reading_mask[0]: + output['health'] |= const.Health.Critical + output['states'].append(lower + " critical threshold") + output['state_ids'].append(self.assert_trap_value(2)) + if reading[2] & 0b100 & self.assertion_reading_mask[0]: + output['health'] |= const.Health.Failed + output['states'].append(lower + " non-recoverable threshold") + output['state_ids'].append(self.assert_trap_value(3)) + if reading[2] & 0b1000 & self.assertion_reading_mask[0]: + output['health'] |= const.Health.Warning + output['states'].append(upper + " non-critical threshold") + output['state_ids'].append(self.assert_trap_value(4)) + if reading[2] & 0b10000 & self.assertion_reading_mask[0]: + output['health'] |= const.Health.Critical + output['states'].append(upper + " critical threshold") + output['state_ids'].append(self.assert_trap_value(5)) + if reading[2] & 0b100000 & self.assertion_reading_mask[0]: + output['health'] |= const.Health.Failed + output['states'].append(upper + " non-recoverable threshold") + output['state_ids'].append(self.assert_trap_value(6)) return SensorReading(output, self.unit_suffix) def _set_tmp_formula(self, ipmicmd, value):