s4:lib/socket: simplify iface_list_wildcard() and its callers
[Samba.git] / ctdb / config / debug-hung-script.sh
blob63d695f01b3f79662c642336f3ad2605d66462ec
1 #!/bin/sh
3 [ -n "$CTDB_BASE" ] || \
4 export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
6 . "$CTDB_BASE/functions"
8 loadconfig ctdb
10 # Testing hook
11 if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then
12 exec >>"$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" 2>&1
16 flock --wait 2 9 || exit 1
18 echo "===== Start of hung script debug for PID=\"$1\", event=\"$2\" ====="
20 echo "pstree -p -a ${1}:"
21 out=$(pstree -p -a $1)
22 echo "$out"
24 # Check for processes matching a regular expression and print
25 # stack staces. This could help confirm that certain processes
26 # are stuck in certain places such as the cluster filesystem. The
27 # regexp should separate items with "\|" and should not contain
28 # parentheses. The default pattern can be replaced for testing.
29 default_pat='exportfs\|rpcinfo'
30 pat="${CTDB_DEBUG_HUNG_SCRIPT_STACKPAT:-${default_pat}}"
31 echo "$out" |
32 sed -n "s@.*-\(.*${pat}.*\),\([0-9]*\).*@\2 \1@p" |
33 while read pid name ; do
34 trace=$(cat "/proc/${pid}/stack" 2>/dev/null)
35 if [ $? -eq 0 ] ; then
36 echo "---- Stack trace of interesting process ${pid}[${name}] ----"
37 echo "$trace"
39 done
41 if [ "$2" = "init" ] ; then
42 exit 0
45 echo "---- ctdb scriptstatus ${2}: ----"
46 # No use running several of these in parallel if, say, "releaseip"
47 # event hangs for multiple IPs. In that case the output would be
48 # interleaved in the log and would just be confusing.
49 ctdb scriptstatus "$2"
51 echo "===== End of hung script debug for PID=\"$1\", event=\"$2\" ====="
53 ) 9>"${CTDB_VARDIR}/debug-hung-script.lock"