Skip to content

Include voltage and current sensors in system health. #16646

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions src/system-health/health_checker/hardware_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class HardwareChecker(HealthChecker):
ASIC_TEMPERATURE_KEY = 'TEMPERATURE_INFO|ASIC'
FAN_TABLE_NAME = 'FAN_INFO'
PSU_TABLE_NAME = 'PSU_INFO'
VOLTAGE_SENSOR_KEY = 'VOLTAGE_INFO'
CURRENT_SENSOR_KEY = 'CURRENT_INFO'

def __init__(self):
HealthChecker.__init__(self)
Expand All @@ -26,6 +28,7 @@ def check(self, config):
self._check_asic_status(config)
self._check_fan_status(config)
self._check_psu_status(config)
self._check_sensors_status(config)

def _check_asic_status(self, config):
"""
Expand Down Expand Up @@ -268,6 +271,34 @@ def _check_psu_status(self, config):

self.set_object_ok('PSU', name)

def _check_sensors_status(self, config):
"""
Check if sensors are in valid range.
:param config: Health checker configuration
:return:
"""
if config.ignore_devices and 'sensors' in config.ignore_devices:
return

sensor_key_list = self._db.keys(self._db.STATE_DB,
HardwareChecker.VOLTAGE_SENSOR_KEY + '*')
sensor_key_list += self._db.keys(self._db.STATE_DB,
HardwareChecker.CURRENT_SENSOR_KEY + '*')
for key in sensor_key_list:
data_dict = self._db.get_all(self._db.STATE_DB, key)
sensor_table_name, sensor_name = key.split('|')
sensor_type = sensor_table_name.split('_')[0].lower()
if data_dict['warning_status'] == 'True':
self.set_object_not_ok(sensor_type, sensor_name,
'{} sensor {} measurement {} {} out of range ({},{})'.format(
sensor_type.capitalize(), sensor_name,
data_dict[sensor_type],
data_dict['unit'],
data_dict['low_threshold'],
data_dict['high_threshold']))
else:
self.set_object_ok(sensor_type, sensor_name)

def reset(self):
self._info = {}

Expand Down
Loading