source: vendor/current/ctdb/config/debug-hung-script.sh

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 1.8 KB
Line 
1#!/bin/sh
2
3# This script only works on Linux. Please modify (and submit patches)
4# for other operating systems.
5
6[ -n "$CTDB_BASE" ] || \
7 export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
8
9. "$CTDB_BASE/functions"
10
11loadconfig ctdb
12
13# Testing hook
14if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then
15 tmp="${CTDB_DEBUG_HUNG_SCRIPT_LOGFILE}.part"
16 exec >>"$tmp" 2>&1
17fi
18
19(
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
24
25 echo "===== Start of hung script debug for PID=\"$1\", event=\"$2\" ====="
26
27 echo "pstree -p -a ${1}:"
28 out=$(pstree -p -a $1)
29 echo "$out"
30
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"
45 fi
46 done
47
48 if [ "$2" != "init" ] ; then
49 echo "---- ctdb scriptstatus ${2}: ----"
50 ctdb scriptstatus "$2"
51 fi
52
53 echo "===== End of hung script debug for PID=\"$1\", event=\"$2\" ====="
54
55 if [ -n "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE" ] ; then
56 mv "$tmp" "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE"
57 fi
58
59) 9>"${CTDB_SCRIPT_VARDIR}/debug-hung-script.lock"
Note: See TracBrowser for help on using the repository browser.