From 35117a72491a2a2c5faefcb9418b94d0dba75e7e Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:34:44 +0530 Subject: [PATCH 01/25] Added custom dir input var --- script/get-platform-details/_cm.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/get-platform-details/_cm.json b/script/get-platform-details/_cm.json index 3c6c5b4bd6..7168f1ce27 100644 --- a/script/get-platform-details/_cm.json +++ b/script/get-platform-details/_cm.json @@ -4,6 +4,9 @@ "automation_uid": "5b4e0237da074764", "cache": false, "category": "Platform information", + "input_mapping": { + "platform_details_dir": "CM_PLATFORM_DETAILS_DIR_PATH" + }, "deps": [ { "tags": "detect,os" From d9df89eb3c919ac49a3a4cdd07e3aef747f2a427 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:37:29 +0530 Subject: [PATCH 02/25] save system_info.txt to specific folder --- script/get-platform-details/customize.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index 47f1bab8b8..d23642fe86 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -22,8 +22,11 @@ def preprocess(i): #if not check_installation("cpupower",os_info): env['CM_INSTALL_CPUPOWER'] = 'True' - if env.get('CM_PLATFORM_DETAILS_FILE_PATH', '') == '': - env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(os.getcwd(), "system_info.txt") + if env.get('CM_PLATFORM_DETAILS_DIR_PATH', '') == '': + env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(os.getcwd(), "system_info.txt") + else: + env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(env['CM_PLATFORM_DETAILS_DIR_PATH'], "system_info.txt") + return {'return':0} From 2ba7bece1b40898808b85b86fd168c27ddb0a25c Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:43:57 +0530 Subject: [PATCH 03/25] Handle automatic creation of directory if not present --- script/get-platform-details/customize.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index d23642fe86..1a5cb6ff16 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -25,6 +25,8 @@ def preprocess(i): if env.get('CM_PLATFORM_DETAILS_DIR_PATH', '') == '': env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(os.getcwd(), "system_info.txt") else: + if not os.path.exists(env['CM_PLATFORM_DETAILS_DIR_PATH']): + os.makedirs(env['CM_PLATFORM_DETAILS_DIR_PATH']) env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(env['CM_PLATFORM_DETAILS_DIR_PATH'], "system_info.txt") From 4306e658279de0804872964f9b2892378d6f2f66 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:02:35 +0530 Subject: [PATCH 04/25] input mapping name change --- script/get-platform-details/_cm.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/get-platform-details/_cm.json b/script/get-platform-details/_cm.json index 7168f1ce27..506d865f62 100644 --- a/script/get-platform-details/_cm.json +++ b/script/get-platform-details/_cm.json @@ -5,7 +5,7 @@ "cache": false, "category": "Platform information", "input_mapping": { - "platform_details_dir": "CM_PLATFORM_DETAILS_DIR_PATH" + "out_dir_path": "CM_PLATFORM_DETAILS_DIR_PATH" }, "deps": [ { From 71655a91431d7da88cbe44d8e1b85f7ee7ab1f31 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:13:53 +0530 Subject: [PATCH 05/25] added input mapping for file name --- script/get-platform-details/_cm.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/get-platform-details/_cm.json b/script/get-platform-details/_cm.json index 506d865f62..5a99bcddfd 100644 --- a/script/get-platform-details/_cm.json +++ b/script/get-platform-details/_cm.json @@ -5,7 +5,8 @@ "cache": false, "category": "Platform information", "input_mapping": { - "out_dir_path": "CM_PLATFORM_DETAILS_DIR_PATH" + "out_dir_path": "CM_PLATFORM_DETAILS_DIR_PATH", + "out_file_name": "CM_PLATFORM_DETAILS_FILE_NAME" }, "deps": [ { From 71a57ed2c405d2b14eea1ec543ae9851a61ab3b3 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:14:22 +0530 Subject: [PATCH 06/25] Updated file path --- script/get-platform-details/customize.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index 1a5cb6ff16..62fb2821f4 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -21,14 +21,13 @@ def preprocess(i): #if not check_installation("cpupower",os_info): env['CM_INSTALL_CPUPOWER'] = 'True' - - if env.get('CM_PLATFORM_DETAILS_DIR_PATH', '') == '': - env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(os.getcwd(), "system_info.txt") - else: - if not os.path.exists(env['CM_PLATFORM_DETAILS_DIR_PATH']): - os.makedirs(env['CM_PLATFORM_DETAILS_DIR_PATH']) - env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(env['CM_PLATFORM_DETAILS_DIR_PATH'], "system_info.txt") - + + if env.get('CM_PLATFORM_DETAILS_FILE_PATH', '') == '': + if env.get('CM_PLATFORM_DETAILS_DIR_PATH', '') == '': + env['CM_PLATFORM_DETAILS_DIR_PATH'] = os.getcwd() + if env.get('CM_PLATFORM_DETAILS_FILE_NAME', '') == '': + env['CM_PLATFORM_DETAILS_FILE_NAME'] = "system_info.txt" + env['CM_PLATFORM_DETAILS_FILE_PATH'] = os.path.join(env['CM_PLATFORM_DETAILS_DIR_PATH'], env['CM_PLATFORM_DETAILS_FILE_NAME']) return {'return':0} From c81e33155b3db5dceafafed3beec310961406c17 Mon Sep 17 00:00:00 2001 From: anandhu-eng Date: Fri, 25 Oct 2024 19:08:56 +0530 Subject: [PATCH 07/25] handle commands requiring sudo --- script/get-platform-details/_cm.json | 3 +++ script/get-platform-details/customize.py | 4 +-- script/get-platform-details/run.sh | 32 ++++++++++++++++++------ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/script/get-platform-details/_cm.json b/script/get-platform-details/_cm.json index 5a99bcddfd..384837a28e 100644 --- a/script/get-platform-details/_cm.json +++ b/script/get-platform-details/_cm.json @@ -12,6 +12,9 @@ { "tags": "detect,os" }, + { + "tags": "detect,sudo" + }, { "tags": "get,sys-util,generic,_psmisc" }, diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index 62fb2821f4..b3e72aaf55 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -13,8 +13,8 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - if os_info['platform'] == "windows": - return {'return':1, 'error':'get-platform-details script not yet supported in windows!'} + #if os_info['platform'] == "windows": + # return {'return':1, 'error':'get-platform-details script not yet supported in windows!'} if not check_installation("numactl",os_info): env['CM_INSTALL_NUMACTL'] = 'True' diff --git a/script/get-platform-details/run.sh b/script/get-platform-details/run.sh index 481319f223..36bfc74db9 100644 --- a/script/get-platform-details/run.sh +++ b/script/get-platform-details/run.sh @@ -46,8 +46,12 @@ else echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "8. numactl --hardware" >> $OUTPUT_FILE - eval "numactl --hardware" >> $OUTPUT_FILE - #test $? -eq 0 || exit $? + if [[ ${CM_SUDO_USER} == "yes" ]]; then + eval "${CM_SUDO} numactl --hardware" >> $OUTPUT_FILE + test $? -eq 0 || exit $? + else + echo "Requires SUDO permission" >> $OUTPUT_FILE + fi echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "9. /proc/meminfo" >> $OUTPUT_FILE @@ -81,8 +85,12 @@ else echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "15. sysctl" >> $OUTPUT_FILE - eval "sudo sysctl -a" >> $OUTPUT_FILE - #test $? -eq 0 || exit $? + if [[ ${CM_SUDO_USER} == "yes" ]]; then + eval "${CM_SUDO} sysctl -a" >> $OUTPUT_FILE + test $? -eq 0 || exit $? + else + echo "Requires SUDO permission" >> $OUTPUT_FILE + fi echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "16. /sys/kernel/mm/transparent_hugepage" >> $OUTPUT_FILE @@ -111,13 +119,21 @@ else echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "21. dmidecode" >> $OUTPUT_FILE - eval "sudo dmidecode" >> $OUTPUT_FILE - #test $? -eq 0 || exit $? + if [[ ${CM_SUDO_USER} == "yes" ]]; then + eval "${CM_SUDO} dmidecode" >> $OUTPUT_FILE + test $? -eq 0 || exit $? + else + echo "Requires SUDO permission" >> $OUTPUT_FILE + fi echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "22. BIOS" >> $OUTPUT_FILE - eval "sudo dmidecode -t bios" >> $OUTPUT_FILE - #test $? -eq 0 || exit $? + if [[ ${CM_SUDO_USER} == "yes" ]]; then + eval "${CM_SUDO} dmidecode -t bios" >> $OUTPUT_FILE + test $? -eq 0 || exit $? + else + echo "Requires SUDO permission" >> $OUTPUT_FILE + fi echo "------------------------------------------------------------" >> $OUTPUT_FILE echo "System information has been saved to $PWD/$OUTPUT_FILE" From 0738add636c89904313ddce63fabd6df35363176 Mon Sep 17 00:00:00 2001 From: anandhu-eng Date: Fri, 25 Oct 2024 19:17:08 +0530 Subject: [PATCH 08/25] changes for platform details --- script/app-mlperf-inference/_cm.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script/app-mlperf-inference/_cm.yaml b/script/app-mlperf-inference/_cm.yaml index 45094cacbc..928709a8f4 100644 --- a/script/app-mlperf-inference/_cm.yaml +++ b/script/app-mlperf-inference/_cm.yaml @@ -27,6 +27,7 @@ default_env: CM_MLPERF_RUN_STYLE: test CM_TEST_QUERY_COUNT: '10' CM_MLPERF_QUANTIZATION: off + CM_GET_PLATFORM_DETAILS: yes env: CM_MLPERF_PRINT_SUMMARY: "no" @@ -114,8 +115,6 @@ posthook_deps: - tags: get,mlperf,sut,description #populate system meta information like framework - tags: get,platform,details enable_if_any_env: - CM_SUDO_USER: - - yes CM_GET_PLATFORM_DETAILS: - yes skip_if_env: From 32d9239e77835b21078cc2a4b0882f63b007397a Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:54:12 +0530 Subject: [PATCH 09/25] add echo for debug - WIP --- script/get-platform-details/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/get-platform-details/run.sh b/script/get-platform-details/run.sh index 36bfc74db9..fb124524b6 100644 --- a/script/get-platform-details/run.sh +++ b/script/get-platform-details/run.sh @@ -86,6 +86,7 @@ else echo "15. sysctl" >> $OUTPUT_FILE if [[ ${CM_SUDO_USER} == "yes" ]]; then + echo "${CM_SUDO} sysctl -a" eval "${CM_SUDO} sysctl -a" >> $OUTPUT_FILE test $? -eq 0 || exit $? else From 4b914c3ca0ab6fa41f99c2663d298feee2f73ff0 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 17:40:55 +0530 Subject: [PATCH 10/25] typo + test commit to fix gh action error --- script/detect-sudo/customize.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/detect-sudo/customize.py b/script/detect-sudo/customize.py index dbc9b89705..c82dd7a979 100644 --- a/script/detect-sudo/customize.py +++ b/script/detect-sudo/customize.py @@ -99,10 +99,11 @@ def prompt_sudo(): try: r = subprocess.check_output(["sudo", "-p", msg, "echo", "Check sudo"], stderr=subprocess.STDOUT, timeout=20) + print(r) print(r.decode('utf-8')) # Decode bytes to string return 0 except subprocess.TimeoutExpired: - reset_terminal() # Reset terminal to sane state + reset_terminal() # Reset terminal to same state if not prompt_retry(): # If the user chooses not to retry or times out return -1 except subprocess.CalledProcessError as e: From 5fb3ea302ec59e7ae6ecdf1a79956ee6d9e695e1 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 18:38:04 +0530 Subject: [PATCH 11/25] test commit for gh error - WIP --- script/get-platform-details/run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/get-platform-details/run.sh b/script/get-platform-details/run.sh index fb124524b6..94a607af94 100644 --- a/script/get-platform-details/run.sh +++ b/script/get-platform-details/run.sh @@ -47,6 +47,7 @@ else echo "8. numactl --hardware" >> $OUTPUT_FILE if [[ ${CM_SUDO_USER} == "yes" ]]; then + echo "${CM_SUDO} numactl --hardware" eval "${CM_SUDO} numactl --hardware" >> $OUTPUT_FILE test $? -eq 0 || exit $? else @@ -87,7 +88,7 @@ else echo "15. sysctl" >> $OUTPUT_FILE if [[ ${CM_SUDO_USER} == "yes" ]]; then echo "${CM_SUDO} sysctl -a" - eval "${CM_SUDO} sysctl -a" >> $OUTPUT_FILE + eval "${CM_SUDO} sudo sysctl -a" >> $OUTPUT_FILE test $? -eq 0 || exit $? else echo "Requires SUDO permission" >> $OUTPUT_FILE From d5ac90c875273df474e8cbbe03b9280ec8c3660a Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:03:22 +0530 Subject: [PATCH 12/25] bug fix - WIP --- script/detect-sudo/customize.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/detect-sudo/customize.py b/script/detect-sudo/customize.py index c82dd7a979..23c2f9ad0c 100644 --- a/script/detect-sudo/customize.py +++ b/script/detect-sudo/customize.py @@ -20,6 +20,8 @@ def preprocess(i): env['CM_SUDO_USER'] = "yes" if os.geteuid() == 0: env['CM_SUDO'] = '' #root user does not need sudo + else: + env['CM_SUDO'] = 'sudo' else: if can_execute_sudo_without_password(): env['CM_SUDO_USER'] = "yes" From 24d0dda027876070a474b422e7d024260a1767c1 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:04:04 +0530 Subject: [PATCH 13/25] test commit for gh error - WIP --- script/get-platform-details/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/get-platform-details/run.sh b/script/get-platform-details/run.sh index 94a607af94..fc8e4ad36c 100644 --- a/script/get-platform-details/run.sh +++ b/script/get-platform-details/run.sh @@ -88,7 +88,7 @@ else echo "15. sysctl" >> $OUTPUT_FILE if [[ ${CM_SUDO_USER} == "yes" ]]; then echo "${CM_SUDO} sysctl -a" - eval "${CM_SUDO} sudo sysctl -a" >> $OUTPUT_FILE + eval "${CM_SUDO} sysctl -a" >> $OUTPUT_FILE test $? -eq 0 || exit $? else echo "Requires SUDO permission" >> $OUTPUT_FILE From 7ed8fe8566b034be26633923b915487d7d4d0482 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:19:07 +0530 Subject: [PATCH 14/25] Update regex condition for new env keys --- script/detect-sudo/_cm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/detect-sudo/_cm.yaml b/script/detect-sudo/_cm.yaml index 56c83b8304..64b60a5f6c 100644 --- a/script/detect-sudo/_cm.yaml +++ b/script/detect-sudo/_cm.yaml @@ -9,7 +9,7 @@ cache: false category: DevOps automation new_env_keys: - - CM_SUDO_* + - CM_SUDO* tags: - detect From 46762d948332a23c44853cf8e4b13ee8a09f90eb Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:49:00 +0530 Subject: [PATCH 15/25] Skip get-platform details for non linux systems --- script/get-platform-details/customize.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index b3e72aaf55..d91997ce1f 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -13,7 +13,9 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - #if os_info['platform'] == "windows": + if os_info['platform'] != "linux": + print("WARNING: get-platform-details is not yet supported for non linux systems. Skipping for now...") + return {return: 0} # return {'return':1, 'error':'get-platform-details script not yet supported in windows!'} if not check_installation("numactl",os_info): From b15bc8a8cfcc7a56e4c186b6be3adf7226bfc74f Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:49:35 +0530 Subject: [PATCH 16/25] fix typo --- script/get-platform-details/customize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index d91997ce1f..f0e613874f 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -15,7 +15,7 @@ def preprocess(i): if os_info['platform'] != "linux": print("WARNING: get-platform-details is not yet supported for non linux systems. Skipping for now...") - return {return: 0} + return {'return': 0} # return {'return':1, 'error':'get-platform-details script not yet supported in windows!'} if not check_installation("numactl",os_info): From 5d62c16e618b971a3bb906b1dd55d1952cc4caa8 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 20:05:06 +0530 Subject: [PATCH 17/25] skip dependency installation on non supported system --- script/get-platform-details/_cm.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/script/get-platform-details/_cm.json b/script/get-platform-details/_cm.json index 384837a28e..6361933a1a 100644 --- a/script/get-platform-details/_cm.json +++ b/script/get-platform-details/_cm.json @@ -13,15 +13,35 @@ "tags": "detect,os" }, { + "skip_if_env": { + "CM_HOST_OS_TYPE": [ + "windows" + ] + }, "tags": "detect,sudo" }, { + "skip_if_env": { + "CM_HOST_OS_TYPE": [ + "windows" + ] + }, "tags": "get,sys-util,generic,_psmisc" }, { + "enable_if_env": { + "CM_HOST_OS_TYPE": [ + "linux" + ] + }, "tags": "get,sys-util,generic,_systemd" }, { + "enable_if_env": { + "CM_HOST_OS_TYPE": [ + "linux" + ] + }, "tags": "get,sys-util,generic,_dmidecode" } ], From 23c7ea7bb0e3dc26671955910e81866a996f0f91 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Sat, 26 Oct 2024 21:59:11 +0530 Subject: [PATCH 18/25] code clean --- script/detect-sudo/customize.py | 1 - 1 file changed, 1 deletion(-) diff --git a/script/detect-sudo/customize.py b/script/detect-sudo/customize.py index 23c2f9ad0c..bf9e4e349d 100644 --- a/script/detect-sudo/customize.py +++ b/script/detect-sudo/customize.py @@ -101,7 +101,6 @@ def prompt_sudo(): try: r = subprocess.check_output(["sudo", "-p", msg, "echo", "Check sudo"], stderr=subprocess.STDOUT, timeout=20) - print(r) print(r.decode('utf-8')) # Decode bytes to string return 0 except subprocess.TimeoutExpired: From 31723a83a049bee4bee1455e1fba02720c9276e6 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 29 Oct 2024 01:54:19 +0530 Subject: [PATCH 19/25] corrected typo --- script/detect-sudo/customize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/detect-sudo/customize.py b/script/detect-sudo/customize.py index bf9e4e349d..31c72ba9d6 100644 --- a/script/detect-sudo/customize.py +++ b/script/detect-sudo/customize.py @@ -104,7 +104,7 @@ def prompt_sudo(): print(r.decode('utf-8')) # Decode bytes to string return 0 except subprocess.TimeoutExpired: - reset_terminal() # Reset terminal to same state + reset_terminal() # Reset terminal to sane state if not prompt_retry(): # If the user chooses not to retry or times out return -1 except subprocess.CalledProcessError as e: From 1e7d5878381a9935fb9c7321935bcb951401740c Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 29 Oct 2024 02:12:47 +0530 Subject: [PATCH 20/25] WIP - handle workload of different OS through different scripts --- script/get-platform-details/customize.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index f0e613874f..1de6969afe 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -13,10 +13,8 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - if os_info['platform'] != "linux": - print("WARNING: get-platform-details is not yet supported for non linux systems. Skipping for now...") - return {'return': 0} - # return {'return':1, 'error':'get-platform-details script not yet supported in windows!'} + if os_info['platform'] == "darwin": + i['run_script_input']['script_name'] = "run-macos" if not check_installation("numactl",os_info): env['CM_INSTALL_NUMACTL'] = 'True' From db93c53dd00b17f47cb1ab5f347f3a45571d42f3 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 29 Oct 2024 02:13:45 +0530 Subject: [PATCH 21/25] updated warning message --- script/get-platform-details/run.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/get-platform-details/run.bat b/script/get-platform-details/run.bat index 73412b64ab..fcde181c03 100644 --- a/script/get-platform-details/run.bat +++ b/script/get-platform-details/run.bat @@ -1 +1 @@ -echo "This CM script not supported for windows yet" +echo "WARNING: get-platform-details script is fully supported on linux systems only." From 984c30be1c2bf03e7758ebe4e5cade253d177613 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 29 Oct 2024 02:14:30 +0530 Subject: [PATCH 22/25] Create run-macos.sh --- script/get-platform-details/run-macos.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 script/get-platform-details/run-macos.sh diff --git a/script/get-platform-details/run-macos.sh b/script/get-platform-details/run-macos.sh new file mode 100644 index 0000000000..fcde181c03 --- /dev/null +++ b/script/get-platform-details/run-macos.sh @@ -0,0 +1 @@ +echo "WARNING: get-platform-details script is fully supported on linux systems only." From 2f0191efdaf8a33d723ffdcc0d0c74b071aaa2a3 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 29 Oct 2024 02:31:24 +0530 Subject: [PATCH 23/25] enable numactl and linux-tools for linux system only --- script/get-platform-details/_cm.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/get-platform-details/_cm.json b/script/get-platform-details/_cm.json index 6361933a1a..11c57baa18 100644 --- a/script/get-platform-details/_cm.json +++ b/script/get-platform-details/_cm.json @@ -50,6 +50,9 @@ "enable_if_env": { "CM_INSTALL_NUMACTL": [ "True" + ], + "CM_HOST_OS_TYPE": [ + "linux" ] }, "tags": "get,sys-util,generic,_numactl" @@ -58,6 +61,9 @@ "enable_if_env": { "CM_INSTALL_CPUPOWER": [ "True" + ], + "CM_HOST_OS_TYPE": [ + "linux" ] }, "tags": "get,sys-util,generic,_linux-tools" From c9dbd4034040db8ff7ec2e9a40e7d7e0d6e03218 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 29 Oct 2024 02:35:05 +0530 Subject: [PATCH 24/25] Code clean --- script/get-platform-details/run.sh | 242 ++++++++++++++--------------- 1 file changed, 119 insertions(+), 123 deletions(-) diff --git a/script/get-platform-details/run.sh b/script/get-platform-details/run.sh index fc8e4ad36c..d3fc7e0d37 100644 --- a/script/get-platform-details/run.sh +++ b/script/get-platform-details/run.sh @@ -5,138 +5,134 @@ OUTPUT_FILE="$CM_PLATFORM_DETAILS_FILE_PATH" #echo $OUTPUT_FILE echo "WARNING: sudo permission is needed for some of the below commands" -if [[ ${CM_HOST_OS_FLAVOR} == "macos" ]]; then - echo "WARNING: To be done for the mac os" -else - echo "Platform Details" > $OUTPUT_FILE - echo "" >> $OUTPUT_FILE - echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "1. uname -a" >> $OUTPUT_FILE - eval "uname -a" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "2. w" >> $OUTPUT_FILE - eval "w" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "3. Username" >> $OUTPUT_FILE - echo "From environment variable \$USER: $USER" >> $OUTPUT_FILE - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "4. ulimit -a" >> $OUTPUT_FILE - eval "ulimit -a" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "5. sysinfo process ancestry" >> $OUTPUT_FILE - eval "pstree" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "6. /proc/cpuinfo" >> $OUTPUT_FILE - eval "cat /proc/cpuinfo" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "7. lscpu" >> $OUTPUT_FILE - eval "lscpu" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "8. numactl --hardware" >> $OUTPUT_FILE - if [[ ${CM_SUDO_USER} == "yes" ]]; then - echo "${CM_SUDO} numactl --hardware" - eval "${CM_SUDO} numactl --hardware" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - else - echo "Requires SUDO permission" >> $OUTPUT_FILE - fi - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "9. /proc/meminfo" >> $OUTPUT_FILE - eval "cat /proc/meminfo" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "10. who -r" >> $OUTPUT_FILE - eval "who -r" >> $OUTPUT_FILE +echo "Platform Details" > $OUTPUT_FILE +echo "" >> $OUTPUT_FILE +echo "------------------------------------------------------------" >> $OUTPUT_FILE +echo "1. uname -a" >> $OUTPUT_FILE +eval "uname -a" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "2. w" >> $OUTPUT_FILE +eval "w" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "3. Username" >> $OUTPUT_FILE +echo "From environment variable \$USER: $USER" >> $OUTPUT_FILE +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "4. ulimit -a" >> $OUTPUT_FILE +eval "ulimit -a" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "5. sysinfo process ancestry" >> $OUTPUT_FILE +eval "pstree" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "6. /proc/cpuinfo" >> $OUTPUT_FILE +eval "cat /proc/cpuinfo" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "7. lscpu" >> $OUTPUT_FILE +eval "lscpu" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "8. numactl --hardware" >> $OUTPUT_FILE +if [[ ${CM_SUDO_USER} == "yes" ]]; then + echo "${CM_SUDO} numactl --hardware" + eval "${CM_SUDO} numactl --hardware" >> $OUTPUT_FILE test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "11. Systemd service manager version" >> $OUTPUT_FILE - eval "systemctl --version | head -n 1" >> $OUTPUT_FILE +else + echo "Requires SUDO permission" >> $OUTPUT_FILE +fi +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "9. /proc/meminfo" >> $OUTPUT_FILE +eval "cat /proc/meminfo" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "10. who -r" >> $OUTPUT_FILE +eval "who -r" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "11. Systemd service manager version" >> $OUTPUT_FILE +eval "systemctl --version | head -n 1" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "12. Services, from systemctl list-unit-files" >> $OUTPUT_FILE +eval "systemctl list-unit-files" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "13. Linux kernel boot-time arguments, from /proc/cmdline" >> $OUTPUT_FILE +eval "cat /proc/cmdline" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "14. cpupower frequency-info" >> $OUTPUT_FILE +eval "cpupower frequency-info" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "15. sysctl" >> $OUTPUT_FILE +if [[ ${CM_SUDO_USER} == "yes" ]]; then + echo "${CM_SUDO} sysctl -a" + eval "${CM_SUDO} sysctl -a" >> $OUTPUT_FILE test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +else + echo "Requires SUDO permission" >> $OUTPUT_FILE +fi +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "12. Services, from systemctl list-unit-files" >> $OUTPUT_FILE - eval "systemctl list-unit-files" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +echo "16. /sys/kernel/mm/transparent_hugepage" >> $OUTPUT_FILE +eval "cat /sys/kernel/mm/transparent_hugepage/enabled" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "13. Linux kernel boot-time arguments, from /proc/cmdline" >> $OUTPUT_FILE - eval "cat /proc/cmdline" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +echo "17. /sys/kernel/mm/transparent_hugepage/khugepaged" >> $OUTPUT_FILE +eval "cat /sys/kernel/mm/transparent_hugepage/khugepaged/defrag" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "14. cpupower frequency-info" >> $OUTPUT_FILE - eval "cpupower frequency-info" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "15. sysctl" >> $OUTPUT_FILE - if [[ ${CM_SUDO_USER} == "yes" ]]; then - echo "${CM_SUDO} sysctl -a" - eval "${CM_SUDO} sysctl -a" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - else - echo "Requires SUDO permission" >> $OUTPUT_FILE - fi - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "16. /sys/kernel/mm/transparent_hugepage" >> $OUTPUT_FILE - eval "cat /sys/kernel/mm/transparent_hugepage/enabled" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +echo "18. OS release" >> $OUTPUT_FILE +eval "cat /etc/os-release" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "17. /sys/kernel/mm/transparent_hugepage/khugepaged" >> $OUTPUT_FILE - eval "cat /sys/kernel/mm/transparent_hugepage/khugepaged/defrag" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +echo "19. Disk information" >> $OUTPUT_FILE +eval "lsblk" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "18. OS release" >> $OUTPUT_FILE - eval "cat /etc/os-release" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +echo "20. /sys/devices/virtual/dmi/id" >> $OUTPUT_FILE +eval "ls /sys/devices/virtual/dmi/id" >> $OUTPUT_FILE +test $? -eq 0 || exit $? +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "19. Disk information" >> $OUTPUT_FILE - eval "lsblk" >> $OUTPUT_FILE +echo "21. dmidecode" >> $OUTPUT_FILE +if [[ ${CM_SUDO_USER} == "yes" ]]; then + eval "${CM_SUDO} dmidecode" >> $OUTPUT_FILE test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE +else + echo "Requires SUDO permission" >> $OUTPUT_FILE +fi +echo "------------------------------------------------------------" >> $OUTPUT_FILE - echo "20. /sys/devices/virtual/dmi/id" >> $OUTPUT_FILE - eval "ls /sys/devices/virtual/dmi/id" >> $OUTPUT_FILE +echo "22. BIOS" >> $OUTPUT_FILE +if [[ ${CM_SUDO_USER} == "yes" ]]; then + eval "${CM_SUDO} dmidecode -t bios" >> $OUTPUT_FILE test $? -eq 0 || exit $? - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "21. dmidecode" >> $OUTPUT_FILE - if [[ ${CM_SUDO_USER} == "yes" ]]; then - eval "${CM_SUDO} dmidecode" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - else - echo "Requires SUDO permission" >> $OUTPUT_FILE - fi - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "22. BIOS" >> $OUTPUT_FILE - if [[ ${CM_SUDO_USER} == "yes" ]]; then - eval "${CM_SUDO} dmidecode -t bios" >> $OUTPUT_FILE - test $? -eq 0 || exit $? - else - echo "Requires SUDO permission" >> $OUTPUT_FILE - fi - echo "------------------------------------------------------------" >> $OUTPUT_FILE - - echo "System information has been saved to $PWD/$OUTPUT_FILE" +else + echo "Requires SUDO permission" >> $OUTPUT_FILE fi +echo "------------------------------------------------------------" >> $OUTPUT_FILE + +echo "System information has been saved to $PWD/$OUTPUT_FILE" From 1b3793c7c3293cc8de2bfbc3c1e82e6ce10d5550 Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Mon, 28 Oct 2024 22:27:23 +0000 Subject: [PATCH 25/25] Update customize.py --- script/get-platform-details/customize.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/script/get-platform-details/customize.py b/script/get-platform-details/customize.py index 1de6969afe..9c26dae026 100644 --- a/script/get-platform-details/customize.py +++ b/script/get-platform-details/customize.py @@ -13,9 +13,6 @@ def preprocess(i): os_info = i['os_info'] env = i['env'] - if os_info['platform'] == "darwin": - i['run_script_input']['script_name'] = "run-macos" - if not check_installation("numactl",os_info): env['CM_INSTALL_NUMACTL'] = 'True'