Skip to content

Commit 7b4032e

Browse files
authored
[system health daemon] Support PSU power threshold checking (#11864)
1 parent a618728 commit 7b4032e

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/system-health/health_checker/hardware_checker.py

+12
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,18 @@ def _check_psu_status(self, config):
239239
voltage_min_th,
240240
voltage_max_th))
241241
continue
242+
243+
if not self._ignore_check(config.ignore_devices, 'psu', name, 'power_threshold'):
244+
power_overload = data_dict.get('power_overload', None)
245+
if power_overload == 'True':
246+
try:
247+
power = data_dict['power']
248+
power_critical_threshold = data_dict['power_critical_threshold']
249+
self.set_object_not_ok('PSU', name, 'power of {} ({}w) exceeds threshold ({}w)'.format(name, power, power_critical_threshold))
250+
except KeyError:
251+
self.set_object_not_ok('PSU', name, 'power of {} exceeds threshold but power or power_critical_threshold is invalid'.format(name))
252+
continue
253+
242254
self.set_object_ok('PSU', name)
243255

244256
def reset(self):

src/system-health/tests/test_system_health.py

+32
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,30 @@ def test_hardware_checker():
362362
'voltage': '10',
363363
'voltage_min_threshold': '12',
364364
'voltage_max_threshold': '15',
365+
},
366+
'PSU_INFO|PSU 6': {
367+
'presence': 'True',
368+
'status': 'True',
369+
'temp': '55',
370+
'temp_threshold': '100',
371+
'voltage': '12',
372+
'voltage_min_threshold': '12',
373+
'voltage_max_threshold': '15',
374+
'power_overload': 'True',
375+
'power': '101.0',
376+
'power_critical_threshold': '100.0',
377+
'power_warning_suppress_threshold': '90.0'
378+
},
379+
'PSU_INFO|PSU 7': {
380+
'presence': 'True',
381+
'status': 'True',
382+
'temp': '55',
383+
'temp_threshold': '100',
384+
'voltage': '12',
385+
'voltage_min_threshold': '12',
386+
'voltage_max_threshold': '15',
387+
'power_overload': 'True',
388+
'power': '101.0'
365389
}
366390
})
367391

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

427+
assert 'PSU 6' in checker._info
428+
assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 6 (101.0w) exceeds threshold (100.0w)'
429+
assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK
430+
431+
assert 'PSU 7' in checker._info
432+
assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK
433+
assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 7 exceeds threshold but power or power_critical_threshold is invalid'
434+
403435

404436
def test_config():
405437
config = Config()

0 commit comments

Comments
 (0)