2 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5 # This script displays the history of requests from the local client
6 # to the Lustre servers.
8 # Requires: tcp network (ksocklnd), ssh
9 # In order to execute this script the user needs interaction-free scp access
13 # The req_history files only keep a limited amount of data, so the results
14 # may not be a complete history.
16 REQ_FILES_OST="ost/OSS/ost_io/req_history \
17 ost/OSS/ost_create/req_history \
18 ost/OSS/ost/req_history"
20 REQ_FILES_MDT="ldlm/services/ldlm_canceld/req_history \
21 ldlm/services/ldlm_cbd/req_history \
22 mdt/MDS/mds_readpage/req_history \
23 mdt/MDS/mds_setattr/req_history \
24 mdt/MDS/mds/req_history"
26 REQ_FILES_CLIENT="ldlm/services/ldlm_canceld/req_history \
27 ldlm/services/ldlm_cbd/req_history"
31 echo " This script collects the history of ptlrpc requests on"
32 echo "the servers from this client. The results are sorted by"
33 echo "the transaction ID."
37 tempip=`lctl list_nids | cut -d "@" -f1`
39 echo $tempip | egrep '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
40 if [ $? -ne 0 ] ; then
41 CLIENT=`host $tempip | cut -d" " -f4`
46 TMP_DIR_CLIENT=`mktemp -d /tmp/src_req_history.XXXXX`
47 chmod ugo+rwx $TMP_DIR_CLIENT
48 MDS_NODE=`cat /proc/fs/lustre/mdc/*/mds_conn_uuid | cut -d @ -f1`
51 for NODE in `cat /proc/fs/lustre/osc/*-osc-*/ost_conn_uuid | cut -d @ -f1` ; do
56 # Get the Histories from all the OSS's
59 for NODE in `cat /proc/fs/lustre/osc/*-osc-*/ost_conn_uuid | cut -d @ -f1` ; do
65 if [ ${NODE_ARRAY[$j]} = $NODE ]
72 if [ $SAME_OST -eq 1 ]
76 TMPFILE1=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`
77 TMPFILE2=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`
80 ( echo cd /proc/fs/lustre
83 echo chmod go+rw $TMPFILE1
84 echo chmod go+rw $TMPFILE2
85 for FILE in $REQ_FILES_OST; do
86 SERVICE=`echo $FILE | cut -d "/" -f3`
87 echo "cat $FILE |cut -d\" \" -f1 | sed s/$/:$TARGET/| sed s/$/:$SERVICE/ >> $TMPFILE1"
89 for FILE in $REQ_FILES_CLIENT; do
90 SERVICE=`echo $FILE | cut -d "/" -f3`
91 echo "cat $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1"
93 if [ $CLIENT = $NODE ]
95 echo "grep -r 0@lo $TMPFILE1 >> $TMPFILE2"
97 echo "grep -r $CLIENT $TMPFILE1 >> $TMPFILE2"
100 scp $NODE:$TMPFILE2 $TMP_DIR_CLIENT/
101 echo rm -f $TMPFILE1 $TMPFILE2 | ssh $NODE
104 # Get the Histories from the MDS
107 for NODE in `cat /proc/fs/lustre/mdc/*/mds_conn_uuid | cut -d @ -f1`; do
108 TMPFILE1=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`
110 TMPFILE2=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`
112 ( echo cd /proc/fs/lustre
115 echo chmod go+rw $TMPFILE1
116 echo chmod go+rw $TMPFILE2
117 for FILE in $REQ_FILES_MDT; do
118 SERVICE=`echo $FILE | cut -d "/" -f3`
119 echo "cat $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1"
121 if [ $CLIENT = $NODE ]
123 echo "grep -r 0@lo $TMPFILE1 >> $TMPFILE2"
125 echo "grep -r $CLIENT $TMPFILE1 >> $TMPFILE2"
128 scp $NODE:$TMPFILE2 $TMP_DIR_CLIENT/
129 echo rm -f $TMPFILE1 $TMPFILE2 | ssh $NODE
132 # Get the Histories from the CLIENT
134 TMPFILE1=`mktemp $TMP_DIR_CLIENT/temp_histories_$CLIENT.XXXXXXXXXX`
135 TMPFILE2=`mktemp $TMP_DIR_CLIENT/temp_histories_$CLIENT.XXXXXXXXXX`
138 for FILE in $REQ_FILES_CLIENT; do
139 SERVICE=`echo $FILE | cut -d "/" -f3`
140 cat /proc/fs/lustre/$FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1
143 grep -r 0@lo $TMPFILE1 >> $TMPFILE2
146 TMPFILE_DEST=`mktemp /tmp/req_histories.XXXXXXXXXX`
147 TMPFILE_SORT=`mktemp /tmp/req_histories_sorted.XXXXXXXXXX`
149 # Merge Histories from OSS's, MDS and CLIENT
151 for NODE in `ls $TMP_DIR_CLIENT` ; do
152 cat $TMP_DIR_CLIENT/$NODE >> $TMPFILE_DEST
155 # Sort the histories w.r.t XID
157 sort -t : -k 4,4n $TMPFILE_DEST >> $TMPFILE_SORT
159 rm -rf $TMP_DIR_CLIENT
161 echo "XID Target Service Seq Status"
162 awk -F: '{ printf "%-10d %-10s %-15s %-10d \t %-15s \n", $4, $7, $8, $1, $6 }' $TMPFILE_SORT