Use eSEL severity in key lookup
When there is an eSEL, get its severity from
inside the contained PEL's UH section, and use
it as part of the key to look up the policy table
entry with, so there can be different entries for
Critical vs Warning vs Informational logs.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/thalerj/openbmctool.py b/thalerj/openbmctool.py
index 2fce508..81e944c 100644
--- a/thalerj/openbmctool.py
+++ b/thalerj/openbmctool.py
@@ -648,6 +648,37 @@
return eselParts
+def getESELSeverity(esel):
+ """
+ Finds the severity type in an eSEL from the User Header section.
+ @param esel - the eSEL data
+ @return severity - e.g. 'Critical'
+ """
+
+ # everything but 1 and 2 are Critical
+ # '1': 'recovered',
+ # '2': 'predictive',
+ # '4': 'unrecoverable',
+ # '5': 'critical',
+ # '6': 'diagnostic',
+ # '7': 'symptom'
+ severities = {
+ '1': 'Informational',
+ '2': 'Warning'
+ }
+
+ try:
+ headerPosition = esel.index('55 48') # 'UH'
+ # The severity is the last byte in the 8 byte section (a byte is ' bb')
+ severity = esel[headerPosition:headerPosition+32].split(' ')[-1]
+ type = severity[0]
+ except ValueError:
+ print("Could not find severity value in UH section in eSEL")
+ type = 'x';
+
+ return severities.get(type, 'Critical')
+
+
def sortSELs(events):
"""
sorts the sels by timestamp, then log entry number
@@ -698,6 +729,7 @@
esel = ""
eselParts = {}
i2cdevice= ""
+ eselSeverity = None
'prepare and sort the event entries'
for key in selEntries:
@@ -747,6 +779,7 @@
calloutFound = True
if("ESEL" in addDataPiece[i]):
esel = str(addDataPiece[i]).strip().split('=')[1]
+ eselSeverity = getESELSeverity(esel)
if args.devdebug:
eselParts = parseESEL(args, esel)
hasEsel=True
@@ -769,6 +802,15 @@
if(calloutFound):
if fruCallout != "":
policyKey = messageID +"||" + fruCallout
+
+ # Also use the severity for hostboot errors
+ if eselSeverity and messageID == 'org.open_power.Host.Error.Event':
+ policyKey += '||' + eselSeverity
+
+ # if not in the table, fall back to the original key
+ if policyKey not in policyTable:
+ policyKey = policyKey.replace('||'+eselSeverity, '')
+
if policyKey not in policyTable:
policyKey = messageID
else: