From 0f26a8bed65e4d3071c7791d7eb36f496dfc7188 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Wed, 23 Jan 2019 14:56:09 +0200 Subject: [PATCH] MXS-2112 Add system info to support info script --- script/maxscale_generate_support_info.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/script/maxscale_generate_support_info.py b/script/maxscale_generate_support_info.py index 3eb73d22c..9bee346e3 100755 --- a/script/maxscale_generate_support_info.py +++ b/script/maxscale_generate_support_info.py @@ -88,6 +88,13 @@ def main(argv): print(format_str.format(file_name)) output_file.writestr(file_name, contents) + # Run some commands to gather general system info. + contents = get_system_info() + if len(contents) > 0: + file_name = "system_info.txt" + print(format_str.format(file_name)) + output_file.writestr(file_name, contents) + output_file.close() @@ -197,5 +204,29 @@ def read_core_file(): return core_file_contents +def get_system_info(): + commands = ["cat /etc/os-release", "lscpu", "cat /proc/meminfo"] + total_output = "" + for command in commands: + try: + output_bytes = subprocess.check_output(command, shell=True, stderr=subprocess.PIPE) + except subprocess.CalledProcessError as e: + # If a command fails, try the next one. It may work. + message = "Error gathering system info: command \"{}\" returned {}".format( + command, e.returncode) + total_output += command + "\n" + message + "\n" + print(message) + except IOError as e: + message = "Error gathering system info: command \"{}\" could not be ran: {}".format( + command, e.strerror) + total_output += command + "\n" + message + "\n" + print(message) + else: + if len(output_bytes) > 0: + total_output += command + "\n" + output_bytes.decode("utf-8") + "\n" + + return total_output + + if __name__ == "__main__": main(sys.argv)