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