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 daemon] Support PSU power threshold checking #11864

Merged
merged 6 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions src/system-health/health_checker/hardware_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ def _check_psu_status(self, config):
voltage_min_th,
voltage_max_th))
continue

if not self._ignore_check(config.ignore_devices, 'psu', name, 'power_threshold'):
power_overload = data_dict.get('power_overload', None)
if power_overload == 'True':
try:
power = data_dict['power']
power_critical_threshold = data_dict['power_critical_threshold']
stephenxs marked this conversation as resolved.
Show resolved Hide resolved
self.set_object_not_ok('PSU', name, 'power of {} ({}w) exceeds threshold ({}w)'.format(name, power, power_critical_threshold))
except KeyError:
self.set_object_not_ok('PSU', name, 'power of {} exceeds threshold but power or power_critical_threshold does not invalid'.format(name))
stephenxs marked this conversation as resolved.
Show resolved Hide resolved
continue

self.set_object_ok('PSU', name)

def reset(self):
Expand Down
32 changes: 32 additions & 0 deletions src/system-health/tests/test_system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,30 @@ def test_hardware_checker():
'voltage': '10',
'voltage_min_threshold': '12',
'voltage_max_threshold': '15',
},
'PSU_INFO|PSU 6': {
'presence': 'True',
'status': 'True',
'temp': '55',
'temp_threshold': '100',
'voltage': '12',
'voltage_min_threshold': '12',
'voltage_max_threshold': '15',
'power_overload': 'True',
'power': '101.0',
'power_critical_threshold': '100.0',
'power_warning_threshold': '90.0'
},
'PSU_INFO|PSU 7': {
'presence': 'True',
'status': 'True',
'temp': '55',
'temp_threshold': '100',
'voltage': '12',
'voltage_min_threshold': '12',
'voltage_max_threshold': '15',
'power_overload': 'True',
'power': '101.0'
}
})

Expand Down Expand Up @@ -400,6 +424,14 @@ def test_hardware_checker():
assert 'PSU 5' in checker._info
assert checker._info['PSU 5'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK

assert 'PSU 6' in checker._info
assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 6 (101.0w) exceeds threshold (100.0w)'
assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK

assert 'PSU 7' in checker._info
assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK
assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 7 exceeds threshold but power or power_critical_threshold does not invalid'


def test_config():
config = Config()
Expand Down