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