-
Notifications
You must be signed in to change notification settings - Fork 21
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
INFRA-388 Converting smartmon into python and adding mock tests #1327
base: stackhpc/2024.1
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great start, many thanks. It would be good to investigate external libraries for the smart data collection / parsing.
def parse_smartctl_attributes(disk, disk_type, serial, json_data): | ||
labels = f'disk="{disk}",type="{disk_type}",serial_number="{serial}"' | ||
metrics = [] | ||
smartmon_attrs = set([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: It would be helpful to move these to a 'constant' eg. SMARTMON_ATTRS = set(..
and put each attribute on a new line.
try: | ||
version_output = run_command([SMARTCTL_PATH, '-j'], parse_json=True) | ||
smartctl_version_list = version_output.get('smartctl', {}).get('version', []) | ||
if smartctl_version_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at Python libraries for doing this?
Eg. This one looks reasonable: https://pypi.org/project/pySMART/
It can handle loading all the device metrics in via smartctl
as you are doing here.
It seems to provide some abstraction over the health state as well.
The work you've put into the tests should be directly usable
class TestSmartMon(unittest.TestCase): | ||
@patch('smartmon.run_command') | ||
def test_parse_smartctl_info(self, mock_run_command): | ||
devices_info = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to factor this example data out into a dedicated file. Then we can have a file for each HW profile, and loop over them.
No description provided.