Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[system-health] Add fan direction check for system health #175

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/system-health/health_checker/hardware_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _check_fan_status(self, config):
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
Expand Down Expand Up @@ -133,6 +134,18 @@ def _check_fan_status(self, config):
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))
Expand Down
18 changes: 16 additions & 2 deletions src/system-health/tests/test_system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,16 @@ def test_hardware_checker():
'status': 'True',
'speed': '60',
'speed_target': '60',
'speed_tolerance': '20'
'speed_tolerance': '20',
'direction': 'intake'
},
'FAN_INFO|fan2': {
'presence': 'False',
'status': 'True',
'speed': '60',
'speed_target': '60',
'speed_tolerance': '20'
'speed_tolerance': '20',

},
'FAN_INFO|fan3': {
'presence': 'True',
Expand All @@ -320,6 +322,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'
}
})

Expand Down Expand Up @@ -415,6 +425,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

Expand Down