#!/bin/sh #usage: slow [-test] PATH=/bin:/usr/bin:/usr/bsd export PATH echo "Slow version 2.3" #################################################################### # Slow: A tool for reporting and diagnosing performance problems # # By Darrell Root of Sterling Software / NASA-Ames Research Center # # (rootd@nas.nasa.gov, http://www.ee.pdx.edu) # # and Belinda Liviero of Intel Corporation # # Published and copyright by Sysadmin Magazine in October 98 # #################################################################### # #PORTING INSTRUCTIONS FOR YOUR SITE: # # 1) Set PINGHOST to your most important central server # 2) Set MAIL_LIST to be the email address you want to receive # performance trouble reports # 3) Set PUBLIC_DOMAIN to be where you have public domain performance tools # 4) Consider changing the TIME and REPEAT variables # 5) Edit the echo statements at the bottom of the script so that # customer expectations are properly communicated. # PINGHOST="most_important_fileserver" MAIL_LIST="email_address_to_send_slow_reports_to" PUBLIC_DOMAIN="/usr/local/bin" TIME=4 REPEATS=4 # # PINGHOST is the target of a ping command which gives you round trip time # TIME is the number of seconds commands such as vmstat collect data each run # REPEATS is the number of runs that commands such as vmstat will run # ################################################################### # #PORTING INSTRUCTIONS FOR A NEW OS: # # 1) Create a new CASE entry for your OS based on the uname output # 2) Using the IRIX case as an example, set each of the following # variables: OS, IOSTAT, MAIL, NFSSTAT, PING, PS, SAR, TOP, # NETSTAT, VMSTAT, and HARDWARE. We recommend that you use # explicit pathnames whenever possible # 3) Verify that the PATH variable is set properly for your OS # (the PATH must include the following commands: uname, # hostname, whoami, sleep, rm, and cat). # 4) Verify that the MAIL command you chose works with the # "-s SUBJECT" syntax (used at the end of this program). # 5) Test your port by running "slow -test" # 6) Email your port of "slow" to rootd@nas.nasa.gov # ################################################################### # #TO ADD AN ADDITIONAL DIAGNOSTIC COMMAND: # # 1) Pick a variable name (example: AFSSTAT). # 2) Add 'AFSSTAT="/usr/local/bin/afsstat -options"' to each # case statement. Use 'AFSSTAT="afsstat_not_implemented_on_sunos"' # for each OS that you don't have your new diagnostic working on yet. # 3) Add '$AFSSTAT > /tmp/slowN.afsstat.$$ 2>&1' to the bottom # part of the program. Also add a 'echo "Collecting afsstat statistics. # ################################################################### # If we don't want to send email to the $MAIL_LIST email address, # set test to 1 TEST=0 if [ "$1" = "-test" ] then TEST=1 fi HOSTNAME=`hostname` USERNAME=`whoami` echo "on one line, please describe your performance problem" read MESSAGE echo $MESSAGE > /tmp/slow.message.$$ echo " " echo "Give a number from 1 (minor) to 10 (unable to work) to indicate" echo "the severity of the performance problem" read SEVERITY echo "SEVERITY $SEVERITY" > /tmp/slow.messag2.$$ if [ "$USERNAME" = "root" ] then echo "You are logged in as root, what is the customers real email address?" read USERNAME fi echo "USERNAME $USERNAME" >> /tmp/slow.messag3.$$ # For each OS we need to pick the command and options we will use # for each type of diagnostic output we are interested in UNAME=`uname` UPTIME="/usr/ucb/uptime" case "$UNAME" in SunOS) VERSION=`uname -r` MAIL="/usr/ucb/mail" TOP="/usr/etc/top -S -I -d$REPEATS -s$TIME -b" NETSTAT="/usr/ucb/netstat -in" VMSTAT="/usr/ucb/vmstat $TIME $REPEATS" case "$VERSION" in 4.1*) OS="SUNOS" IOSTAT="iostat -t -d $TIME $REPEATS" NFSSTAT="/usr/etc/nfsstat -c" PING="/usr/etc/ping -s $PINGHOST 56 $REPEATS" PS="/usr/bin/ps auwwx" SAR="echo SAR_NOT_SUPPORTED_ON_SUNOS" HARDWARE="echo SunOS_does_not_have_a_hardware_inventory_command" ;; 5.*) OS="SOLARIS" IOSTAT="iostat -tx $TIME $REPEATS" NFSSTAT="/bin/nfsstat -c" PING="/usr/sbin/ping -s $PINGHOST 56 $REPEATS" PS="/usr/ucb/ps auwwwx" SAR="/bin/sar -u $TIME $REPEATS" HARDWARE="/usr/platform/`uname -m`/sbin/prtdiag" ;; *) OS="UNKNOWN" IOSTAT="iostat -tx $TIME $REPEATS" NFSSTAT="/bin/nfsstat -c" PING="/usr/sbin/ping -s $PINGHOST 56 $REPEATS" PS="/usr/ucb/ps auwwwx" SAR="/bin/sar -u $TIME $REPEATS" ;; esac ;; IRI*) OS="IRIX" IOSTAT="sar -d $TIME $REPEATS" MAIL="/usr/sbin/Mail" NFSSTAT="/usr/etc/nfsstat -c" PING="/usr/etc/ping -c $REPEATS $PINGHOST" PS="/bin/ps -elf" SAR="/bin/sar -u $TIME $REPEATS" TOP="${PUBLIC_DOMAIN}/top -S -I -d$REPEATS -s$TIME -b" NETSTAT="/usr/etc/netstat -in" VMSTAT="echo VMSTAT_IS_NOT_SUPPORTED_ON_IRIX" HARDWARE="/bin/hinv" ;; AIX*) OS="AIX" VERSION=`uname -v` IOSTAT="iostat -d $TIME $REPEATS" MAIL="/bin/mail" NFSSTAT="/usr/etc/nfsstat -c" PING="/usr/sbin/ping -c $REPEATS $PINGHOST" TOP="${PUBLIC_DOMAIN}/top -S -I -d$REPEATS -s$TIME -b" NETSTAT="/usr/ucb/netstat -in" VMSTAT="/usr/ucb/vmstat $TIME $REPEATS" HARDWARE="echo AIX_does_not_have_a_hardware_inventory_command" PS="/bin/ps -elf" # note: permissions to /usr/lib/sa/sadc must be 755 SAR="/usr/sbin/sar -u 4 4" ;; HP-UX*) OS="HPUX" VERSION=`uname -r` IOSTAT="iostat -t $TIME $REPEATS" MAIL="/usr/bin/mailx" TOP="${PUBLIC_DOMAIN}/top -S -I -d$REPEATS -s$TIME -b" NETSTAT="/usr/ucb/netstat -in" VMSTAT="/usr/ucb/vmstat $TIME $REPEATS" HARDWARE="echo HPUX_does_not_have_a_hardware_inventory_command" PS="/bin/ps -elf" case "$VERSION" in A*) NFSSTAT="/usr/etc/nfsstat -c" SAR="echo HPUX_V9_does_not_have_sar" PING="/etc/ping $PINGHOST -n $REPEATS" ;; B*) NFSSTAT="/usr/ucb/nfsstat -c" SAR="/usr/ucb/sar -u $TIME $REPEATS" PING="/usr/sbin/ping $PINGHOST -n $REPEATS" ;; *) OS="UNKNOWN" NFSSTAT="/usr/ucb/nfsstat -c" SAR="/bin/sar -u $TIME $REPEATS" PING="/usr/bin/ping $PINGHOST -n $REPEATS" ;; esac ;; BSD*) OS="BSD" IOSTAT="/usr/sbin/iostat -c $TIME -w $REPEATS" MAIL="/usr/ucb/Mail" NFSSTAT="/usr/bin/nfsstat" PING="/bin/ping -c $REPEATS $PINGHOST" PS="/bin/ps -auwwx" SAR="echo SAR_NOT_SUPPORTED_ON_BSD" TOP="/usr/contrib/bin/top -S -I -d$REPEATS -s$TIME -b" NETSTAT="/usr/sbin/netstat -in" VMSTAT="/usr/sbin/vmstat $TIME $REPEATS" HARDWARE="echo BSD_does_not_have_a_hardware_inventory_command" ;; *) OS="UNKNOWN" echo "WARNING: Unknown OS, please report problem to support@nas.nasa.gov" IOSTAT="sar -d $TIME $INTERVAL" MAIL="mail" NFSSTAT="/usr/etc/nfsstat -c" PING="/usr/etc/ping -c 5 $PINGHOST" PS="/usr/bin/ps auwwwx" TOP="/usr/etc/top -S -I -d$INTERVAL -s$TIME -b" SAR="/bin/sar -u $TIME $INTERVAL" HARDWARE="echo UNKNOWN_HARDWARE" ;; esac # In the following section, we run each diagnostic command. # We put the output into separate files such that, when sorted # alphanumerically, they are in the order we want in the output file # (for example, the two netstat runs are put in slow1.netstat1.$$ # and slow1.netstat2.$$; that way, even though they are run at # vastly different times, in the final output file they are adjacent). echo "Collecting first batch of Netstat Statistics" echo " " > /tmp/slow1.netstat1.$$ echo "NETSTAT 1" >> /tmp/slow1.netstat1.$$ $NETSTAT >> /tmp/slow1.netstat1.$$ 2>&1 echo "Collecting first batch of NFS Statistics" echo " " > /tmp/slow1.nfsstat1.$$ echo "NFSSTAT 1" >> /tmp/slow1.nfsstat1.$$ $NFSSTAT >> /tmp/slow1.nfsstat1.$$ 2>&1 echo "Collecting Process Statistics" echo " " > /tmp/slow9.ps.$$ echo "PS STATISTICS" >> /tmp/slow9.ps.$$ $PS >> /tmp/slow9.ps.$$ 2>&1 echo "Collecting Disk IO Statistics" echo " " > /tmp/slow3.iostat.$$ echo "DISK IO STATISTICS" >> /tmp/slow3.iostat.$$ $IOSTAT >> /tmp/slow3.iostat.$$ 2>&1 echo "Collecting Top CPU Statistics" echo " " > /tmp/slow4.top.$$ echo "TOP CPU STATISTICS" >> /tmp/slow4.top.$$ $TOP >> /tmp/slow4.top.$$ 2>&1 echo "Collecting Uptime Statistics" echo " " > /tmp/slow5.uptime.$$ echo "UPTIME STATISTICS" >> /tmp/slow5.uptime.$$ $UPTIME >> /tmp/slow5.uptime.$$ 2>&1 echo "Collecting vmstat Statistics" echo " " > /tmp/slow6.vmstat.$$ echo "VMSTAT STATISTICS" >> /tmp/slow6.vmstat.$$ $VMSTAT >> /tmp/slow6.vmstat.$$ 2>&1 echo "Collecting SAR CPU Statistics" echo " " > /tmp/slow7.sarcpu.$$ echo "SAR CPU STATISTICS" >> /tmp/slow7.sarcpu.$$ $SAR >> /tmp/slow7.sarcpu.$$ 2>&1 echo "Collecting Network Ping Statistics" echo " " > /tmp/slow8.ping.$$ echo "PING TIMES TO IMPORTANT FILESERVER" >> /tmp/slow8.ping.$$ $PING >> /tmp/slow8.ping.$$ 2>&1 echo "Collecting Hardware Inventory" echo " " > /tmp/slow9.hardware.$$ echo "HARDWARE INVENTORY" >> /tmp/slow9.hardware.$$ $HARDWARE >> /tmp/slow9.hardware.$$ 2>&1 echo "Collecting second batch of Netstat Statistics" echo " " > /tmp/slow1.netstat2.$$ echo "NETSTAT 2" >> /tmp/slow1.netstat2.$$ $NETSTAT >> /tmp/slow1.netstat2.$$ 2>&1 echo "Collecting second batch of NFS Statistics" echo " " > /tmp/slow1.nfsstat2.$$ echo "NFSSTAT 2" >> /tmp/slow1.nfsstat2.$$ $NFSSTAT >> /tmp/slow1.nfsstat2.$$ 2>&1 #Time to concatenate all the output files into alphanumeric order sleep 1 cat /tmp/slow*.$$ > /tmp/slo.output.$$ #if we are not testing, send email to performance if [ "$TEST" = "0" ] then $MAIL -s slow_report_from_$HOSTNAME $MAIL_LIST < /tmp/slo.output.$$ fi # We always send email to the person running the program $MAIL -s slow_report_from_$HOSTNAME $USERNAME < /tmp/slo.output.$$ sleep 1 #Clean up our temporary files rm /tmp/slow*.$$ rm /tmp/slo.output.$$ # #It is very important to set customer expectation levels correctly #so you don't unintentionally commit your staff to an unrealistic #level of support. echo " " echo "your slow report has been sent" echo " " echo "This slow report provides data to the workstation team on the" echo "number and magnitude of performance problems." echo "It also provides diagnostic information for debugging performance problems" echo "The workstation team will probably _not_ respond individually to this" echo "performance problem, unless you specifically request it by opening" echo "a problem report via email or by calling the helpdesk" echo " " echo "Thank you for your performance feedback - the Workstation Team"