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=$(lctl get_param -n mdc.*.mds_conn_uuid | cut -d @ -f1)
51 for NODE in $(lctl get_param -n osc.*-osc-*.ost_conn_uuid | cut -d @ -f1) ; do
56 # Get the Histories from all the OSS's
59 for NODE in $(lctl get_param -n 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 touch $TMPFILE1
82 echo chmod go+rw $TMPFILE1
83 echo chmod go+rw $TMPFILE2
84 for FILE in $REQ_FILES_OST; do
85 SERVICE=`echo $FILE | cut -d "/" -f3`
86 echo "lctl get_param -n $FILE |cut -d\" \" -f1 | sed s/$/:$TARGET/| sed s/$/:$SERVICE/ >> $TMPFILE1"
88 for FILE in $REQ_FILES_CLIENT; do
89 SERVICE=`echo $FILE | cut -d "/" -f3`
90 echo "lctl get_param -n $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1"
92 if [ $CLIENT = $NODE ]
94 echo "grep -r 0@lo $TMPFILE1 >> $TMPFILE2"
96 echo "grep -r $CLIENT $TMPFILE1 >> $TMPFILE2"
99 scp $NODE:$TMPFILE2 $TMP_DIR_CLIENT/
100 echo rm -f $TMPFILE1 $TMPFILE2 | ssh $NODE
103 # Get the Histories from the MDS
106 for NODE in $(lctl get_param -n mdc.*.mds_conn_uuid | cut -d @ -f1); do
107 TMPFILE1=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`
109 TMPFILE2=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`
111 ( echo touch $TMPFILE1
113 echo chmod go+rw $TMPFILE1
114 echo chmod go+rw $TMPFILE2
115 for FILE in $REQ_FILES_MDT; do
116 SERVICE=`echo $FILE | cut -d "/" -f3`
117 echo "lctl get_param -n $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1"
119 if [ $CLIENT = $NODE ]
121 echo "grep -r 0@lo $TMPFILE1 >> $TMPFILE2"
123 echo "grep -r $CLIENT $TMPFILE1 >> $TMPFILE2"
126 scp $NODE:$TMPFILE2 $TMP_DIR_CLIENT/
127 echo rm -f $TMPFILE1 $TMPFILE2 | ssh $NODE
130 # Get the Histories from the CLIENT
132 TMPFILE1=`mktemp $TMP_DIR_CLIENT/temp_histories_$CLIENT.XXXXXXXXXX`
133 TMPFILE2=`mktemp $TMP_DIR_CLIENT/temp_histories_$CLIENT.XXXXXXXXXX`
136 for FILE in $REQ_FILES_CLIENT; do
137 SERVICE=`echo $FILE | cut -d "/" -f3`
138 lctl get_param -n $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1
141 grep -r 0@lo $TMPFILE1 >> $TMPFILE2
144 TMPFILE_DEST=`mktemp /tmp/req_histories.XXXXXXXXXX`
145 TMPFILE_SORT=`mktemp /tmp/req_histories_sorted.XXXXXXXXXX`
147 # Merge Histories from OSS's, MDS and CLIENT
149 for NODE in `ls $TMP_DIR_CLIENT` ; do
150 cat $TMP_DIR_CLIENT/$NODE >> $TMPFILE_DEST
153 # Sort the histories w.r.t XID
155 sort -t : -k 4,4n $TMPFILE_DEST >> $TMPFILE_SORT
157 rm -rf $TMP_DIR_CLIENT
159 echo "XID Target Service Seq Status"
160 awk -F: '{ printf "%-10d %-10s %-15s %-10d \t %-15s \n", $4, $7, $8, $1, $6 }' $TMPFILE_SORT