lustre_req_history

来自「lustre 1.6.5 source code」· 代码 · 共 164 行

TXT
164
字号
#!/bin/sh# Copyright (C) 2006  Cluster File Systems, Inc.# Purpose:# This script displays the history of requests from the local client  # to the Lustre servers.# Requires: tcp network (ksocklnd), ssh# In order to execute this script the user needs interaction-free scp access# to all the servers# Limitations:# The req_history files only keep a limited amount of data, so the results# may not be a complete history.REQ_FILES_OST="ost/OSS/ost_io/req_history \ost/OSS/ost_create/req_history \ost/OSS/ost/req_history"REQ_FILES_MDT="ldlm/services/ldlm_canceld/req_history \ldlm/services/ldlm_cbd/req_history \mdt/MDS/mds_readpage/req_history \mdt/MDS/mds_setattr/req_history \mdt/MDS/mds/req_history"REQ_FILES_CLIENT="ldlm/services/ldlm_canceld/req_history \ldlm/services/ldlm_cbd/req_history"if [ $#  -gt  0 ]; then	echo "Usage: $0"	echo "  This script collects the history of ptlrpc requests on"	echo "the servers from this client. The results are sorted by" 	echo "the transaction ID."	exit 1fitempip=`lctl list_nids | cut -d "@" -f1`echo $tempip | egrep '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'if [ $? -ne 0 ] ; then        CLIENT=`host $tempip | cut -d" " -f4`else        CLIENT=$tempipfiTMP_DIR_CLIENT=`mktemp -d /tmp/src_req_history.XXXXX`chmod ugo+rwx $TMP_DIR_CLIENTMDS_NODE=`cat /proc/fs/lustre/mdc/*/mds_conn_uuid | cut -d @ -f1`TARGET="OSS"i=0for NODE in `cat /proc/fs/lustre/osc/*-osc-*/ost_conn_uuid | cut -d @ -f1` ; do	NODE_ARRAY[$i]=$NODE	i=`expr $i + 1`done# Get the Histories from all the OSS'sk=0for NODE in `cat /proc/fs/lustre/osc/*-osc-*/ost_conn_uuid | cut -d @ -f1` ; do	SAME_OST=0	j=0	while [ $j -lt $k ]	do		if [ ${NODE_ARRAY[$j]} = $NODE ]		then			SAME_OST=1               fi                j=`expr $j + 1`	done	k=`expr $k + 1` 	if [ $SAME_OST -eq 1 ]        then                continue        fi	TMPFILE1=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`	TMPFILE2=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`	rm -f $TMPFILE1	rm -f $TMPFILE2	( echo cd /proc/fs/lustre	echo touch $TMPFILE1	echo touch $TMPFILE2	echo chmod go+rw $TMPFILE1	echo chmod go+rw $TMPFILE2	for FILE in $REQ_FILES_OST; do		SERVICE=`echo $FILE | cut -d "/" -f3`		echo "cat $FILE |cut -d\" \" -f1 | sed s/$/:$TARGET/| sed s/$/:$SERVICE/ >> $TMPFILE1"	done	for FILE in $REQ_FILES_CLIENT; do                SERVICE=`echo $FILE | cut -d "/" -f3`                echo "cat $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1"        done	if [ $CLIENT = $NODE ]	then		echo "grep -r 0@lo $TMPFILE1 >> $TMPFILE2"	else		echo "grep -r $CLIENT $TMPFILE1 >> $TMPFILE2"	fi	) | ssh $NODE	scp $NODE:$TMPFILE2 $TMP_DIR_CLIENT/	echo rm -f $TMPFILE1 $TMPFILE2 | ssh $NODEdone# Get the Histories from the MDSTARGET="MDS"for NODE in `cat /proc/fs/lustre/mdc/*/mds_conn_uuid | cut -d @ -f1`; do	TMPFILE1=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`        rm -f $TMPFILE1	TMPFILE2=`mktemp /tmp/temp_histories_$NODE.XXXXXXXXXX`        rm -f $TMPFILE2	( echo cd /proc/fs/lustre	echo touch $TMPFILE1	echo touch $TMPFILE2	echo chmod go+rw $TMPFILE1	echo chmod go+rw $TMPFILE2	for FILE in $REQ_FILES_MDT; do		SERVICE=`echo $FILE | cut -d "/" -f3`		echo "cat $FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1"	done	if [ $CLIENT = $NODE ]        then		echo "grep -r 0@lo $TMPFILE1 >> $TMPFILE2"	else		echo "grep -r $CLIENT $TMPFILE1 >> $TMPFILE2"	fi	) | ssh $NODE	scp $NODE:$TMPFILE2 $TMP_DIR_CLIENT/        echo rm -f $TMPFILE1 $TMPFILE2 | ssh $NODEdone# Get the Histories from the CLIENTTMPFILE1=`mktemp $TMP_DIR_CLIENT/temp_histories_$CLIENT.XXXXXXXXXX`TMPFILE2=`mktemp $TMP_DIR_CLIENT/temp_histories_$CLIENT.XXXXXXXXXX`TARGET="CLIENT"for FILE in $REQ_FILES_CLIENT; do	SERVICE=`echo $FILE | cut -d "/" -f3`	cat /proc/fs/lustre/$FILE | sed s/$/:$TARGET/ | sed s/$/:$SERVICE/ >> $TMPFILE1donegrep -r 0@lo $TMPFILE1 >> $TMPFILE2rm -f $TMPFILE1TMPFILE_DEST=`mktemp /tmp/req_histories.XXXXXXXXXX`TMPFILE_SORT=`mktemp /tmp/req_histories_sorted.XXXXXXXXXX`# Merge Histories from OSS's, MDS and CLIENTfor NODE in `ls $TMP_DIR_CLIENT` ; do	cat $TMP_DIR_CLIENT/$NODE >> $TMPFILE_DESTdone# Sort the histories w.r.t XIDsort -t : -k 4,4n $TMPFILE_DEST >> $TMPFILE_SORTrm -f $TMPFILE_DESTrm -rf $TMP_DIR_CLIENTecho "XID  	   Target	Service        Seq  	    	   Status"awk -F: '{ printf "%-10d %-10s %-15s   %-10d \t   %-15s \n", $4, $7, $8, $1, $6 }' $TMPFILE_SORTrm -f $TMPFILE_SORT

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?