summaryrefslogtreecommitdiff
path: root/ctdb/config
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-11-14 13:31:03 +1100
committerAmitay Isaacs <amitay@samba.org>2014-11-18 04:17:10 +0100
commit2ebc305be64cd59ad8cb4ccb6beb6ec6e66bf07a (patch)
treed1afb9cfe6dbbaf740f1fb4f2448561f04fd736f /ctdb/config
parent0062a2f5fb464b7c0991ccefd2f9d146fca54a0e (diff)
downloadsamba-2ebc305be64cd59ad8cb4ccb6beb6ec6e66bf07a.tar.gz
ctdb-scripts: Factor out new function program_stack_traces()
In the process, fix a bug where an extra trace would be printed. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/config')
-rwxr-xr-xctdb/config/functions40
1 files changed, 24 insertions, 16 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 53a36dc3355..49553c73559 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -211,6 +211,27 @@ get_proc ()
}
######################################################
+# Print up to $_max kernel stack traces for processes named $_program
+program_stack_traces ()
+{
+ _prog="$1"
+ _max="${2:-1}"
+
+ _count=1
+ for _pid in $(pidof "$_prog") ; do
+ [ $_count -le $_max ] || break
+
+ # Do this first to avoid racing with process exit
+ _stack=$(get_proc "${_pid}/stack" 2>/dev/null)
+ if [ -n "$_stack" ] ; then
+ echo "Stack trace for ${_prog}[${_pid}]:"
+ echo "$_stack"
+ _count=$(($_count + 1))
+ fi
+ done
+}
+
+######################################################
# Check that an RPC service is healthy -
# this includes allowing a certain number of failures
# before marking the NFS service unhealthy.
@@ -745,23 +766,10 @@ startstop_nfs() {
# Dump up to the configured number of nfsd thread backtraces.
nfs_dump_some_threads ()
{
- [ -n "$CTDB_NFS_DUMP_STUCK_THREADS" ] || CTDB_NFS_DUMP_STUCK_THREADS=5
-
- # Optimisation to avoid running an unnecessary pidof
- [ $CTDB_NFS_DUMP_STUCK_THREADS -gt 0 ] || return 0
+ _num="${CTDB_NFS_DUMP_STUCK_THREADS:-5}"
+ [ $_num -gt 0 ] || return 0
- _count=0
- for _pid in $(pidof nfsd) ; do
- [ $_count -le $CTDB_NFS_DUMP_STUCK_THREADS ] || break
-
- # Do this first to avoid racing with thread exit
- _stack=$(get_proc "${_pid}/stack" 2>/dev/null)
- if [ -n "$_stack" ] ; then
- echo "Stack trace for stuck nfsd thread [${_pid}]:"
- echo "$_stack"
- _count=$(($_count + 1))
- fi
- done
+ program_stack_traces "nfsd" $_num
}
########################################################