diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..3fe92c4a --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if ! shellcheck -S error NfsDiagnostics/nfsclientlogs.sh SMBDiagnostics/smbclientlogs.sh +then + echo "Shellcheck failed" + exit 1 +fi diff --git a/.github/workflows/packaging-action.yaml b/.github/workflows/packaging-action.yaml new file mode 100644 index 00000000..16d33a7f --- /dev/null +++ b/.github/workflows/packaging-action.yaml @@ -0,0 +1,54 @@ +name: Package NFS and CIFS diagnostic scripts +run-name: Package NFS and CIFS diagnostic scripts +on: [push] + +jobs: + package: + runs-on: ubuntu-latest + + steps: + # - name: Download version artifact + # continue-on-error: true + # uses: actions/download-artifact@v3 + # with: + # name: version + # path: packaging + + + - name: Set up environment + run: | + sudo apt install -y shellcheck + sudo apt install -y rpm + sudo apt install -y build-essential + sudo apt install -y debhelper + + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: ShellCheck-Validation + run: | + if ! shellcheck -S error NfsDiagnostics/nfsclientlogs.sh SMBDiagnostics/smbclientlogs.sh; then echo "ShellCheck Failed"; exit 1; fi + + - name: Build Packages + run: | + cd packaging + make + + - name: Upload Debian Package + uses: actions/upload-artifact@v3 + with: + name: debian-package + path: packaging/*.deb + + - name: Upload RPM Package + uses: actions/upload-artifact@v3 + with: + name: rpm-package + path: packaging/*.rpm + + # - name: Update Future Version + # uses: actions/upload-artifact@v3 + # with: + # name: version + # path: packaging/VERSION.txt + diff --git a/NfsDiagnostics/nfsclientlogs.sh b/NfsDiagnostics/nfsclientlogs.sh index 1b993a27..322bcc72 100755 --- a/NfsDiagnostics/nfsclientlogs.sh +++ b/NfsDiagnostics/nfsclientlogs.sh @@ -3,11 +3,19 @@ PIDFILE="/tmp/nfsclientlog.pid" DIRNAME="./output" NFS_PORT=2049 -TRACE_NFSBPF_ABS_PATH="$(cd "$(dirname "trace-nfsbpf")" && pwd)/$(basename "trace-nfsbpf")" +#TRACE_NFSBPF_ABS_PATH="$(cd "$(dirname "trace-nfsbpf")" && pwd)/$(basename "trace-nfsbpf")" +TRACE_NFSBPF_ABS_PATH="/opt/xstore/lib/NfsDiagnostics/trace-nfsbpf" PYTHON_PROG='python' STDLOG_FILE='/dev/null' +# to enable backward compatibility. +_trace_nfsfsbpf_alt_path="$(cd "$(dirname "trace-nfsbpf")" && pwd)/$(basename "trace-nfsbpf")" +if [[ -f "${_trace_nfsbpf_alt_path}" ]]; +then + TRACE_NFSBPF_ABS_PATH="${_trace_nfsbpf_alt_path}" +fi + main() { if [[ "$*" =~ "v3b" ]] then @@ -23,7 +31,7 @@ main() { then stop 0<&- > "${STDLOG_FILE}" 2>&1 else - echo "Usage: ./nfsclientlogs.sh <> " + echo "Usage: diag-main.sh nfs " exit 1 fi @@ -45,7 +53,7 @@ start() { init() { check_utils - rm -r "$DIRNAME" + rm -rf "$DIRNAME" mkdir -p "$DIRNAME" dmesg -Tc > /dev/null @@ -91,7 +99,7 @@ capture_network() { } trace_nfsbpf() { - nohup "${PYTHON_PROG}" "${TRACE_NFSBPF_ABS_PATH}" "${DIRNAME}" 0<&- 2>&1 & + nohup /usr/bin/env "${PYTHON_PROG}" "${TRACE_NFSBPF_ABS_PATH}" "${DIRNAME}" 0<&- 2>&1 & } stop() { diff --git a/NfsDiagnostics/trace-nfsbpf b/NfsDiagnostics/trace-nfsbpf index c50f6ce0..1d1d40ea 100755 --- a/NfsDiagnostics/trace-nfsbpf +++ b/NfsDiagnostics/trace-nfsbpf @@ -1,9 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/env python from bcc import BPF from bcc.utils import printb from time import sleep import os from sys import argv +from datetime import datetime # define BPF program bpf_text= """ #include @@ -90,10 +91,10 @@ b.attach_tracepoint(tp="nfs:nfs_commit_error", fn_name="trace_page_error") b.attach_tracepoint(tp="nfs:nfs_pgio_error", fn_name="trace_pgio_error") b.attach_tracepoint(tp="nfs:nfs_writeback_page_exit", fn_name="trace_inode_event") b.attach_tracepoint(tp="nfs:nfs_writeback_inode_exit", fn_name="trace_inode_event") -print("Running Anomaly") class stop_and_collapse(Exception): pass +print(f"[{str(datetime.now())}] Running Anomaly Mode") while 1: try: sleep(1); @@ -109,17 +110,18 @@ while 1: break; output_dir = argv[1] -print("Exiting Anomaly") -fd=open("/tmp/nfsclientlog.pid", "r"); -# trace_pid=fd.readline(); -tcpdump_pid=fd.readline(); -print(tcpdump_pid) -command = "kill -INT %s" % (tcpdump_pid) -os.system(command); -# command = "kill -INT %s" % (trace_pid) +print(f"[{str(datetime.now())}] Exiting Anomaly Mode") +if(os.path.exists("/tmp/nfsclientlog.pid")): + fd=open("/tmp/nfsclientlog.pid", "r"); + tcpdump_pid=fd.readline(); + command = "kill -INT %s" % (tcpdump_pid) + os.system(command); + command = "trace-cmd stop" os.system(command); sleep(3) + +os.system(f"trace-cmd extract") os.system(f"trace-cmd report 2>&1 > {output_dir}/nfs_trace") os.system("trace-cmd reset") os.system(f"sudo dmesg -c > {output_dir}/nfs_dmesg") diff --git a/README_hooks.md b/README_hooks.md new file mode 100644 index 00000000..8836b00e --- /dev/null +++ b/README_hooks.md @@ -0,0 +1,10 @@ +# Git Hooks +- The hooks need to be enabled manually by the contributor. +- To enable hooks, change the default hook directory by `git config core.hooksPath .githooks` or manually copy hooks from `.githooks` to `.git/hooks` +- New validations can be added to `.githooks/pre-commit`. + + +# GitHub Actions +- Github actions are stored in .github/workflow +- To modify automatic packaging process (for cifs and nfs diagnostic scripts), make changes to `.github/workflow/packaging-action.yaml` +- New validations can be added here. diff --git a/SMBDiagnostics/smbclientlogs.sh b/SMBDiagnostics/smbclientlogs.sh index ae622127..7f34d67b 100755 --- a/SMBDiagnostics/smbclientlogs.sh +++ b/SMBDiagnostics/smbclientlogs.sh @@ -3,11 +3,19 @@ PIDFILE="/tmp/smbclientlog.pid" DIRNAME="./output" CIFS_PORT=445 -TRACE_CIFSBPF_ABS_PATH="$(cd "$(dirname "trace-cifsbpf")" && pwd)/$(basename "trace-cifsbpf")" +# TRACE_CIFSBPF_ABS_PATH="$(cd "$(dirname "trace-cifsbpf")" && pwd)/$(basename "trace-cifsbpf")" +TRACE_CIFSBPF_ABS_PATH="/opt/xstore/lib/SMBDiagnostics/trace-cifsbpf" PYTHON_PROG='python' STDLOG_FILE='/dev/null' +# to enable backward compatibility. +_trace_cifsbpf_alt_path="$(cd "$(dirname "trace-cifsbpf")" && pwd)/$(basename "trace-cifsbpf")" +if [[ -f "${_trace_cifsbpf_alt_path}" ]]; +then + TRACE_CIFSBPF_ABS_PATH="${_trace_cifsbpf_alt_path}" +fi + main() { if [[ "$*" =~ "start" ]] then @@ -16,7 +24,7 @@ main() { then stop 0<&- > "${STDLOG_FILE}" 2>&1 else - echo "Usage: ./smbclientlogs.sh " + echo "Usage: diag-main.sh cifs " exit 1 fi @@ -43,7 +51,7 @@ start() { init() { check_utils - rm -r "$DIRNAME" + rm -rf "$DIRNAME" mkdir -p "$DIRNAME" dmesg -Tc > /dev/null @@ -117,7 +125,7 @@ capture_network() { } trace_cifsbpf() { - nohup "${PYTHON_PROG}" "${TRACE_CIFSBPF_ABS_PATH}" "${DIRNAME}" 0<&- 2>&1 & + nohup /usr/bin/env "${PYTHON_PROG}" "${TRACE_CIFSBPF_ABS_PATH}" "${DIRNAME}" 0<&- 2>&1 & } stop() { diff --git a/SMBDiagnostics/trace-cifsbpf b/SMBDiagnostics/trace-cifsbpf index 29e9fd74..d54f4c06 100644 --- a/SMBDiagnostics/trace-cifsbpf +++ b/SMBDiagnostics/trace-cifsbpf @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python from bcc import BPF from bcc.utils import printb from time import sleep @@ -133,19 +133,21 @@ while 1: output_dir = argv[1] print(f"[{str(datetime.now())}] Exiting Anomaly Mode") -fd=open("/tmp/smbclientlog.pid", "r"); -# trace_pid=fd.readline(); -tcpdump_pid=fd.readline(); -print(tcpdump_pid) -command = "kill -INT %s" % (tcpdump_pid) -os.system(command); -# command = "kill -INT %s" % (trace_pid) + +if(os.path.exists("/tmp/smbclientlog.pid")): + fd=open("/tmp/smbclientlog.pid", "r"); + tcpdump_pid=fd.readline(); + command = "kill -INT %s" % (tcpdump_pid) + os.system(command); + command = "trace-cmd stop" os.system(command); sleep(3) + +os.system(f"trace-cmd extract") os.system(f"trace-cmd report 2>&1 > {output_dir}/cifs_trace") os.system("trace-cmd reset") -os.system(f"sudo dmesg -c > {output_dir}/nfs_dmesg") +os.system(f"sudo dmesg -c > {output_dir}/cifs_dmesg") os.system(f"mv cifs_diag.txt {output_dir}") os.system(f"mv os_details.txt {output_dir}") command = f"zip -r $(basename {output_dir}).zip {output_dir}" diff --git a/diag-main.sh b/diag-main.sh new file mode 100755 index 00000000..29fb9c98 --- /dev/null +++ b/diag-main.sh @@ -0,0 +1,19 @@ +#!/usr/bin/bash + +# PACKAGE_TREE="$(dirname $(dirname $(readlink -f $0)))" +PACKAGE_TREE="/opt/xstore" +run() { + if [[ $1 == "nfs" ]] || [[ $1 == "cifs" ]]; + then + if [[ $1 == "nfs" ]] + then script_path="${PACKAGE_TREE}/lib/NfsDiagnostics/nfsclientlogs.sh" + else script_path="${PACKAGE_TREE}/lib/SMBDiagnostics/smbclientlogs.sh" + fi + $script_path "$@" + + else + echo "Usage: diag-main.sh [Version] [CaptureNetwork] [OnAnomaly]" >&2 + fi +} + +run "$@" diff --git a/health-check-daemon-POC/README.md b/health-check-daemon-POC/README.md new file mode 100644 index 00000000..9aebc984 --- /dev/null +++ b/health-check-daemon-POC/README.md @@ -0,0 +1,14 @@ +# Steps to simulate fault and test the daemon: +1. Install the linux-crashdump using `./crash_dump.sh install`. This step requires a reboot. +2. Start the daemon by running 'sudo ./main.sh'. +3. Simulate fault by inserting module from `./buggy-module/moduleA.ko`. +4. Wait for daemon to print "Crash Dump Enabled". +5. Once crash dump is enabled, insert the other copy of buggy module `./buggy-module/moduleB.ko` +6. This should trigger a kernel panic and the system should enter into a reboot. +7. Crashdumps will be generated inside `/var/crash` directory. +8. Disable crashdumps manually running `sudo ./crash_dump.sh disable`. + +# Note: +- crashdumps can be enabled without a restart. +- disabling crashdumps require a restart. +- moduleB is a copy of moduleA. We need two copies because when the buggy module is inserted, it cannot be removed from kernel by running `rmmod MODULE_NAME`. So instead of inserting, removing and reinserting the same module, we instead use a copy of the same module. diff --git a/health-check-daemon-POC/buggy-module/Makefile b/health-check-daemon-POC/buggy-module/Makefile new file mode 100644 index 00000000..4fa2ad03 --- /dev/null +++ b/health-check-daemon-POC/buggy-module/Makefile @@ -0,0 +1,7 @@ +obj-m += module.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules + +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean diff --git a/health-check-daemon-POC/buggy-module/module.c b/health-check-daemon-POC/buggy-module/module.c new file mode 100644 index 00000000..9fcee597 --- /dev/null +++ b/health-check-daemon-POC/buggy-module/module.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include + +MODULE_AUTHOR("Aman"); +MODULE_DESCRIPTION("This module when inserted causes null pointer dereference fault"); +MODULE_LICENSE("GPL"); + +typedef struct ABC { + int a; + int b; +} ABC; + +ABC* ptr; + +void print(ABC* abc) { + printk(KERN_INFO "abc(a: %d, b: %d)\n", abc->a, abc->b); +} + +void cause_gpf(void) { + printk(KERN_WARNING "Hello World \n\n"); + ptr = kmalloc(sizeof(ABC), GFP_KERNEL); + ptr->a = 118; + ptr->b = 212; + + printk(KERN_INFO "Before Free:"); + print(ptr); + kfree(ptr); +} + +void cause_nullderef(void) { + ptr = kmalloc(sizeof(ABC), GFP_KERNEL); + ptr -> a = 118; + ptr -> b = 212; + printk(KERN_INFO "Before Free"); + print(ptr); + kfree(ptr); + ptr = NULL; + print(ptr); +} + +static int __init custom_init(void) { + cause_nullderef(); + return 1; +} + +static void __exit custom_exit(void) { + printk(KERN_INFO "After Free:"); + print(ptr); + printk(KERN_INFO "Goodbye |:>)\n\n"); +} + +module_init(custom_init); +module_exit(custom_exit); + + diff --git a/health-check-daemon-POC/buggy-module/moduleA.ko b/health-check-daemon-POC/buggy-module/moduleA.ko new file mode 100644 index 00000000..0097d99c Binary files /dev/null and b/health-check-daemon-POC/buggy-module/moduleA.ko differ diff --git a/health-check-daemon-POC/buggy-module/moduleB.ko b/health-check-daemon-POC/buggy-module/moduleB.ko new file mode 100644 index 00000000..6848ffb4 Binary files /dev/null and b/health-check-daemon-POC/buggy-module/moduleB.ko differ diff --git a/health-check-daemon-POC/crash_dump.sh b/health-check-daemon-POC/crash_dump.sh new file mode 100755 index 00000000..e978fca0 --- /dev/null +++ b/health-check-daemon-POC/crash_dump.sh @@ -0,0 +1,88 @@ +#!/usr/bin/bash + +temp_action() { + echo "encountered error patterns" +} + +install_crashdump() { + export DEBIAN_FRONTEND=noninteractive + sudo DEBIAN_FRONTEND=noninteractive apt install -y linux-crashdump + echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=512M-:512M"' | sudo tee '/etc/default/grub.d/kdump-tools.cfg' + _update_configuration +} + + +_update_configuration() { + echo "This action requires a restart. Do you want to restart now. Enter (y|N)" + read -r var; + res=${var:0:1} + if [ "$res" == "y" ] || [ "$res" == "Y" ] + then + update-grub + echo restarting + reboot + return 0 + fi + return 1 +} + +enable_crash_dump() { + LOAD_KEXEC=$(awk -F= '/^LOAD_KEXEC/ {print $2}' /etc/default/kexec) + USE_KDUMP=$(awk -F= '/^USE_KDUMP/ {print $2}' /etc/default/kdump-tools) + echo $LOAD_KEXEC $USE_KDUMP + + if [ "$LOAD_KEXEC" == true ] && [ "$USE_KDUMP" == 1 ] + then + echo "Crash Dump is already enabled" + return 0 + fi + + if ! grep -q '^LOAD_KEXEC' /etc/default/kexec + then + echo LOAD_KEXEC=true >> /etc/default/kexec + else + sed 's/LOAD_KEXEC=false/LOAD_KEXEC=true/' -i /etc/default/kexec + fi + + if ! grep -q '^USE_KDUMP' /etc/default/kdump-tools + then + echo USE_KDUMP=1 >> /etc/default/kdump-tools + else + sed 's/USE_KDUMP=0/USE_KDUMP=1/' -i /etc/default/kdump-tools + fi + + kdump-config load + echo "Crash Dump Enabled" +} + +disable_crash_dump() { + LOAD_KEXEC=$(awk -F= '/^LOAD_KEXEC/ {print $2}' /etc/default/kexec) + USE_KDUMP=$(awk -F= '/^USE_KDUMP/ {print $2}' /etc/default/kdump-tools) + echo $LOAD_KEXEC $USE_KDUMP + + if [ "$LOAD_KEXEC" != true ] && [ "$USE_KDUMP" != 1 ] + then + echo "Crash Dump is already disabled" + return 0 + fi + + sed 's/LOAD_KEXEC=true/LOAD_KEXEC=false/' -i /etc/default/kexec + sed 's/USE_KDUMP=1/USE_KDUMP=0/' -i /etc/default/kdump-tools + + echo "Crash Dump Disabled" + _update_configuration + +} + +if [ "$1" == "enable" ] +then + enable_crash_dump +elif [ "$1" == "disable" ] +then + disable_crash_dump +elif [ "$1" == "install" ] +then + install_crashdump +else + echo "Usage: ./crash_dump.sh " +fi diff --git a/health-check-daemon-POC/main.sh b/health-check-daemon-POC/main.sh new file mode 100755 index 00000000..daa2413f --- /dev/null +++ b/health-check-daemon-POC/main.sh @@ -0,0 +1,23 @@ +SLEEP_DURATION=15 + +input_logs() { + # cat ./crashdmesg070501.txt ./VMcrashdmesg-20.97.25.82.txt + # journalctl -ro short-unix + dmesg +} + +signal_handler() { + sudo bash ./crash_dump.sh disable +} + +main() { + while true; + do + input_logs | sudo ./t.awk + # input_logs | sudo ./t2.awk + sleep ${SLEEP_DURATION} + done +} + +main + diff --git a/health-check-daemon-POC/t.awk b/health-check-daemon-POC/t.awk new file mode 100755 index 00000000..b3404a4c --- /dev/null +++ b/health-check-daemon-POC/t.awk @@ -0,0 +1,21 @@ +#!/usr/bin/awk -f + +BEGIN { + i=0; +} + +$0 ~ "general protection fault" || $0 ~ "use-after-free" || $0 ~ "kernel NULL pointer dereference" { + i++; + system("sudo bash ./crash_dump.sh enable"); + end(); +} + +END { + end(); +} + +function end() { + # print i; + # print "End"; + exit 0; +} diff --git a/packaging/.gitignore b/packaging/.gitignore new file mode 100644 index 00000000..f7288a3d --- /dev/null +++ b/packaging/.gitignore @@ -0,0 +1,2 @@ +*.rpm +*.deb diff --git a/packaging/DEBIAN/control b/packaging/DEBIAN/control new file mode 100644 index 00000000..7b980872 --- /dev/null +++ b/packaging/DEBIAN/control @@ -0,0 +1,6 @@ +Package: $PKG_NAME +Version: $VERSION +Maintainer: Microsoft +Architecture: all +Description: Diagnostics scripts for CIFS and NFS. +Depends: tcpdump, trace-cmd, nfs-common, bpfcc-tools diff --git a/packaging/DEBIAN/postinst b/packaging/DEBIAN/postinst new file mode 100755 index 00000000..3fd1675f --- /dev/null +++ b/packaging/DEBIAN/postinst @@ -0,0 +1,3 @@ + +chown root:root $SYS_DIR/bin/diag-main.sh +chmod 454 $SYS_DIR/bin/diag-main.sh diff --git a/packaging/DEBIAN/postrm b/packaging/DEBIAN/postrm new file mode 100755 index 00000000..5c8876e9 --- /dev/null +++ b/packaging/DEBIAN/postrm @@ -0,0 +1 @@ +rm -rf $SYS_DIR diff --git a/packaging/Makefile b/packaging/Makefile new file mode 100644 index 00000000..729a13aa --- /dev/null +++ b/packaging/Makefile @@ -0,0 +1,49 @@ +export PKG_NAME=azure-files-diag +export RELEASE=1 +VERSION := $(shell cat ./VERSION.txt) +export SYS_DIR=/opt/xstore +export SRC_DIR=.. +# export PKG_BUILD=$(PKG_NAME)$(sles)-$(RELEASE)-1.x86_64 +# export PKG_DIR=BUILDROOT/$(PKG_BUILD) +export PKG_DIR=$(PKG_NAME) +export DEB_PKG_DIR=$(PKG_DIR)/DEBIAN +export OPT_DIR=$(PKG_DIR)$(SYS_DIR) + +build: init debian rpm clean + echo "Building deb and rpm packages" + +init: + # if [ -f VERSION.txt ]; then echo "file present";VERSION=$(shell cat ./VERSION.txt); fi + echo "Building Version: ${VERSION}" + mkdir -p $(OPT_DIR)/bin + mkdir -p $(OPT_DIR)/lib + cp -r ../NfsDiagnostics $(OPT_DIR)/lib + cp -r ../SMBDiagnostics $(OPT_DIR)/lib + cp -r ../diag-main.sh $(OPT_DIR)/bin + +debian: init + cp -r ./DEBIAN ./$(PKG_DIR) + for file in ./$(PKG_DIR)/DEBIAN/*; do \ + sed -i "s/\$$PKG_NAME/${PKG_NAME}/g" $$file; \ + sed -i "s:\$$SYS_DIR:${SYS_DIR}:g" $$file; \ + sed -i "s/\$$VERSION/${VERSION}/g" $$file; \ + done + dpkg-deb --build ./$(PKG_DIR) + +rpm: init + mkdir -p ~/rpmbuild/SOURCES + cp -r $(PKG_DIR)/opt ~/rpmbuild/SOURCES + cp ./RPM/spec.spec . + sed -i "s:\$$SYS_DIR:${SYS_DIR}:g" spec.spec + sed -i "s:\$$PKG_NAME:${PKG_NAME}:g" spec.spec + sed -i "s:\$$VERSION:${VERSION}:g" spec.spec + sed -i "s:\$$RELEASE:${RELEASE}:g" spec.spec + rpmbuild -bb spec.spec + mv ~/rpmbuild/RPMS/x86_64/*.rpm . + rm -r ~/rpmbuild + +post: + expr ${VERSION} + 1 > VERSION.txt + +clean: + rm -rf ./$(PKG_DIR) spec.spec diff --git a/packaging/README.md b/packaging/README.md new file mode 100644 index 00000000..88e12120 --- /dev/null +++ b/packaging/README.md @@ -0,0 +1,37 @@ +# Generate Packages: +Run `make` to generate both .deb and .rpm packages and clean the build directories or individually run the following: + +- Run `make debian` to generate .deb package +- Run `make rpm` to generate .rpm package +- Run `make clean` once the packages are created. + +Edit `DEBIAN/control` and `RPM/spec.spec` files to change package description or maintainer information. \ +Edit `Makefile` to make changes to PKG_NAME, RELEASE or VERSION, etc. + +# Installation: +Debian: + `sudo apt install -f ./azure-files-diag.deb` + +RPM: + `sudo dnf install ./azure-files-diag-*.x86_64.rpm` + +Add `/opt/xstore/bin/diag-main.sh` to `PATH` for root user. __[Optional]__ + +# How to use: + +These scripts require root priveleges. +1. Start trace: +`sudo diag-main.sh start [] [CaptureNetwork] [OnAnomaly]`. + - NFS defaults to __v4__ (if no version is specified). + - [OPTION] are optional arguments. + +2. Stop: +If __OnAnomaly__ option is enabled, the script will auto detect and collect the traces and generate the zip file. No action needed here. Otherwise: `sudo diag-main.sh stop` + + +# Uninstall: +Debian: + `sudo apt remove azure-files-diag` + +RPM: + `sudo dnf remove azure-files-diag` diff --git a/packaging/RPM/spec.spec b/packaging/RPM/spec.spec new file mode 100644 index 00000000..b5408bb8 --- /dev/null +++ b/packaging/RPM/spec.spec @@ -0,0 +1,41 @@ +Name: $PKG_NAME +Version: $VERSION +Release: $RELEASE +Summary: Diagnostics scripts for NFS and CIFS +License: GPL +URL: https://example.com + +Requires: tcpdump +Requires: trace-cmd +Requires: rpcdebug +Requires: bcc + + +%description +Diagnostics scripts for NFS and CIFS + +%prep + +%install +# Install script and related files +# install -m 454 ~/opt/xstore/bin/diag-main.sh %{buildroot}/opt/xstore/bin/diag-main.sh +cp -r ~/rpmbuild/SOURCES/opt %{buildroot} +echo %{buildroot} + +%post +chmod 454 $SYS_DIR/bin/diag-main.sh + +%files +# List all the files that are part of the package +# /opt/xstore/bin/diag-main.sh +$SYS_DIR/bin/diag-main.sh +$SYS_DIR/lib/NfsDiagnostics/README +$SYS_DIR/lib/NfsDiagnostics/nfsclientlogs.sh +$SYS_DIR/lib/NfsDiagnostics/trace-nfsbpf +$SYS_DIR/lib/SMBDiagnostics/README +$SYS_DIR/lib/SMBDiagnostics/smbclientlogs.sh +$SYS_DIR/lib/SMBDiagnostics/trace-cifsbpf +%changelog + +%postun +rm -r $SYS_DIR diff --git a/packaging/VERSION.txt b/packaging/VERSION.txt new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/packaging/VERSION.txt @@ -0,0 +1 @@ +1