This commit is contained in:
parent
c3b25660ed
commit
d22c610874
@ -257,12 +257,13 @@ class HardwareChecker(HealthChecker):
|
||||
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))
|
||||
self.set_object_not_ok('PSU', name, 'System power exceeds threshold ({}w)'.format(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))
|
||||
self.set_object_not_ok('PSU', name, 'System power exceeds threshold but power_critical_threshold is invalid')
|
||||
continue
|
||||
|
||||
self.set_object_ok('PSU', name)
|
||||
|
@ -444,12 +444,12 @@ def test_hardware_checker():
|
||||
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_MSG] == 'System power 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'
|
||||
assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'System power exceeds threshold but power_critical_threshold is invalid'
|
||||
|
||||
|
||||
def test_config():
|
||||
|
Reference in New Issue
Block a user