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