0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-22 04:59:34 +01:00
mongodb/evergreen/functions/get_network_diagnostics.py
Tianyu Wang 72a5a3d8a8 SERVER-95930: Collect network diagnostics for failed tests (#28191)
GitOrigin-RevId: fc5c90c756d9cc21dbc4e55281bfa1d8b4a0a09b
2024-10-21 22:21:39 +00:00

22 lines
650 B
Python
Executable File

#!/usr/bin/env python3
"""Generate network diagnostics information and generate a .txt file."""
import pathlib
import shutil
import subprocess
def generate_netstat():
if shutil.which("netstat") is None:
print('Command not found: netstat. Skipping "generate and upload network diagnostics".')
return
with open("network_diagnostics.txt", "w") as outfile:
subprocess.run(["netstat"], stdout=outfile, stderr=subprocess.STDOUT, check=True)
if not pathlib.Path("resmoke_error_code").is_file():
print('resmoke_error_code not found. Skipping "generate and upload network diagnostics".')
else:
generate_netstat()