Infodoc ID |
|
Synopsis |
|
Date |
14321 |
|
Performance monitor script |
|
17 Sep 1999 |
This is a generic script that I send to customers. I have them make
this a cron job. The frequency I have the customer run this depending on
what customer's problem is.
Update, not original author:
What's needed is data covering both good and
bad performance time periods if possible, and a README from the customer
saying what time the problem was bad, so that we can compare -- it's the
comparison of the changes in the data with the customer's perceived performance
issues that is important.
#!/bin/sh
# A modification to allow this to run for many days and allow the sysadmin
# to delete old data
# set -x
DATESUFFIX=`date +%m%d`
OUTPUTDIR=/var/tmp/$DATESUFFIX
if [ ! -d $OUTPUTDIR ] ; then
mkdir -p $OUTPUTDIR
fi
PATH=$PATH:/usr/sbin:/usr/bin
export PATH
date >> $OUTPUTDIR/vmstat.out
vmstat 30 5 >> $OUTPUTDIR/vmstat.out
OSREV=`uname -r`
case $OSREV in
"5.6"* | "5.7"* )
IOARGS="-xnctpE"
;;
*) IOARGS="-xct"
;;
esac
date >> $OUTPUTDIR/iostat.out
iostat "$IOARGS" 30 5 >> $OUTPUTDIR/iostat.out
date >> $OUTPUTDIR/ps.out
/usr/bin/ps -el -o pcpu,pmem,fname,rss,vsz,pid,stime >> $OUTPUTDIR/ps.out
date >> $OUTPUTDIR/ucbps.out
/usr/ucb/ps -aux >> $OUTPUTDIR/ucbps.out
date >> $OUTPUTDIR/kmastat.out
echo kmastat | crash >> $OUTPUTDIR/kmastat.out
date >> $OUTPUTDIR/kernelmap.out
echo "map kernelmap" | crash >> $OUTPUTDIR/kernelmap.out
date >> $OUTPUTDIR/uptime.out
uptime >> $OUTPUTDIR/uptime.out
date >> $OUTPUTDIR/netstat.out
netstat -i >> $OUTPUTDIR/netstat.out
# uncomment these if you need data on /tmp (if running out of swap)
#date >> $OUTPUTDIR/du.out
#du -s /tmp >> $OUTPUTDIR/du.out
#date >> $OUTPUTDIR/ls.out
#ls -lt /tmp >> $OUTPUTDIR/ls.out
numcpu=`psrinfo | wc -l `
numcpus=`echo $numcpu`
case $numcpus in
1 ) ;;
0 ) echo "cpus = $numcpus cannot be true\n"
psrinfo
;;
* ) date >> $OUTPUTDIR/mpstat.out
mpstat 30 5 >> $OUTPUTDIR/mpstat.out
;;
esac
------------------- cut here ---
Alternatively, if the problem is too fine-grained to capture with snapshots
every 5 minutes or so, such as a problem that can be triggered by a command
but only lasts 1-7 minutes, this can be used instead. It's run by hand,
from the command line, with # of minutes TOTAL to continue capturing data
as the command-line argument:
#!/bin/sh
PATH=$PATH:/usr/sbin:/usr/bin
export PATH
DATESUFFIX=`date +%m%d`
OUTPUTDIR=/var/tmp/$DATESUFFIX
mkdir -p $OUTPUTDIR
time=$1
if [ -z "$time" ] ; then
echo "usage: $0 num_minutes"
exit 1
fi
if [ $time -eq 0 ] ; then
time=1
fi
time=`expr $time \* 60`
iterations=`expr $time / 5`
OSREV=`uname -r`
case $OSREV in "5.6"* | "5.7"* )
IOARGS="-xnctpE"
;;
*) IOARGS="-xct"
;;
esac
sar -A -o $OUTPUTDIR/sar.out 5 $iterations > /dev/null &
date >> $OUTPUTDIR/vmstat.out
vmstat 5 $iterations > $OUTPUTDIR/vmstat.out &
date >> $OUTPUTDIR/iostat.out
iostat $IOARGS 5 $iterations > $OUTPUTDIR/iostat.out
while [ $iterations -gt 0 ] ; do
date >> $OUTPUTDIR/ps.out
/usr/bin/ps -el -o pcpu,pmem,fname,rss,vsz,pid,stime >> $OUTPUTDIR/ps.out &
sleep 4
iterations=`expr $iterations - 1`
done
Top
Sun Proprietary/Confidential: Internal Use Only
Feedback to SunSolve Team