-
Notifications
You must be signed in to change notification settings - Fork 199
Modifications to README and smbclientlogs.sh #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
meetakshi253
wants to merge
5
commits into
master
Choose a base branch
from
msetiya/smbclientlogs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bb5929f
Reformat README for SMBDiagnostics
meetakshi253 92683eb
Use command -v instead of which and minor modifications
meetakshi253 76321a8
Minor modifications to README and check python dependency only on OnA…
meetakshi253 1c54b71
Add zgrep as a dependency only for apt-based systems and other minor …
meetakshi253 f7e01f7
Fix restoring cifsFYI log level
meetakshi253 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,30 @@ | ||
| Steps to collect the logs: | ||
| -------------------------- | ||
| Copy smbclientlogs.sh (Shell script) to linux machine where we need to collect logs. | ||
| # Steps to collect the logs: | ||
|
|
||
| Dependencies: | ||
| Install packages trace-cmd, zip and ss. If debian-based distro, please install zgrep. | ||
| If using CaptureNetwork option (see below), install tcpdump. | ||
| Copy smbclientlogs.sh (Shell script) to the Linux machine where we need to collect logs. | ||
|
|
||
| If issue can be easily reproduced: | ||
| 1) Open linux terminal or ssh to linux machine or the AKS node. | ||
| ## 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. | ||
| 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. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,11 @@ 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) | ||
| if (( $euid != 0 )); | ||
| then | ||
| if (( $euid != 0 )); then | ||
| echo "Please run $0 as root"; | ||
| exit | ||
| fi | ||
|
|
@@ -35,7 +34,7 @@ main() { | |
| } | ||
|
|
||
| init() { | ||
| check_utils | ||
| check_utils "$@" | ||
| if [[ -f $DIRNAME ]]; | ||
| then | ||
| rm -rf "$DIRNAME" | ||
|
|
@@ -44,55 +43,56 @@ 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 | ||
| 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 | ||
|
|
||
| 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 | ||
| 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 | ||
| else PYTHON_PROG='python3' | ||
| else PYTHON_PROG='python' | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| 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=$? | ||
|
|
||
| if [ $rc -ne 0 ]; then | ||
| echo "trace-cmd failed to start. cifs-trace will not be captured." | ||
| fi | ||
| } | ||
|
|
||
| dump_system_logs() { | ||
|
|
@@ -115,7 +115,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 +143,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 | ||
|
|
@@ -196,8 +194,8 @@ trace_cifsbpf() { | |
| } | ||
|
|
||
| start() { | ||
| init | ||
| start_trace $@ | ||
| init "$@" | ||
| start_trace "$@" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is start_trace utilizing the args passed?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, yes for VerboseLogs, but I found a bug. Let me submit another commit. |
||
| dump_os_information | ||
| echo "======= Dumping CIFS Debug Stats at start =======" > cifs_diag.txt | ||
| dump_debug_stats | ||
|
|
@@ -216,6 +214,8 @@ start() { | |
| if [[ "$*" =~ "OnAnomaly" ]]; then | ||
| trace_cifsbpf | ||
| fi | ||
|
|
||
| echo "started collecting smb client logs" | ||
| } | ||
|
|
||
| stop() { | ||
|
|
@@ -249,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* | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to your change: Why do we have apt as a dependency? This would not work for non-debian distros, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a precondition for using zgrep.