[system-health] Add fan direction check for system health (#14509)
- Why I did it Add fan direction check to system health, all fans should be in the same direction - How I did it Add fan direction check to system health, all fans should be in the same direction - How to verify it Manual test Unit test Added sonic-mgmt test case to verify
This commit is contained in:
parent
aeaaebbafc
commit
5e893666df
@ -71,6 +71,7 @@ class HardwareChecker(HealthChecker):
|
||||
1. Check all fans are present
|
||||
2. Check all fans are in good state
|
||||
3. Check fan speed is in valid range
|
||||
4. Check all fans direction are the same
|
||||
:param config: Health checker configuration
|
||||
:return:
|
||||
"""
|
||||
@ -82,6 +83,7 @@ class HardwareChecker(HealthChecker):
|
||||
self.set_object_not_ok('Fan', 'Fan', 'Failed to get fan information')
|
||||
return
|
||||
|
||||
expect_fan_direction = None
|
||||
for key in natsorted(keys):
|
||||
key_list = key.split('|')
|
||||
if len(key_list) != 2: # error data in DB, log it and ignore
|
||||
@ -133,6 +135,18 @@ class HardwareChecker(HealthChecker):
|
||||
speed_tolerance))
|
||||
continue
|
||||
|
||||
if not self._ignore_check(config.ignore_devices, 'fan', name, 'direction'):
|
||||
direction = data_dict.get('direction', 'N/A')
|
||||
# ignore fan whose direction is not available to avoid too many false alarms
|
||||
if direction != 'N/A':
|
||||
if not expect_fan_direction:
|
||||
# initialize the expect fan direction
|
||||
expect_fan_direction = (name, direction)
|
||||
elif direction != expect_fan_direction[1]:
|
||||
self.set_object_not_ok('Fan', name,
|
||||
f'{name} direction {direction} is not aligned with {expect_fan_direction[0]} direction {expect_fan_direction[1]}')
|
||||
continue
|
||||
|
||||
status = data_dict.get('status', 'false')
|
||||
if status.lower() != 'true':
|
||||
self.set_object_not_ok('Fan', name, '{} is broken'.format(name))
|
||||
|
@ -298,7 +298,8 @@ def test_hardware_checker():
|
||||
'status': 'True',
|
||||
'speed': '60',
|
||||
'speed_target': '60',
|
||||
'speed_tolerance': '20'
|
||||
'speed_tolerance': '20',
|
||||
'direction': 'intake'
|
||||
},
|
||||
'FAN_INFO|fan2': {
|
||||
'presence': 'False',
|
||||
@ -320,6 +321,14 @@ def test_hardware_checker():
|
||||
'speed': '20',
|
||||
'speed_target': '60',
|
||||
'speed_tolerance': '20'
|
||||
},
|
||||
'FAN_INFO|fan5': {
|
||||
'presence': 'True',
|
||||
'status': 'True',
|
||||
'speed': '60',
|
||||
'speed_target': '60',
|
||||
'speed_tolerance': '20',
|
||||
'direction': 'exhaust'
|
||||
}
|
||||
})
|
||||
|
||||
@ -415,6 +424,10 @@ def test_hardware_checker():
|
||||
assert 'fan4' in checker._info
|
||||
assert checker._info['fan4'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK
|
||||
|
||||
assert 'fan5' in checker._info
|
||||
assert checker._info['fan5'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK
|
||||
assert checker._info['fan5'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'fan5 direction exhaust is not aligned with fan1 direction intake'
|
||||
|
||||
assert 'PSU 1' in checker._info
|
||||
assert checker._info['PSU 1'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_OK
|
||||
|
||||
|
Reference in New Issue
Block a user