50dc83
From 2a905a8ae6b4737e84543ad76b55f3346fa0f32c Mon Sep 17 00:00:00 2001
50dc83
From: Hari Gowtham <hgowtham@redhat.com>
50dc83
Date: Tue, 27 Aug 2019 14:12:31 +0530
50dc83
Subject: [PATCH 286/297] glusterfs.spec.in: added script files for machine /
50dc83
 component stats
50dc83
50dc83
Have added the file (extras/identify-hangs.sh) to the code base.
50dc83
And included the following to be packaged:
50dc83
50dc83
Quota Accounting issue:
50dc83
extras/quota/xattr_analysis.py (made available only on server)
50dc83
extras/quota/quota_fsck.py (made available only on server)
50dc83
extras/quota/log_accounting.sh
50dc83
50dc83
Debugging Statedumps:
50dc83
extras/identify-hangs.sh
50dc83
50dc83
Performance:
50dc83
extras/collect-system-stats.sh
50dc83
50dc83
Note: rest of the files were already included.
50dc83
50dc83
Label: DOWNSTREAM ONLY.
50dc83
50dc83
Change-Id: I2efb959865c3f381166c6a25c6eef613d13dd5ee
50dc83
fixes: bz#1719171
50dc83
Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/179515
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
50dc83
---
50dc83
 extras/Makefile.am       |  9 +++++++-
50dc83
 extras/identify-hangs.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
50dc83
 glusterfs.spec.in        |  8 ++++++++
50dc83
 3 files changed, 69 insertions(+), 1 deletion(-)
50dc83
 create mode 100644 extras/identify-hangs.sh
50dc83
50dc83
diff --git a/extras/Makefile.am b/extras/Makefile.am
50dc83
index 983f014..8cbfda1 100644
50dc83
--- a/extras/Makefile.am
50dc83
+++ b/extras/Makefile.am
50dc83
@@ -30,9 +30,14 @@ endif
50dc83
 
50dc83
 scriptsdir = $(datadir)/glusterfs/scripts
50dc83
 scripts_SCRIPTS = thin-arbiter/setup-thin-arbiter.sh
50dc83
+scripts_SCRIPTS += quota/log_accounting.sh
50dc83
+scripts_SCRIPTS += collect-system-stats.sh
50dc83
+scripts_SCRIPTS += identify-hangs.sh
50dc83
 if WITH_SERVER
50dc83
 scripts_SCRIPTS += post-upgrade-script-for-quota.sh \
50dc83
 	pre-upgrade-script-for-quota.sh stop-all-gluster-processes.sh
50dc83
+scripts_SCRIPTS += quota/quota_fsck.py
50dc83
+scripts_SCRIPTS += quota/xattr_analysis.py
50dc83
 if USE_SYSTEMD
50dc83
 scripts_SCRIPTS += control-cpu-load.sh
50dc83
 scripts_SCRIPTS += control-mem.sh
50dc83
@@ -50,7 +55,9 @@ EXTRA_DIST = glusterfs-logrotate gluster-rsyslog-7.2.conf gluster-rsyslog-5.8.co
50dc83
 	command-completion/Makefile command-completion/README \
50dc83
 	stop-all-gluster-processes.sh clang-checker.sh mount-shared-storage.sh \
50dc83
 	control-cpu-load.sh control-mem.sh group-distributed-virt \
50dc83
-	thin-arbiter/thin-arbiter.vol thin-arbiter/setup-thin-arbiter.sh
50dc83
+	thin-arbiter/thin-arbiter.vol thin-arbiter/setup-thin-arbiter.sh \
50dc83
+	quota/xattr_analysis.py quota/quota_fsck.py quota/log_accounting.sh \
50dc83
+	collect-system-stats.sh identify-hangs.sh
50dc83
 
50dc83
 if WITH_SERVER
50dc83
 install-data-local:
50dc83
diff --git a/extras/identify-hangs.sh b/extras/identify-hangs.sh
50dc83
new file mode 100644
50dc83
index 0000000..ebc6bf1
50dc83
--- /dev/null
50dc83
+++ b/extras/identify-hangs.sh
50dc83
@@ -0,0 +1,53 @@
50dc83
+#!/bin/bash
50dc83
+function get_statedump_fnames_without_timestamps
50dc83
+{
50dc83
+    ls | grep -E "[.]dump[.][0-9][0-9]*" | cut -f1-3 -d'.' | sort -u
50dc83
+}
50dc83
+
50dc83
+function get_non_uniq_fields
50dc83
+{
50dc83
+    local statedump_fname_prefix=$1
50dc83
+    print_stack_lkowner_unique_in_one_line "$statedump_fname_prefix" | sort | uniq -c | grep -vE "^\s*1 " | awk '{$1="repeats="$1; print $0}'
50dc83
+}
50dc83
+
50dc83
+function print_stack_lkowner_unique_in_one_line
50dc83
+{
50dc83
+    local statedump_fname_prefix=$1
50dc83
+    sed -e '/./{H;$!d;}' -e 'x;/unique=/!d;/stack=/!d;/lk-owner=/!d;/pid=/!d;' "${statedump_fname_prefix}"* | grep -E "(stack|lk-owner|unique|pid)=" | paste -d " " - - - -
50dc83
+}
50dc83
+
50dc83
+function get_stacks_that_appear_in_multiple_statedumps
50dc83
+{
50dc83
+    #If a stack with same 'unique/lk-owner/stack' appears in multiple statedumps
50dc83
+    #print the stack
50dc83
+    local statedump_fname_prefix=$1
50dc83
+    while read -r non_uniq_stack;
50dc83
+    do
50dc83
+        if [ -z "$printed" ];
50dc83
+        then
50dc83
+            printed="1"
50dc83
+        fi
50dc83
+        echo "$statedump_fname_prefix" "$non_uniq_stack"
50dc83
+    done < <(get_non_uniq_fields "$statedump_fname_prefix")
50dc83
+}
50dc83
+
50dc83
+statedumpdir=${1}
50dc83
+if [ -z "$statedumpdir" ];
50dc83
+then
50dc83
+    echo "Usage: $0 <statedump-dir>"
50dc83
+    exit 1
50dc83
+fi
50dc83
+
50dc83
+if [ ! -d "$statedumpdir" ];
50dc83
+then
50dc83
+    echo "$statedumpdir: Is not a directory"
50dc83
+    echo "Usage: $0 <statedump-dir>"
50dc83
+    exit 1
50dc83
+fi
50dc83
+
50dc83
+cd "$statedumpdir" || exit 1
50dc83
+for statedump_fname_prefix in $(get_statedump_fnames_without_timestamps);
50dc83
+do
50dc83
+    get_stacks_that_appear_in_multiple_statedumps "$statedump_fname_prefix"
50dc83
+done | column -t
50dc83
+echo "NOTE: stacks with lk-owner=\"\"/lk-owner=0000000000000000/unique=0 may not be hung frames and need further inspection" >&2
50dc83
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
50dc83
index 00603ec..3c2e2dc 100644
50dc83
--- a/glusterfs.spec.in
50dc83
+++ b/glusterfs.spec.in
50dc83
@@ -1107,6 +1107,9 @@ exit 0
50dc83
      %{_datadir}/glusterfs/scripts/post-upgrade-script-for-quota.sh
50dc83
      %{_datadir}/glusterfs/scripts/pre-upgrade-script-for-quota.sh
50dc83
 %endif
50dc83
+%{_datadir}/glusterfs/scripts/identify-hangs.sh
50dc83
+%{_datadir}/glusterfs/scripts/collect-system-stats.sh
50dc83
+%{_datadir}/glusterfs/scripts/log_accounting.sh
50dc83
 # xlators that are needed on the client- and on the server-side
50dc83
 %dir %{_libdir}/glusterfs
50dc83
 %dir %{_libdir}/glusterfs/%{version}%{?prereltag}
50dc83
@@ -1352,6 +1355,8 @@ exit 0
50dc83
 %if ( 0%{!?_without_server:1} )
50dc83
 %files server
50dc83
 %doc extras/clear_xattrs.sh
50dc83
+%{_datadir}/glusterfs/scripts/xattr_analysis.py*
50dc83
+%{_datadir}/glusterfs/scripts/quota_fsck.py*
50dc83
 # sysconf
50dc83
 %config(noreplace) %{_sysconfdir}/glusterfs
50dc83
 %exclude %{_sysconfdir}/glusterfs/thin-arbiter.vol
50dc83
@@ -1942,6 +1947,9 @@ fi
50dc83
 %endif
50dc83
 
50dc83
 %changelog
50dc83
+* Tue Aug 27 2019 Hari Gowtham <hgowtham@redhat.com>
50dc83
+- Added scripts to collect machine stats and component stats (#1719171)
50dc83
+
50dc83
 * Tue Jun 18  2019 Jiffin Tony Thottan <jthottan@redhat.com>
50dc83
 - build glusterfs-ganesha for rhel 7 and above (#1720551)
50dc83
 
50dc83
-- 
50dc83
1.8.3.1
50dc83