Skip to content

Commit

Permalink
[system health daemon] Support PSU power threshold checking (#11864)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenxs authored Nov 21, 2022
1 parent a618728 commit 7b4032e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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']
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 is invalid'.format(name))
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_suppress_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 is invalid'


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

0 comments on commit 7b4032e

Please sign in to comment.