Try to parse output as json in case of an error exit code, and output the error key

This commit is contained in:
root 2025-11-01 21:10:15 +00:00
parent a0377961c4
commit 706b95071c

View file

@ -150,6 +150,12 @@ def run_iperf3(options) -> Union[dict, NoReturn]:
if e.errno == 2:
nagexit(3, "cannot find iperf3")
except subprocess.CalledProcessError as e:
try:
json_data = json.loads(e.output)
if "error" in json_data:
nagexit(3, json_data["error"])
except Exception as ex:
pass
nagexit(3, e.output)
nagexit(3, "what happended?")