3 # System Profiling Script
5 TESTS="oprofile iostat vmstat proc_dump"
8 export OUTPUTDIR=/home/op
9 export KERNELDIR=/usr/src/linux
10 export LUSTREDIR=/usr/src/lustre
11 export PORTALSDIR=/usr/src/portals
15 #CTR0_EVENT=CPU_CLK_UNHALTED
18 # for intel Petium 4 onwards... Also requires Unit Mask
19 CTR0_EVENT=GLOBAL_POWER_EVENTS
28 # Params for PROC DUMP
29 export PROC_SAMPLING=2
31 #-------------------------------------------------------------------
34 echo `date +%T`": oprofile started...." >> $OUTPUTDIR/$HOSTNAME/summary
35 op_start --ctr0-event=$CTR0_EVENT --ctr0-count=$CTR0_COUNT --ctr0-unit-mask=$CTR0_UNIT_MASK --vmlinux=${KERNELDIR}/vmlinux
36 mkdir -p ${OUTPUTDIR}/${HOSTNAME}/oprofile/prof_source/{obdclass,obdecho,osc,ptlrpc,extN,obdfilter,ost,mdc,mds4mds,mds4mds_extN,llite,portals,$NAL}
37 mkdir -p ${OUTPUTDIR}/${HOSTNAME}/oprofile/profiling
42 echo `date +%T`": iostat started...." >> $OUTPUTDIR/$HOSTNAME/summary
44 mkdir ${OUTPUTDIR}/${HOSTNAME}/iostat
46 iostat $IO_SAMPLING > $OUTPUTDIR/$HOSTNAME/iostat/iostat.op &
48 echo $PID > $OUTPUTDIR/$HOSTNAME/tmp/iostat.pid
54 echo `date +%T`": vmstat started...." >> $OUTPUTDIR/$HOSTNAME/summary
56 mkdir ${OUTPUTDIR}/${HOSTNAME}/vmstat
58 vmstat $VM_SAMPLING > $OUTPUTDIR/$HOSTNAME/vmstat/vmstat.op &
60 echo $PID > $OUTPUTDIR/$HOSTNAME/tmp/vmstat.pid
64 echo `date +%T`": proc dump started...." >> $OUTPUTDIR/$HOSTNAME/summary
66 CTRFILE=/$OUTPUTDIR/$HOSTNAME/tmp/running.$$.pid;
68 while [ -f $CTRFILE ]; do
69 cat /proc/meminfo >> $OUTPUTDIR/$HOSTNAME/meminfo;
70 cat /proc/interrupts >> $OUTPUTDIR/$HOSTNAME/interrupts;
71 cat /proc/net/dev >> $OUTPUTDIR/$HOSTNAME/net-dev;
72 sleep ${PROC_SAMPLING};
75 CTRFILE=/tmp/running.$!.pid
76 echo "proc_dump_ctrl $CTRFILE" >> /tmp/prof-ctrl
84 echo `date +%T`": oprofile stopped...." >> $OUTPUTDIR/$HOSTNAME/summary
86 for i in obdclass obdecho osc ptlrpc extN obdfilter mds ost mdc llite
88 oprofpp -l ${LUSTREDIR}/${i}/${i}.o > ${OUTPUTDIR}/${HOSTNAME}/oprofile/profiling/${i}.prof 2>/dev/null
90 oprofpp -l ${LUSTREDIR}/mds/mds_extN.o > ${OUTPUTDIR}/${HOSTNAME}/oprofile/profiling/mds_extN.prof 2>/dev/null
91 oprofpp -l ${PORTALSDIR}/linux/oslib/portals.o > ${OUTPUTDIR}/${HOSTNAME}/oprofile/profiling/portals.prof 2>/dev/null
92 oprofpp -l ${PORTALSDIR}/linux/${NAL}/k${NAL}.o > ${OUTPUTDIR}/${HOSTNAME}/oprofile/profiling/k${NAL}.prof 2>/dev/null
95 for i in obdclass obdecho osc ptlrpc extN obdfilter ost mdc llite
97 op_to_source --source-dir=${LUSTREDIR}/${i}/ --output-dir=${OUTPUTDIR}/${HOSTNAME}/oprofile/prof_source/${i}/ ${LUSTREDIR}/${i}/${i}.o 2>/dev/null
100 op_to_source --source-dir=${LUSTREDIR}/mds/ --output-dir=${OUTPUTDIR}/${HOSTNAME}/oprofile/prof_source/mds4mds/ ${LUSTREDIR}/mds/mds.o 2>/dev/null
101 op_to_source --source-dir=${LUSTREDIR}/mds/ --output-dir=${OUTPUTDIR}/${HOSTNAME}/oprofile/prof_source/mds4mds_extN/ ${LUSTREDIR}/mds/mds_extN.o 2>/dev/null
103 op_to_source --source-dir=${PORTALSDIR}/linux/oslib/ --output-dir=${OUTPUTDIR}/${HOSTNAME}/oprofile/prof_source/portals ${PORTALSDIR}/linux/oslib/portals.o 2>/dev/null
104 op_to_source --source-dir=${PORTALSDIR}/linux/${NAL}/ --output-dir=${OUTPUTDIR}/${HOSTNAME}/oprofile/prof_source/${NAL} ${PORTALSDIR}/linux/${NAL}/k${NAL}.o 2>/dev/null
106 op_time -l > ${OUTPUTDIR}/${HOSTNAME}/oprofile/globalprofile 2>/dev/null
111 echo `date +%T`": iostat stopped...." >> $OUTPUTDIR/$HOSTNAME/summary
113 PID=$(cat $OUTPUTDIR/$HOSTNAME/tmp/iostat.pid)
118 echo `date +%T`": vmstat stopped...." >> $OUTPUTDIR/$HOSTNAME/summary
120 PID=$(cat $OUTPUTDIR/$HOSTNAME/tmp/vmstat.pid)
129 echo `date +%T`": proc dump stopped...." >> $OUTPUTDIR/$HOSTNAME/summary
130 CTRFILE=`cat /tmp/prof-ctrl | awk '$1 == "prof_dump_ctrl" {print $2}'`
133 #-------------------------------------------------------------------
140 while [ ${#*} -gt 1 ]; do
161 echo unrecognized option $1
167 echo "kerneldir $KERNELDIR" > /tmp/prof-ctrl
168 echo -e "\nlustredir $LUSTREDIR" >> /tmp/prof-ctrl
169 echo -e "\nportalsdir $PORTALSDIR" >> /tmp/prof-ctrl
170 echo -e "\noutputdir $OUTPUTDIR" >> /tmp/prof-ctrl
172 if [ -d ${OUTPUTDIR}/${HOSTNAME} ]; then
173 echo "Output already exists"
174 echo "Please take backup and remove it"
178 mkdir -p ${OUTPUTDIR}/${HOSTNAME}
179 echo -e "Profiling started on $HOSTNAME" > ${OUTPUTDIR}/${HOSTNAME}/summary
180 echo -e "\n\nModules Listing on $HOSTNAME" >> ${OUTPUTDIR}/${HOSTNAME}/summary
181 /sbin/lsmod >> ${OUTPUTDIR}/${HOSTNAME}/summary
182 echo -e "\n\nKernel : " >> ${OUTPUTDIR}/${HOSTNAME}/summary
183 uname -a >> ${OUTPUTDIR}/${HOSTNAME}/summary
184 echo -e "\n\nPCI Devices : " >> ${OUTPUTDIR}/${HOSTNAME}/summary
185 lspci -t -v >> ${OUTPUTDIR}/${HOSTNAME}/summary
186 echo -e "\n\nTests carried out " >> ${OUTPUTDIR}/${HOSTNAME}/summary
188 mkdir $OUTPUTDIR/$HOSTNAME/tmp
189 for test in $TESTS; do
195 KERNELDIR=`cat /tmp/prof-ctrl | awk '$1 == "kerneldir" {print $2}'`
196 LUSTREDIR=`cat /tmp/prof-ctrl | awk '$1 == "lustredir" {print $2}'`
197 PORTALSDIR=`cat /tmp/prof-ctrl | awk '$1 == "portalsdir" {print $2}'`
198 OUTPUTDIR=`cat /tmp/prof-ctrl | awk '$1 == "outputdir" {print $2}'`
199 for test in $TESTS; do
203 rm -rf ${OUTPUTDIR}/$HOSTNAME/tmp
204 tar -cf ${OUTPUTDIR}/${HOSTNAME}.tar ${OUTPUTDIR}/${HOSTNAME}
205 echo "Dumped results in ${OUTPUTDIR}/${HOSTNAME}.tar"
208 if "oprofile" in $TESTS; then
214 OUTPUTDIR=`cat /tmp/prof-ctrl | awk '$1 == "outputdir" {print $2}'`
215 echo Deleting directory $OUTPUTDIR/$HOSTNAME ...
216 rm -rf $OUTPUTDIR/$HOSTNAME
217 echo Deleting file $OUTPUTDIR/${HOSTNAME}.tar ...
218 rm -rf $OUTPUTDIR/${HOSTNAME}.tar
219 echo Deleting oprofile samples ...
220 rm -f /var/lib/oprofile/samples/*
224 echo $"Usage : $0 {start|stop|dump|clean} [OPTIONS]";
226 echo $" -l lustre_dir"
227 echo $" -p portals_dir"
228 echo $" -k kernel_dir"
229 echo $" -o output_dir"