From 2d864e5b2f2bd0d7e2bc8041b981d0c937944cee Mon Sep 17 00:00:00 2001 From: tshalvi Date: Thu, 22 Aug 2024 20:53:35 +0300 Subject: [PATCH 1/5] Added CMIS host management-related files to the show techsupport dumps --- scripts/generate_dump | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/generate_dump b/scripts/generate_dump index 3d0ef3430d..72039c3219 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1309,6 +1309,34 @@ collect_mellanox_dfw_dumps() { fi fi done + + # Save CMIS-host-management related files + cmis_host_mgmt_files=( + "sai.profile" + "pmon_daemon_control.json" + "media_settings.json" + "optics_si_settings.json" + ) + sku_folder="/usr/share/sonic/device/${platform}/${hwsku}" + host_cmis_mgmt_path="etc/cmis-host-mgmt" + + for file in "${cmis_host_mgmt_files[@]}"; do + if [[ -f "${sku_folder}/${file}" ]]; then + ${CMD_PREFIX}save_file "${sku_folder}/${file}" "$host_cmis_mgmt_path" false true + fi + done + + platform_folder="/usr/share/sonic/device/${platform}" + if [[ ! -f "${sku_folder}/pmon_daemon_control.json" && -f "${platform_folder}/pmon_daemon_control.json" ]]; then + ${CMD_PREFIX}save_file "${platform_folder}/pmon_daemon_control.json" "$host_cmis_mgmt_path" false true + fi + + autoneg_status_file="/tmp/autoneg.status" + if show int autoneg sta > "$autoneg_status_file"; then + ${CMD_PREFIX}save_file "$autoneg_status_file" "$host_cmis_mgmt_path" false true + else + echo "ERROR: Failed to save autoneg.status." + fi } ############################################################################### From 860380fd781ea0106955d633d0035bc87d44caa4 Mon Sep 17 00:00:00 2001 From: tshalvi Date: Sun, 25 Aug 2024 17:13:51 +0300 Subject: [PATCH 2/5] Refactor: move variable declarations to function start, update command to 'show interfaces autoneg status' --- scripts/generate_dump | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index 72039c3219..75feff042a 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1265,9 +1265,17 @@ collect_mellanox() { collect_mellanox_dfw_dumps() { trap 'handle_error $? $LINENO' ERR local platform=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_platform())") + local platform_folder="/usr/share/sonic/device/${platform}" local hwsku=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_hwsku())") + local sku_folder="/usr/share/sonic/device/${platform}/${hwsku}" local def_dump_path="/var/log/mellanox/sdk-dumps" local sdk_dump_path=`cat /usr/share/sonic/device/${platform}/${hwsku}/sai.profile|grep "SAI_DUMP_STORE_PATH"|cut -d = -f2` + local cmis_host_mgmt_files=( + "sai.profile" + "pmon_daemon_control.json" + "media_settings.json" + "optics_si_settings.json" + ) if [ -z $sdk_dump_path ]; then # If the SAI_DUMP_STORE_PATH is not found in device specific sai profile, check in common sai profile @@ -1311,14 +1319,7 @@ collect_mellanox_dfw_dumps() { done # Save CMIS-host-management related files - cmis_host_mgmt_files=( - "sai.profile" - "pmon_daemon_control.json" - "media_settings.json" - "optics_si_settings.json" - ) - sku_folder="/usr/share/sonic/device/${platform}/${hwsku}" - host_cmis_mgmt_path="etc/cmis-host-mgmt" + local host_cmis_mgmt_path="etc/cmis-host-mgmt" for file in "${cmis_host_mgmt_files[@]}"; do if [[ -f "${sku_folder}/${file}" ]]; then @@ -1326,16 +1327,15 @@ collect_mellanox_dfw_dumps() { fi done - platform_folder="/usr/share/sonic/device/${platform}" if [[ ! -f "${sku_folder}/pmon_daemon_control.json" && -f "${platform_folder}/pmon_daemon_control.json" ]]; then ${CMD_PREFIX}save_file "${platform_folder}/pmon_daemon_control.json" "$host_cmis_mgmt_path" false true fi - autoneg_status_file="/tmp/autoneg.status" - if show int autoneg sta > "$autoneg_status_file"; then + local autoneg_status_file="/tmp/autoneg.status" + if show interfaces autoneg status > "$autoneg_status_file"; then ${CMD_PREFIX}save_file "$autoneg_status_file" "$host_cmis_mgmt_path" false true else - echo "ERROR: Failed to save autoneg.status." + echo "ERROR: Failed to save autoneg.status" fi } From ddbc2701a40b177042ddb7cea33729f9297011a0 Mon Sep 17 00:00:00 2001 From: tshalvi Date: Mon, 26 Aug 2024 14:44:28 +0300 Subject: [PATCH 3/5] Moved logic from collect_mellanox_dfw_dumps() to collect_mellanox() and used save_cmd() instead of running the command directly and manually storing the output in a file --- scripts/generate_dump | 53 ++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index 75feff042a..8c12a8fff1 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1209,6 +1209,16 @@ collect_mellanox() { local timeout_cmd="timeout --foreground ${TIMEOUT_MIN}m" local sai_dump_folder="/tmp/saisdkdump" local sai_dump_filename="${sai_dump_folder}/sai_sdk_dump_$(date +"%m_%d_%Y_%I_%M_%p")" + local platform=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_platform())") + local platform_folder="/usr/share/sonic/device/${platform}" + local hwsku=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_hwsku())") + local sku_folder="/usr/share/sonic/device/${platform}/${hwsku}" + local cmis_host_mgmt_files=( + "sai.profile" + "pmon_daemon_control.json" + "media_settings.json" + "optics_si_settings.json" + ) if [[ "$( docker container inspect -f '{{.State.Running}}' syncd )" == "true" ]]; then if [[ x"$(sonic-db-cli APPL_DB EXISTS PORT_TABLE:PortInitDone)" == x"1" ]]; then @@ -1251,6 +1261,21 @@ collect_mellanox() { fi save_cmd "get_component_versions.py" "component_versions" + + # Save CMIS-host-management related files + local host_cmis_mgmt_path="cmis-host-mgmt" + + for file in "${cmis_host_mgmt_files[@]}"; do + if [[ -f "${sku_folder}/${file}" ]]; then + ${CMD_PREFIX}save_file "${sku_folder}/${file}" "$host_cmis_mgmt_path" false true + fi + done + + if [[ ! -f "${sku_folder}/pmon_daemon_control.json" && -f "${platform_folder}/pmon_daemon_control.json" ]]; then + ${CMD_PREFIX}save_file "${platform_folder}/pmon_daemon_control.json" "$host_cmis_mgmt_path" false true + fi + + save_cmd "show interfaces autoneg status" "autoneg.status" } ############################################################################### @@ -1265,17 +1290,9 @@ collect_mellanox() { collect_mellanox_dfw_dumps() { trap 'handle_error $? $LINENO' ERR local platform=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_platform())") - local platform_folder="/usr/share/sonic/device/${platform}" local hwsku=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_hwsku())") - local sku_folder="/usr/share/sonic/device/${platform}/${hwsku}" local def_dump_path="/var/log/mellanox/sdk-dumps" local sdk_dump_path=`cat /usr/share/sonic/device/${platform}/${hwsku}/sai.profile|grep "SAI_DUMP_STORE_PATH"|cut -d = -f2` - local cmis_host_mgmt_files=( - "sai.profile" - "pmon_daemon_control.json" - "media_settings.json" - "optics_si_settings.json" - ) if [ -z $sdk_dump_path ]; then # If the SAI_DUMP_STORE_PATH is not found in device specific sai profile, check in common sai profile @@ -1317,26 +1334,6 @@ collect_mellanox_dfw_dumps() { fi fi done - - # Save CMIS-host-management related files - local host_cmis_mgmt_path="etc/cmis-host-mgmt" - - for file in "${cmis_host_mgmt_files[@]}"; do - if [[ -f "${sku_folder}/${file}" ]]; then - ${CMD_PREFIX}save_file "${sku_folder}/${file}" "$host_cmis_mgmt_path" false true - fi - done - - if [[ ! -f "${sku_folder}/pmon_daemon_control.json" && -f "${platform_folder}/pmon_daemon_control.json" ]]; then - ${CMD_PREFIX}save_file "${platform_folder}/pmon_daemon_control.json" "$host_cmis_mgmt_path" false true - fi - - local autoneg_status_file="/tmp/autoneg.status" - if show interfaces autoneg status > "$autoneg_status_file"; then - ${CMD_PREFIX}save_file "$autoneg_status_file" "$host_cmis_mgmt_path" false true - else - echo "ERROR: Failed to save autoneg.status" - fi } ############################################################################### From 52e4862deb5496f4574edf1621f09d17ce2a848b Mon Sep 17 00:00:00 2001 From: tshalvi Date: Mon, 26 Aug 2024 15:38:02 +0300 Subject: [PATCH 4/5] Update file path for sai.profile --- scripts/generate_dump | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index 8c12a8fff1..b891bb324a 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1214,10 +1214,10 @@ collect_mellanox() { local hwsku=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_hwsku())") local sku_folder="/usr/share/sonic/device/${platform}/${hwsku}" local cmis_host_mgmt_files=( - "sai.profile" - "pmon_daemon_control.json" - "media_settings.json" - "optics_si_settings.json" + "/tmp/nv-syncd-shared/sai.profile" + "${sku_folder}/pmon_daemon_control.json" + "${sku_folder}/media_settings.json" + "${sku_folder}/optics_si_settings.json" ) if [[ "$( docker container inspect -f '{{.State.Running}}' syncd )" == "true" ]]; then @@ -1266,8 +1266,8 @@ collect_mellanox() { local host_cmis_mgmt_path="cmis-host-mgmt" for file in "${cmis_host_mgmt_files[@]}"; do - if [[ -f "${sku_folder}/${file}" ]]; then - ${CMD_PREFIX}save_file "${sku_folder}/${file}" "$host_cmis_mgmt_path" false true + if [[ -f "${file}" ]]; then + ${CMD_PREFIX}save_file "${file}" "$host_cmis_mgmt_path" false true fi done From 241e3b15ac922340f4ad5f1ca1a9f05431ce380b Mon Sep 17 00:00:00 2001 From: tshalvi Date: Mon, 26 Aug 2024 17:44:44 +0300 Subject: [PATCH 5/5] Variable renaming --- scripts/generate_dump | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index b891bb324a..38774c4a37 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1263,16 +1263,16 @@ collect_mellanox() { save_cmd "get_component_versions.py" "component_versions" # Save CMIS-host-management related files - local host_cmis_mgmt_path="cmis-host-mgmt" + local cmis_host_mgmt_path="cmis-host-mgmt" for file in "${cmis_host_mgmt_files[@]}"; do if [[ -f "${file}" ]]; then - ${CMD_PREFIX}save_file "${file}" "$host_cmis_mgmt_path" false true + ${CMD_PREFIX}save_file "${file}" "$cmis_host_mgmt_path" false true fi done if [[ ! -f "${sku_folder}/pmon_daemon_control.json" && -f "${platform_folder}/pmon_daemon_control.json" ]]; then - ${CMD_PREFIX}save_file "${platform_folder}/pmon_daemon_control.json" "$host_cmis_mgmt_path" false true + ${CMD_PREFIX}save_file "${platform_folder}/pmon_daemon_control.json" "$cmis_host_mgmt_path" false true fi save_cmd "show interfaces autoneg status" "autoneg.status"