9 [ ! -z "$cleanup_lock" ] && rmdir $cleanup_lock
14 echo " -d dir (required)"
15 echo " Specifies the top level directory that all hosts share"
16 echo " and collects stats under. Each host will use a "
17 echo " subdirectory named after its hostname."
19 echo " If the host directory doesn't exist, stats collection"
20 echo " begins by clearing accumulators in /proc and launching"
21 echo " background tasks."
23 echo " If the host directory exists, the script stops "
24 echo " background processes and collects the results. A host"
25 echo " directory can not be reused once it has collected"
28 echo " Shows this help message."
31 echo " [on all nodes] $0 -d /tmp/collection"
32 echo " (time passes while a load is run)"
33 echo " [on all nodes] $0 -d /tmp/collection"
34 echo " tree /tmp/collection"
39 [ ${#*} == 0 ] && usage
41 while getopts ":d:" opt; do
48 if [ ! -e $topdir ]; then
49 mkdir -p $topdir || die "couldn't create dir $topdir"
52 [ ! -d $topdir ] && die "$topdir isn't a directory"
54 mydir="$topdir/`hostname`"
55 lock="$topdir/.`hostname`-lock"
57 mkdir $lock || "another script is working on $mydir, exiting."
62 [ ! -f $f ] && continue
71 [ ! -d $d ] && continue
72 log="$mydir/`basename $d`"
75 [ ! -f $d/$f ] && continue
76 echo "----------------- $f" >> $log
77 ( cd $d && cat $f ) >> $log
82 # find filter dirs, sigh.
84 for f in /proc/fs/lustre/obdfilter/*; do
85 [ ! -d $f ] && continue;
86 num_filter_dirs=$((num_filter_dirs + 1))
87 filter_dirs="$filter_dirs,`basename $f`"
89 if [ $num_filter_dirs == "1" ]; then
90 tmp=`echo $filter_dirs | sed -e 's/,//g'`
91 filter_dirs="/proc/fs/lustre/obdfilter/$tmp"
93 if [ $num_filter_dirs -gt "1" ]; then
94 filter_dirs="/proc/fs/lustre/obdfilter/{$filter_dirs}"
100 save=`echo $f | sed -e 's@/@_@g'`
101 [ ! -f $f ] && continue
102 cat $f > $mydir/$save
110 if ! which $1 > /dev/null 2>&1; then
119 echo "launched '$*' as pid $PID"
129 echo "starting collection in $mydir"
130 mkdir $mydir || die "couldn't create dir $mydir"
132 echo clearing files in /proc/fs/lustre
133 clear_files '/proc/fs/lustre/osc/*MNT*/rpc_stats'
134 clear_files '/proc/fs/lustre/llite/*/read_ahead_stats'
135 [ ! -z "$filter_dirs" ] && clear_files "$filter_dirs/brw_stats"
141 date > $mydir/started
148 [ -e $mydir/finished ] && die "$mydir already contains collected files"
149 [ ! -e $mydir/started ] && die "$mydir hasn't started collection?"
151 echo "collecting files for $mydir"
152 dump_files '/proc/fs/lustre/osc/*MNT*' max_dirty_mb max_pages_per_rpc \
153 max_rpcs_in_flight cur_grant_bytes rpc_stats
154 dump_files '/proc/fs/lustre/llite/*' read_ahead max_read_ahead_mb \
156 [ ! -z "$filter_dirs" ] && dump_files $filter_dirs \
157 readcache_max_filesize tot_granted \
160 for pid in `cat $pids`; do
161 echo killing pid $pid
166 save_proc_files cpuinfo meminfo slabinfo
168 if which lspci > /dev/null 2>&1; then
169 lspci > $mydir/lspci 2>&1
172 date > $mydir/finished
176 if [ -e $mydir ]; then