lib: Remove unused parmlist code
[Samba.git] / ctdb / config / debug-hung-script.sh
blob3f800fc55599b0b8a5a000da4a787de52c4ec739
1 #!/bin/sh
3 # This script only works on Linux. Please modify (and submit patches)
4 # for other operating systems.
6 [ -n "$CTDB_BASE" ] || \
7 export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
9 . "$CTDB_BASE/functions"
11 loadconfig ctdb
13 # Testing hook
14 if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then
15 tmp="${CTDB_DEBUG_HUNG_SCRIPT_LOGFILE}.part"
16 exec >>"$tmp" 2>&1
20 # No use running several of these in parallel if, say, "releaseip"
21 # event hangs for multiple IPs. In that case the output would be
22 # interleaved in the log and would just be confusing.
23 flock --wait 2 9 || exit 1
25 echo "===== Start of hung script debug for PID=\"$1\", event=\"$2\" ====="
27 echo "pstree -p -a ${1}:"
28 out=$(pstree -p -a $1)
29 echo "$out"
31 # Check for processes matching a regular expression and print
32 # stack staces. This could help confirm that certain processes
33 # are stuck in certain places such as the cluster filesystem. The
34 # regexp must separate items with "|" and must not contain
35 # parentheses. The default pattern can be replaced for testing.
36 default_pat='exportfs|rpcinfo'
37 pat="${CTDB_DEBUG_HUNG_SCRIPT_STACKPAT:-${default_pat}}"
38 echo "$out" |
39 sed -r -n "s@.*-(.*(${pat}).*),([0-9]*).*@\3 \1@p" |
40 while read pid name ; do
41 trace=$(cat "/proc/${pid}/stack" 2>/dev/null)
42 if [ $? -eq 0 ] ; then
43 echo "---- Stack trace of interesting process ${pid}[${name}] ----"
44 echo "$trace"
46 done
48 if [ "$2" != "init" ] ; then
49 echo "---- ctdb scriptstatus ${2}: ----"
50 ctdb scriptstatus "$2"
53 echo "===== End of hung script debug for PID=\"$1\", event=\"$2\" ====="
55 if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then
56 mv "$tmp" "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE"
59 ) 9>"${CTDB_VARDIR}/debug-hung-script.lock"