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