Merge "Add maximum fan rpm to hardware.ipmi.fan metrics"

This commit is contained in:
Zuul 2025-03-26 09:40:09 +00:00 committed by Gerrit Code Review
commit ef25114840
3 changed files with 56 additions and 0 deletions

View File

@ -107,6 +107,10 @@ class SensorPollster(plugin_base.PollsterBase):
'node': self.conf.host
}
extra_metadata = self.get_extra_sensor_metadata(sensor_data)
if extra_metadata:
metadata.update(extra_metadata)
yield sample.Sample(
name='hardware.ipmi.%s' % self.METRIC.lower(),
type=sample.TYPE_GAUGE,
@ -117,6 +121,11 @@ class SensorPollster(plugin_base.PollsterBase):
resource_id=resource_id,
resource_metadata=metadata)
def get_extra_sensor_metadata(self, sensor_data):
# override get_extra_sensor_metadata to add specific metrics for
# each sensor
return {}
class TemperatureSensorPollster(SensorPollster):
METRIC = 'Temperature'
@ -129,6 +138,16 @@ class CurrentSensorPollster(SensorPollster):
class FanSensorPollster(SensorPollster):
METRIC = 'Fan'
def get_extra_sensor_metadata(self, sensor_data):
try:
return {
"maximum_rpm": sensor_data['Normal Maximum'],
}
except KeyError:
# Maximum rpm might not be reported when usage
# is reported as percent
return {}
class VoltageSensorPollster(SensorPollster):
METRIC = 'Voltage'

View File

@ -606,6 +606,25 @@ FAN_DATA = {
}
FAN_DATA_PERCENT = {
'Fan 1 (0x23)': {
'Sensor ID': 'Fan 1 (0x23)',
'Entity ID': '7.1 (System Board)',
'Sensor Type (Threshold)': 'Fan (0x04)',
'Sensor Reading': '47.040 (+/- 0) percent',
'Status': 'ok',
'Positive Hysteresis': 'Unspecified',
'Negative Hysteresis': 'Unspecified',
'Minimum sensor range': 'Unspecified',
'Maximum sensor range': 'Unspecified',
'Event Message Control': 'Global Disable Only',
'Readable Thresholds': '',
'Settable Thresholds': '',
'Assertions Enabled': ''
}
}
VOLTAGE_DATA = {
'Planar 12V (0x18)': {
'Status': 'ok',

View File

@ -28,6 +28,10 @@ FAN_SENSOR_DATA = {
'Fan': ipmi_test_data.FAN_DATA
}
FAN_SENSOR_DATA_PERCENT = {
'Fan': ipmi_test_data.FAN_DATA_PERCENT
}
VOLTAGE_SENSOR_DATA = {
'Voltage': ipmi_test_data.VOLTAGE_DATA
}
@ -108,6 +112,20 @@ class TestFanSensorPollster(base.TestPollsterBase):
self._verify_metering(12, float(7140), self.CONF.host)
class TestFanPercentSensorPollster(base.TestPollsterBase):
def fake_sensor_data(self, sensor_type):
return FAN_SENSOR_DATA_PERCENT
def make_pollster(self):
return sensor.FanSensorPollster(self.CONF)
def test_get_samples(self):
self._test_get_samples()
self._verify_metering(1, float(47.04), self.CONF.host)
class TestCurrentSensorPollster(base.TestPollsterBase):
def fake_sensor_data(self, sensor_type):