/// <summary> /// Recursively retrieves System Event Log entries. /// </summary> public virtual SystemEventLog GetSel() { // return value. create string collection to hold system event strings. SystemEventLog messageCollection = new SystemEventLog(0x00); // Default Record Off Set byte offSet = 0x00; // limit number of records to retrive ushort RecordCount = 0; // limit number of records to retrive ushort RecordLimit = 350; // system event log entry point ushort recordId = 0; // system event log record reserve (used for partial retrieve) ushort reserveId = 0; // signal last system event record (aborts event log Loop) ushort lastRecordId = 65535; // system event log record Id and raw payload collection IpmiSelCollection responseCollection = new IpmiSelCollection(); // retrieve all records while connected by recursively calling the Sel entry command while (recordId != lastRecordId && RecordCount < RecordLimit) { // get the SEL record SelEntryResponse response = (SelEntryResponse)this.IpmiSendReceive( new SelEntryRequest(reserveId, recordId, offSet), typeof(SelEntryResponse)); // reset the main class error code. messageCollection.CompletionCode = response.CompletionCode; if (response.CompletionCode == 0x00) { // add the record to the collection responseCollection.Add(response); // update the record Id (signals loop exit) recordId = BitConverter.ToUInt16(response.NextRecordId, 0); } else { // add the errored record to the collection responseCollection.Add(response); // break the loop on error. break; } RecordCount++; } // check for valid sel event messages before processing if (responseCollection.Count > 0) { foreach (SelEntryResponse response in responseCollection) { SystemEventLogMessage message = new SystemEventLogMessage(response.CompletionCode); // if the response was not an error cast it. if (response.CompletionCode == 0x00) { // bytes 1-2 = Record ID message.RecordId = BitConverter.ToUInt16(response.SelEntry, 0); // SEL record type byte recordType = response.SelEntry[2]; message.RecordType = recordType; // byte array for message data byte[] messageData = new byte[13]; // copy message data in message data array Buffer.BlockCopy(response.SelEntry, 3, messageData, 0, (response.SelEntry.Length - 3)); // IPMI SPEC: 31.6.1 SEL Record Type Ranges if (recordType >= 0x00 && recordType <= 0xBF) { // System Event Record (0x02) message.EventFormat = EventMessageFormat.SystemEvent; // Format Standard SEL record SelSupport.StandardSelFormat(ref message, messageData); message.EventMessage = ExtractSystemEventRecordMessage(message.RawSensorType, message.EventTypeCode, message.RawPayload); } else if ((recordType >= 0xC0) && (recordType <= 0xDF)) { // Time Stamped OEM. (override type to reduce string repetition in resource file) message.EventFormat = EventMessageFormat.OemTimeStamped; // Format "TimeStamped OEM" SEL record SelSupport.TimeStampedOEMSelFormat(ref message, messageData); message.EventMessage = ExtractOemTimestampedEventMessage(message.RawPayload); } else if ((recordType >= 0xE0) && (recordType <= 0xFF)) { // Non TimeStamped OEM. (override type to reduce string repetition in resource file) message.EventFormat = EventMessageFormat.OemNonTimeStamped; // Format "Non TimeStamped OEM" SEL record SelSupport.NonTimestampedOemSelFormat(ref message, messageData); message.EventMessage = ExtractOemNonTimestampedEventMessage(message.RawPayload); } // add message to the collection messageCollection.EventLog.Add(message); } } } return messageCollection; }
/// <summary> /// Recursively retrieves System Event Log entries. /// </summary> public virtual SystemEventLog GetSel() { // return value. create string collection to hold system event strings. SystemEventLog messageCollection = new SystemEventLog(0x00); // Default Record Off Set byte offSet = 0x00; // limit number of records to retrive ushort RecordCount = 0; // limit number of records to retrive ushort RecordLimit = 350; // system event log entry point ushort recordId = 0; // system event log record reserve (used for partial retrieve) ushort reserveId = 0; // signal last system event record (aborts event log Loop) ushort lastRecordId = 65535; // system event log record Id and raw payload collection IpmiSelCollection responseCollection = new IpmiSelCollection(); // retrieve all records while connected by recursively calling the Sel entry command while (recordId != lastRecordId || RecordCount >= RecordLimit) { // get the SEL record SelEntryResponse response = (SelEntryResponse)this.IpmiSendReceive( new SelEntryRequest(reserveId, recordId, offSet), typeof(SelEntryResponse)); // reset the main class error code. messageCollection.CompletionCode = response.CompletionCode; if (response.CompletionCode == 0x00) { // add the record to the collection responseCollection.Add(response); // update the record Id (signals loop exit) recordId = BitConverter.ToUInt16(response.NextRecordId, 0); } else { // add the errored record to the collection responseCollection.Add(response); // break the loop on error. break; } RecordCount++; } // check for valid sel event messages before processing if (responseCollection.Count > 0) { foreach (SelEntryResponse response in responseCollection) { SystemEventLogMessage message = new SystemEventLogMessage(response.CompletionCode); // if the response was not an error cast it. if (response.CompletionCode == 0x00) { // bytes 0-2 = Record Id ushort recordNo = BitConverter.ToUInt16(response.SelEntry, 0); // sel record type byte recordType = response.SelEntry[2]; // byte array for message data byte[] messageData = new byte[13]; // copy message data in message data array Buffer.BlockCopy(response.SelEntry, 3, messageData, 0, (response.SelEntry.Length - 3)); // IPMI SPEC: 31.6.1 SEL Record Type Ranges if (recordType >= 0x00 && recordType <= 0xBF) { // Standard Range. 0x02 "System Event". (Spec declares 0x02. TODO: Monitor the range here) message.EventFormat = EventMessageFormat.SystemEvent; // Format Standard SEL record SelSupport.StandardSelFormat(ref message, messageData); message.EventMessage = ExtractSystemEventRecordMessage(message.RawSensorType, message.EventTypeCode, message.RawPayload); } else if ((recordType >= 0xC0) && (recordType <= 0xDF)) { // Time Stamped OEM. (override type to reduce string repetition in resource file) message.EventFormat = EventMessageFormat.OemTimeStamped; // Format "TimeStamped OEM" SEL record SelSupport.TimeStampedOEMSelFormat(ref message, messageData); message.EventMessage = ExtractOemTimestampedEventMessage(message.RawPayload); } else if ((recordType >= 0xE0) && (recordType <= 0xFF)) { // Non TimeStamped OEM. (override type to reduce string repetition in resource file) message.EventFormat = EventMessageFormat.OemNonTimeStamped; // Format "Non TimeStamped OEM" SEL record SelSupport.NonTimestampedOemSelFormat(ref message, messageData); message.EventMessage = ExtractOemNonTimestampedEventMessage(message.RawPayload); } // add message to the collection messageCollection.EventLog.Add(message); } } } return(messageCollection); }