From bb5929fe38ef942337a3dd3147ca17bc034d0d4b Mon Sep 17 00:00:00 2001 From: meetakshi253 Date: Tue, 13 Jan 2026 14:06:30 +0000 Subject: [PATCH 1/5] Reformat README for SMBDiagnostics --- SMBDiagnostics/README | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/SMBDiagnostics/README b/SMBDiagnostics/README index 35d45815..98ec25d3 100644 --- a/SMBDiagnostics/README +++ b/SMBDiagnostics/README @@ -1,29 +1,29 @@ -Steps to collect the logs: --------------------------- +# Steps to collect the logs: + Copy smbclientlogs.sh (Shell script) to linux machine where we need to collect logs. Dependencies: Install packages trace-cmd, zip and ss. If debian-based distro, please install zgrep. If using CaptureNetwork option (see below), install tcpdump. -If issue can be easily reproduced: +## Usage: +**If issue can be easily reproduced:** 1) Open linux terminal or ssh to linux machine or the AKS node. 2) Run the command "sudo bash" to gain root privileges. 3) Cd to script location and run the command - "chmod +x ./smbclientlogs.sh" + `chmod +x ./smbclientlogs.sh` 4) Run the command - "./smbclientlogs.sh start" - (or) - "./smbclientlogs.sh start CaptureNetwork" (in case Microsoft instructs you to use this option) + `./smbclientlogs.sh start` + or + `./smbclientlogs.sh start CaptureNetwork` (in case Microsoft instructs you to use this option) 5) Repro the issue. -6) Run "./smbclientlogs.sh stop" +6) Run `./smbclientlogs.sh stop` 7) Above command generates output.zip 8) Send the output.zip file to Microsoft support against your support case. -Contents of Zip file: +## Contents of Zip file: 1) cifs_diag.txt - Internal debug data and stats from the SMB client. 2) cifs_dmesg - System logs since the last reboot. 3) cifs_trace - Output of trace-cmd, which contain the kernel event logs. 4) os_details.txt - Info about the operating system, which will help developers to understand which features/fixes are missing. -5) cifs_traffic.pcap - network capture of SMB traffic in case CaptureNetwork option was used. - +5) cifs_traffic.pcap - network capture of SMB traffic in case CaptureNetwork option was used.~ \ No newline at end of file From 92683eb1fec413f5ca038381e8a89a3ee63b6fa9 Mon Sep 17 00:00:00 2001 From: meetakshi253 Date: Tue, 13 Jan 2026 14:15:57 +0000 Subject: [PATCH 2/5] Use command -v instead of which and minor modifications --- SMBDiagnostics/smbclientlogs.sh | 44 ++++++++++++++------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/SMBDiagnostics/smbclientlogs.sh b/SMBDiagnostics/smbclientlogs.sh index 31970e61..792d0783 100755 --- a/SMBDiagnostics/smbclientlogs.sh +++ b/SMBDiagnostics/smbclientlogs.sh @@ -10,8 +10,7 @@ CIFS_FYI_ENABLED=0 am_i_root() { local euid=$(id -u) - if (( $euid != 0 )); - then + if (( $euid != 0 )); then echo "Please run $0 as root"; exit fi @@ -44,44 +43,36 @@ init() { } check_utils() { - which trace-cmd > /dev/null - if [ $? == 1 ]; then + if ! command -v trace-cmd >/dev/null 2>&1; then echo "trace-cmd is not installed, please install trace-cmd" exit 1 fi - if (( ($(which apt |egrep -c apt) > 0) && ($(which zgrep |egrep -c zgrep) == 0) )); - then + if ! command -v zgrep >/dev/null 2>&1; then echo "zgrep is not installed, please install zgrep" exit 1 fi - which tcpdump > /dev/null - if [ $? != 0 ]; then + if ! command -v tcpdump >/dev/null 2>&1; then echo "tcpdump is not installed. Please install tcpdump if you intend to capture network traces." #Not exiting since packet capture is optional fi - which zip > /dev/null - if [ $? == 1 ]; then + if ! command -v zip >/dev/null 2>&1; then echo "zip is not installed, please install zip to continue" exit 1 fi - which ss > /dev/null - if [ $? == 1 ]; then + if ! command -v ss >/dev/null 2>&1; then echo "ss is not installed, please install ss to continue" exit 1 fi - which python > /dev/null - if [ $? == 1 ]; then - which python3 > /dev/null - if [ $? == 1 ]; then - echo "python is not installed, please install python to continue" - exit 1 - else PYTHON_PROG='python3' - fi + if command -v python3 >/dev/null 2>&1; then + PYTHON_PROG='python3' + elif ! command -v python >/dev/null 2>&1; then + echo "python is not installed, please install python to continue" + exit 1 fi } @@ -93,6 +84,11 @@ start_trace() { CIFS_FYI_ENABLED=1 fi trace-cmd start -e cifs + rc=$? + + if [ $rc -ne 0 ]; then + echo "trace-cmd failed to start. cifs-trace would not be captured." + fi } dump_system_logs() { @@ -115,7 +111,7 @@ dump_system_logs() { dump_azfileauth_logs() { local output_file=$1 - if which azfilesauthmanager >/dev/null 2>&1; then + if command -v azfilesauthmanager >/dev/null 2>&1; then echo -e "\nDumping azfileauth tickets" >> "$output_file" azfilesauthmanager list >> "$output_file" 2>&1 else @@ -143,14 +139,12 @@ dump_os_information() { echo -e "\nSystem Uptime:" >> os_details.txt cat /proc/uptime >> os_details.txt echo -e "\npackage install details:" >> os_details.txt - if (( $(which rpm |egrep -c rpm) > 0)); - then + if command -v rpm >/dev/null 2>&1; then rpm -qa --last |grep keyutils >> os_details.txt rpm -qa --last |grep cifs-utils >> os_details.txt rpm -qi keyutils >> os_details.txt rpm -qi cifs-utils >> os_details.txt - elif (( $(which apt |egrep -c apt) > 0 )); - then + elif command -v apt >/dev/null 2>&1; then zgrep -B5 -A5 keyutils /var/log/apt/history.log* >> os_details.txt zgrep -B5 -A5 cifs-utils /var/log/apt/history.log* >> os_details.txt dpkg -s keyutils cifs-utils >> os_details.txt From 76321a8b24d80b7004d03be3e1053f1ac47b8f47 Mon Sep 17 00:00:00 2001 From: Meetakshi Setiya Date: Wed, 21 Jan 2026 02:14:26 -0500 Subject: [PATCH 3/5] Minor modifications to README and check python dependency only on OnAnomaly mode --- SMBDiagnostics/smbclientlogs.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/SMBDiagnostics/smbclientlogs.sh b/SMBDiagnostics/smbclientlogs.sh index 792d0783..f2f1c705 100755 --- a/SMBDiagnostics/smbclientlogs.sh +++ b/SMBDiagnostics/smbclientlogs.sh @@ -34,7 +34,7 @@ main() { } init() { - check_utils + check_utils "$@" if [[ -f $DIRNAME ]]; then rm -rf "$DIRNAME" @@ -68,11 +68,13 @@ check_utils() { exit 1 fi - if command -v python3 >/dev/null 2>&1; then - PYTHON_PROG='python3' - elif ! command -v python >/dev/null 2>&1; then - echo "python is not installed, please install python to continue" - exit 1 + if [[ "$*" =~ "OnAnomaly" ]]; then + if command -v python3 >/dev/null 2>&1; then + PYTHON_PROG='python3' + elif ! command -v python >/dev/null 2>&1; then + echo "python is not installed, please install python to continue" + exit 1 + fi fi } @@ -190,8 +192,8 @@ trace_cifsbpf() { } start() { - init - start_trace $@ + init "$@" + start_trace "$@" dump_os_information echo "======= Dumping CIFS Debug Stats at start =======" > cifs_diag.txt dump_debug_stats @@ -210,6 +212,8 @@ start() { if [[ "$*" =~ "OnAnomaly" ]]; then trace_cifsbpf fi + + echo "started collecting smb client logs" } stop() { From 1c54b7157e2dc07777813e353f2a3bdb3483bc82 Mon Sep 17 00:00:00 2001 From: Meetakshi Setiya Date: Tue, 3 Mar 2026 01:05:54 -0500 Subject: [PATCH 4/5] Add zgrep as a dependency only for apt-based systems and other minor revisions --- SMBDiagnostics/README | 13 +++++++------ SMBDiagnostics/smbclientlogs.sh | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/SMBDiagnostics/README b/SMBDiagnostics/README index 98ec25d3..a4f1c85d 100644 --- a/SMBDiagnostics/README +++ b/SMBDiagnostics/README @@ -1,14 +1,15 @@ # Steps to collect the logs: -Copy smbclientlogs.sh (Shell script) to linux machine where we need to collect logs. +Copy smbclientlogs.sh (Shell script) to the Linux machine where we need to collect logs. -Dependencies: -Install packages trace-cmd, zip and ss. If debian-based distro, please install zgrep. -If using CaptureNetwork option (see below), install tcpdump. +## Dependencies: +- Ensure the **ss** command is installed (usually provided by the **iproute2** or **iproute** package), and install **trace-cmd** and **zip**. +- On debian-based distros, also install **zgrep**. +- If using CaptureNetwork option (see below), install **tcpdump**. ## Usage: **If issue can be easily reproduced:** -1) Open linux terminal or ssh to linux machine or the AKS node. +1) Open Linux terminal or ssh to Linux machine or the AKS node. 2) Run the command "sudo bash" to gain root privileges. 3) Cd to script location and run the command `chmod +x ./smbclientlogs.sh` @@ -26,4 +27,4 @@ If using CaptureNetwork option (see below), install tcpdump. 2) cifs_dmesg - System logs since the last reboot. 3) cifs_trace - Output of trace-cmd, which contain the kernel event logs. 4) os_details.txt - Info about the operating system, which will help developers to understand which features/fixes are missing. -5) cifs_traffic.pcap - network capture of SMB traffic in case CaptureNetwork option was used.~ \ No newline at end of file +5) cifs_traffic.pcap - network capture of SMB traffic in case CaptureNetwork option was used. diff --git a/SMBDiagnostics/smbclientlogs.sh b/SMBDiagnostics/smbclientlogs.sh index f2f1c705..f8237662 100755 --- a/SMBDiagnostics/smbclientlogs.sh +++ b/SMBDiagnostics/smbclientlogs.sh @@ -48,8 +48,8 @@ check_utils() { exit 1 fi - if ! command -v zgrep >/dev/null 2>&1; then - echo "zgrep is not installed, please install zgrep" + if (command -v apt >/dev/null 2>&1) && (! command -v zgrep >/dev/null 2>&1); then + echo "apt-based package management is in use, but zgrep is not installed, please install zgrep" exit 1 fi @@ -74,6 +74,7 @@ check_utils() { elif ! command -v python >/dev/null 2>&1; then echo "python is not installed, please install python to continue" exit 1 + else PYTHON_PROG='python' fi fi } @@ -89,7 +90,7 @@ start_trace() { rc=$? if [ $rc -ne 0 ]; then - echo "trace-cmd failed to start. cifs-trace would not be captured." + echo "trace-cmd failed to start. cifs-trace will not be captured." fi } From f7e01f7aa48f88f97c4a028ac5439747e09f576d Mon Sep 17 00:00:00 2001 From: Meetakshi Setiya Date: Tue, 3 Mar 2026 03:54:23 -0500 Subject: [PATCH 5/5] Fix restoring cifsFYI log level --- SMBDiagnostics/smbclientlogs.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SMBDiagnostics/smbclientlogs.sh b/SMBDiagnostics/smbclientlogs.sh index f8237662..85af61af 100755 --- a/SMBDiagnostics/smbclientlogs.sh +++ b/SMBDiagnostics/smbclientlogs.sh @@ -6,7 +6,7 @@ CIFS_PORT=445 TRACE_CIFSBPF_ABS_PATH="$(cd "$(dirname "trace-cifsbpf")" && pwd)/$(basename "trace-cifsbpf")" PYTHON_PROG='python' STDLOG_FILE='/dev/null' -CIFS_FYI_ENABLED=0 +VERBOSE_FLAG=".smbclientlogs_verbose.flag" am_i_root() { local euid=$(id -u) @@ -81,10 +81,11 @@ check_utils() { start_trace() { if [[ "$*" =~ "VerboseLogs" ]]; then + echo "setting verbose logging for cifs module" + cat /proc/fs/cifs/cifsFYI 2>/dev/null > "${VERBOSE_FLAG}" echo 'module cifs +p' > /sys/kernel/debug/dynamic_debug/control echo 'file fs/cifs/* +p' > /sys/kernel/debug/dynamic_debug/control echo 7 > /proc/fs/cifs/cifsFYI - CIFS_FYI_ENABLED=1 fi trace-cmd start -e cifs rc=$? @@ -248,8 +249,10 @@ stop_trace() { trace-cmd report > "${DIRNAME}/cifs_trace" trace-cmd stop trace-cmd reset - if [ $CIFS_FYI_ENABLED -ne 0 ]; then - echo 0 > /proc/fs/cifs/cifsFYI + if [ -f "${VERBOSE_FLAG}" ]; then + prev_value=$(cat "${VERBOSE_FLAG}") + echo "${prev_value:-0}" > /proc/fs/cifs/cifsFYI + rm -f "${VERBOSE_FLAG}" fi rm -rf trace.dat* }