Have average CPU handle totally missing sensors
If not even unavailable sensors are found, create a new sensor to hold the unavailable data. Change-Id: I2865ff6b407955cb69655e1ae80da22c31bb6d5a
This commit is contained in:
parent
0335e90e4c
commit
b91ea93fe7
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import pyghmi.exceptions as exc
|
import pyghmi.exceptions as exc
|
||||||
import pyghmi.ipmi.private.constants as event_const
|
import pyghmi.ipmi.private.constants as event_const
|
||||||
|
import pyghmi.ipmi.sdr as ipmisdr
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
class OEMHandler(object):
|
class OEMHandler(object):
|
||||||
@ -67,16 +68,14 @@ class OEMHandler(object):
|
|||||||
if sensor.entity == 'Processor':
|
if sensor.entity == 'Processor':
|
||||||
self._processor_names.append(sensor.sensor_name)
|
self._processor_names.append(sensor.sensor_name)
|
||||||
readingvalues = []
|
readingvalues = []
|
||||||
tmplreading = None
|
|
||||||
for procsensor in self._processor_names:
|
for procsensor in self._processor_names:
|
||||||
try:
|
try:
|
||||||
reading = ipmicmd.get_sensor_reading(procsensor)
|
reading = ipmicmd.get_sensor_reading(procsensor)
|
||||||
except exc.IpmiException:
|
except exc.IpmiException:
|
||||||
continue
|
continue
|
||||||
tmplreading = reading
|
|
||||||
if reading.value is not None:
|
if reading.value is not None:
|
||||||
readingvalues.append(float(reading.value))
|
readingvalues.append(float(reading.value))
|
||||||
tmplreading.name = 'Average Processor Temperature'
|
tmplreading = ipmisdr.SensorReading({'name': 'Average Processor Temperature', 'type': 'Temperature'}, '°C')
|
||||||
if readingvalues:
|
if readingvalues:
|
||||||
tmplreading.value = sum(readingvalues) / len(readingvalues)
|
tmplreading.value = sum(readingvalues) / len(readingvalues)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user