mirror of
https://opendev.org/x/pyghmi
synced 2025-08-21 02:20:19 +00:00
Add 'get_health' to Command class
Provide a convenience function that summarizes the overall health of the managed system based. Currently, it just enumerates all SDR indicated sensors seeking unhealthy readings. Change-Id: Ifce6d05623acc86b6bf42ceb57824b65eefa36ae
This commit is contained in:
@@ -60,6 +60,8 @@ def docommand(result, ipmisession):
|
||||
elif cmmand == 'sensors':
|
||||
for reading in ipmisession.get_sensor_data():
|
||||
print repr(reading)
|
||||
elif cmmand == 'health':
|
||||
print repr(ipmisession.get_health())
|
||||
elif cmmand == 'raw':
|
||||
print ipmisession.raw_command(netfn=int(args[0]),
|
||||
command=int(args[1]),
|
||||
|
@@ -15,6 +15,7 @@
|
||||
# limitations under the License.
|
||||
# This represents the low layer message framing portion of IPMI
|
||||
|
||||
import pyghmi.constants as const
|
||||
import pyghmi.exceptions as exc
|
||||
|
||||
from pyghmi.ipmi.private import session
|
||||
@@ -291,6 +292,22 @@ class Command(object):
|
||||
self.powerstate = 'on' if (response['data'][0] & 1) else 'off'
|
||||
return {'powerstate': self.powerstate}
|
||||
|
||||
def get_health(self):
|
||||
"""Summarize health of managed system
|
||||
|
||||
This provides a summary of the health of the managed system.
|
||||
It additionally provides an iterable list of reasons for
|
||||
warning, critical, or failed assessments.
|
||||
"""
|
||||
summary = {}
|
||||
summary['badreadings'] = []
|
||||
summary['health'] = const.Health.Ok
|
||||
for reading in self.get_sensor_data():
|
||||
if reading.health != const.Health.Ok:
|
||||
summary['health'] |= reading.health
|
||||
summary['badreadings'].append(reading)
|
||||
return summary
|
||||
|
||||
def get_sensor_data(self):
|
||||
"""Get sensor reading objects
|
||||
|
||||
|
Reference in New Issue
Block a user