Class IpmiHelper
java.lang.Object
org.sentrysoftware.metricshub.extension.oscommand.ipmi.IpmiHelper
Utility class for Unix IPMI operations and data processing.
This class provides methods for cleaning, processing, and translating IPMI-related data.
-
Method Summary
Modifier and TypeMethodDescriptionaddSensorElementToDeviceList(List<String> deviceList, String sdrResult, String deviceType, String deviceId, String entityId, String statusArray, List<String> fruList) Add sensor information to the global device list.static StringcheckPatternAndReturnDelimitedString(String entry, Pattern patternToMatch, String leftLimit, String rightLimit) Parse the entry and get the line that matches the pattern, then return the substring delimited by the given parameters.static StringcleanSensorCommandResult(String sdrResult) Reformat the ipmitoolSdr list so that each SDR entry is on a separate line.static StringgetFanFromSensor(String sensorEntry, String sensorName, String sensorId, String location, String valueReading) Get fan information for the given sensor entry.static StringgetSensorStatusArray(String sensorEntry, String sensorName) Get the actual status of the given sensor.static StringgetTemperatureFromSensor(String sensorEntry, String sensorName, String sensorId, String location, String valueReading) Get temperature information for the given sensor entry.static StringgetVoltageFromSensor(String sensorEntry, String sensorName, String sensorId, String location, String valueReading) Get voltage information for the given sensor entry.ipmiAddHardwareSensorInfo(String sdrResult, List<String> ipmiTable) Add temperature, fan, voltage, current, and power consumption information from sensors to the given ipmiTable.ipmiBuildDeviceListFromIpmitool(String fruResult, String sdrResult) Process the data obtained from ipmitool and return a formatted device table.ipmiTranslateFromIpmitool(String fruResult, String sdrResult) Process what we got from ipmitool and return a pretty table.processFruResult(String fruResult) Process the raw result of the FRU command and return the list of good FRU and poor FRU.static StringprocessOemSpecific(String sensorName, String sensorEntry) Retrieve States Asserted entry line and reformat the entry code to deduce the correct status of the given sensor Look for all states listed (States Asserted and Assertion Events) which are located before the "Assertions Enabled" entryParse SDR records in order to extract each sensor and complete the device list.
-
Method Details
-
ipmiTranslateFromIpmitool
Process what we got from ipmitool and return a pretty table.- Parameters:
fruResult- The result from the FRU command.sdrResult- The result from the SDR command.- Returns:
- A List of Lists representing the translated ipmiTable.
-
cleanSensorCommandResult
Reformat the ipmitoolSdr list so that each SDR entry is on a separate line. Removes lines that start with "BMC req" and "-- ".- Parameters:
sdrResult- The input string containing the ipmitool SDR list.- Returns:
- The reformatted string with one line per SDR entry.
-
ipmiBuildDeviceListFromIpmitool
Process the data obtained from ipmitool and return a formatted device table.- Parameters:
fruResult- The result from the FRU command.sdrResult- The result from the SDR command.- Returns:
- The formatted device table.
-
processSdrRecords
public static List<String> processSdrRecords(String sdrResult, Map<String, List<String>> fruMap, List<String> deviceList) Parse SDR records in order to extract each sensor and complete the device list.- Parameters:
sdrResult- The result containing SDR records.fruMap- The map containing FRU information.deviceList- The list of devices to be updated.- Returns:
- The updated device list.
-
processFruResult
Process the raw result of the FRU command and return the list of good FRU and poor FRU.- Parameters:
fruResult- The raw result of the FRU command.- Returns:
- A map containing lists of good FRU, poor FRU, and all FRU entries.
-
ipmiAddHardwareSensorInfo
Add temperature, fan, voltage, current, and power consumption information from sensors to the given ipmiTable.- Parameters:
sdrResult- The result from the SDR command.ipmiTable- The existing ipmiTable to which sensor information will be added.- Returns:
- The updated ipmiTable with sensor information.
-
getVoltageFromSensor
public static String getVoltageFromSensor(String sensorEntry, String sensorName, String sensorId, String location, String valueReading) Get voltage information for the given sensor entry. Threshold1 is determined by priority: Lower Non-Critical > Lower Critical > Lower Non-Recoverable. Threshold2 is determined by priority: Upper Non-Critical > Upper Critical > Upper Non-Recoverable.- Parameters:
sensorEntry- The sensor entry to extract voltage information from.sensorName- The name of the sensor.sensorId- The ID of the sensor.location- The location of the sensor.valueReading- The current value reading of the sensor.- Returns:
- A formatted string containing voltage information.
-
getFanFromSensor
public static String getFanFromSensor(String sensorEntry, String sensorName, String sensorId, String location, String valueReading) Get fan information for the given sensor entry. Threshold1 is Lower Non-Critical if it exists. Threshold2 is determined by priority: Lower Critical > Lower Non-Recoverable.- Parameters:
sensorEntry- The sensor entry to extract fan information from.sensorName- The name of the sensor.sensorId- The ID of the sensor.location- The location of the sensor.valueReading- The current value reading of the sensor.- Returns:
- A formatted string containing fan information.
-
getTemperatureFromSensor
public static String getTemperatureFromSensor(String sensorEntry, String sensorName, String sensorId, String location, String valueReading) Get temperature information for the given sensor entry. Threshold1 is Upper Non-Critical if it exists. Threshold2 is determined by priority: Upper Critical > Upper Non-Recoverable.- Parameters:
sensorEntry- The sensor entry to extract temperature information from.sensorName- The name of the sensor.sensorId- The ID of the sensor.location- The location of the sensor.valueReading- The current value reading of the sensor.- Returns:
- A formatted string containing temperature information.
-
addSensorElementToDeviceList
public static List<String> addSensorElementToDeviceList(List<String> deviceList, String sdrResult, String deviceType, String deviceId, String entityId, String statusArray, List<String> fruList) Add sensor information to the global device list. Check if this entityID was already put into the list, then complete its description with the given status; otherwise, insert a new sensor entry.- Parameters:
deviceList- The global device list to which the sensor information is added.sdrResult- The result of the SDR command.deviceType- The type of the device.deviceId- The ID of the device.entityId- The entity ID of the sensor.statusArray- The status array of the sensor.fruList- The list of FRU entries.- Returns:
- The updated global device list.
-
getSensorStatusArray
Get the actual status of the given sensor. It looks for all states listed (States Asserted and Assertion Events) which are located before the "Assertions Enabled" entry.- Parameters:
sensorEntry- The entry containing information about the sensor.sensorName- The name of the sensor.- Returns:
- A string representing the status array of the sensor.
-
processOemSpecific
Retrieve States Asserted entry line and reformat the entry code to deduce the correct status of the given sensor Look for all states listed (States Asserted and Assertion Events) which are located before the "Assertions Enabled" entry- Parameters:
sensorName- Name of the sensorsensorEntry- Entry of the sensor- Returns:
- string
-
checkPatternAndReturnDelimitedString
public static String checkPatternAndReturnDelimitedString(String entry, Pattern patternToMatch, String leftLimit, String rightLimit) Parse the entry and get the line that matches the pattern, then return the substring delimited by the given parameters.- Parameters:
entry- The input string to parse.patternToMatch- The pattern to match in the entry.leftLimit- The left delimiter of the substring.rightLimit- The right delimiter of the substring.- Returns:
- The substring delimited by leftLimit and rightLimit in the matched line, or an empty string if not found.
-