diff options
author | Jannik Schönartz | 2020-12-08 19:39:39 +0100 |
---|---|---|
committer | Jannik Schönartz | 2020-12-08 19:39:39 +0100 |
commit | c85034e5bc9db22dfcebb7e67f3b1b98044a3811 (patch) | |
tree | 6cdd9051d07e39ec3fc8ead40263f657d177c01b | |
parent | Add fallback for ip and mac addresses (diff) | |
download | systemd-init-c85034e5bc9db22dfcebb7e67f3b1b98044a3811.tar.gz systemd-init-c85034e5bc9db22dfcebb7e67f3b1b98044a3811.tar.xz systemd-init-c85034e5bc9db22dfcebb7e67f3b1b98044a3811.zip |
Remove endl from mac and catch error if scmartctl version < 7
-rwxr-xr-x | modules.d/bas-python/scripts/00collect_hw_info_json.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules.d/bas-python/scripts/00collect_hw_info_json.py b/modules.d/bas-python/scripts/00collect_hw_info_json.py index 0c14a019..c22e5f36 100755 --- a/modules.d/bas-python/scripts/00collect_hw_info_json.py +++ b/modules.d/bas-python/scripts/00collect_hw_info_json.py @@ -51,7 +51,13 @@ def get_smartctl(): for d in filteredDisks: output = run_subprocess('smartctl -x --json /dev/disk/by-path/' + d) if isinstance(output, str): - smartctl[d] = json.loads(output) + try: + smartctl[d] = json.loads(output) + except ValueError as e: + print('smartctl failed with error:') + print(e) + print() + return [] return smartctl # Get and process "lspci -mn" output @@ -113,6 +119,8 @@ def get_net_fallback(): continue net = {} net['mac'] = run_subprocess('cat /sys/class/net/' + interface + '/address') + if net['mac'].endswith('\n'): + net['mac'] = net['mac'][:-1] result[interface] = net # Get IP address |