From c85034e5bc9db22dfcebb7e67f3b1b98044a3811 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 8 Dec 2020 19:39:39 +0100 Subject: Remove endl from mac and catch error if scmartctl version < 7 --- modules.d/bas-python/scripts/00collect_hw_info_json.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-55-g7522