debug_winbindd.sh: add "n" to ps options to avoid name translation
[slow/toolbox.git] / trace.sh
1 #! /bin/sh
2
3
4 # Trace one afpsrv client process by PID with srvmsg -D and truss
5 # and snoop AFP traffic with one client by IP
6 #
7
8 if [ $# -ne 3 ] ; then
9     echo "Usage: trace.sh <folder for trace output> <PID of afpsrv client process> <IP of the AFP client>"
10     exit 1
11 fi
12
13 DIR="$1"
14 AFPPID=$2
15 IP=$3
16
17 echo Tracing afpsrv process with PID $AFPPID and AFP client with IP $IP.
18 echo Writing trace data to $DIR.
19
20 if [ ! -d "${DIR}" ] ; then
21     mkdir -p "${DIR}"
22 fi
23
24 exec >"${DIR}/trace.log" 2>&1
25
26 PATH=$PATH:/usr/local/helios/bin:/usr/local/helios/sbin
27 export PATH
28 HELIOSDIR=`cat /etc/HELIOSInstallPath`
29
30 echo Collecting system data ... > /dev/tty
31
32 date
33 echo
34 ps -efl
35 echo
36 "${HELIOSDIR}/bin/swho" -cn
37 echo
38 fuser "${HELIOSDIR}/lib/libhelios_s.so"
39 echo
40 fuser "${HELIOSDIR}/var/run/locktable"
41 echo
42
43 # Start traces
44 echo Starting traces... Now reproduce problem. Press RETURN to abort > /dev/tty
45
46 srvmsg -D $AFPPID -l all  > "${DIR}/afp.srvmsg" &
47 PID_SRVMSG_AFP=$!
48
49 truss -d -D -E -v all -o "${DIR}/afp.truss" -p $AFPPID &
50 PID_TRUSS_AFP=$!
51
52 snoop -o "${DIR}/snoop.pcap" host $IP and port 548 > /dev/null 2>&1 &
53 PID_SNOOP=$!
54
55 # Wait for RETURN
56 read LINE
57
58 # Terminate tracing session
59 echo Killing traces... > /dev/tty
60 kill $PID_SRVMSG_AFP $PID_TRUSS_AFP $PID_SNOOP
61
62 echo Creating tar archive of folder \"$DIR\" as \"$DIR.tar\" ...
63 tar cf "$DIR.tar" "$DIR"