1 #!/bin/sh 2 # 3 # Copyright (c) International Business Machines Corp., 2003 4 # 5 # This program is free software; you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation; either version 2 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implie; warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13 # the GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 # 19 # 20 # 21 # FILE : nfs_fsstress.sh 22 # 23 # PURPOSE: Runs fsstress over an NFS mount point for a specified amount 24 # of time. The test will also start 'sar' to monitor the system 25 # utilization data. The purpose of this test is to stress the 26 # NFS kernel code and possibly the underlying filesystem where 27 # the export resides. A PASS is if the test completes. 28 # 29 # PREREQUISITE: There must exist an NFS exported filesystem available to 30 # test on. 31 # 32 # 33 # HISTORY: 34 # 11/21/03 Robbie Williamson (robbiew (at] us.ibm.com) 35 # -Written 36 # 37 #*********************************************************************** 38 39 #Uncomment line below for debug output. 40 #trace_logic=${trace_logic:-"set -x"} 41 42 $trace_logic 43 44 echo -n "Please enter the server location of the NFS exported filesystem: " 45 read RHOST 46 echo -n "Please enter the name of the NFS exported filesystem: " 47 read FILESYSTEM 48 echo -n "Please enter the test duration in hours: " 49 read DURATION 50 51 HOSTNAME=$(hostname | awk {'print $1'}) 52 53 #Convert to seconds 54 DURATION=$(( $DURATION * 60 * 60 )) 55 56 echo "Setting up local mount points" 57 mkdir -p /tmp/udp/2/${HOSTNAME}1 58 mkdir -p /tmp/tcp/2/${HOSTNAME}2 59 mkdir -p /tmp/udp/3/${HOSTNAME}3 60 mkdir -p /tmp/tcp/3/${HOSTNAME}4 61 62 echo "Mounting NFS filesystem" 63 mount -o "intr,soft,proto=udp,vers=2" $RHOST:$FILESYSTEM /tmp/udp/2/${HOSTNAME}1 >/dev/null 2>&1 64 if [ $? -ne 0 ];then 65 echo "Error: mount using UDP & version 2 failed" 66 exit 1 67 fi 68 mount -o "intr,soft,proto=tcp,vers=2" $RHOST:$FILESYSTEM /tmp/tcp/2/${HOSTNAME}2 >/dev/null 2>&1 69 if [ $? -ne 0 ];then 70 echo "Error: mount using TCP & version 2 failed" 71 exit 1 72 fi 73 mount -o "intr,soft,proto=udp,vers=3" $RHOST:$FILESYSTEM /tmp/udp/3/${HOSTNAME}3 >/dev/null 2>&1 74 if [ $? -ne 0 ];then 75 echo "Error: mount using UDP & version 3 failed" 76 exit 1 77 fi 78 mount -o "intr,soft,proto=tcp,vers=3" $RHOST:$FILESYSTEM /tmp/tcp/3/${HOSTNAME}4 >/dev/null 2>&1 79 if [ $? -ne 0 ];then 80 echo "Error: mount using TCP & version 3 failed" 81 exit 1 82 fi 83 84 echo "Test set for $DURATION seconds. Starting test processes now." 85 ./fsstress -l 0 -d /tmp/udp/2/${HOSTNAME}1 -n 1000 -p 50 -r > /tmp/nfs_fsstress.udp.2.log 2>&1 & 86 ./fsstress -l 0 -d /tmp/udp/3/${HOSTNAME}2 -n 1000 -p 50 -r > /tmp/nfs_fsstress.udp.3.log 2>&1 & 87 ./fsstress -l 0 -d /tmp/tcp/2/${HOSTNAME}3 -n 1000 -p 50 -r > /tmp/nfs_fsstress.tcp.2.log 2>&1 & 88 ./fsstress -l 0 -d /tmp/tcp/3/${HOSTNAME}4 -n 1000 -p 50 -r > /tmp/nfs_fsstress.tcp.3.log 2>&1 & 89 90 echo "Starting sar" 91 sar -o /tmp/nfs_fsstress.sardata 30 0 & 92 93 echo "Testing in progress" 94 sleep $DURATION 95 echo "Testing done. Killing processes." 96 killall -9 sadc 97 killall -9 fsstress 98 ps -ef | grep -v grep | grep fsstress > /dev/null 2>&1 99 TESTING=$? 100 while [ $TESTING -eq 0 ] 101 do 102 killall -9 fsstress 103 echo -n "." 104 sleep 5 105 ps -ef | grep -v grep | grep -v nfs_fsstress | grep fsstress > /dev/null 2>&1 106 TESTING=$? 107 done 108 echo " " 109 echo "All processes killed." 110 echo "Unmounting NFS filesystem" 111 umount /tmp/udp/2/${HOSTNAME}1 112 umount /tmp/tcp/2/${HOSTNAME}2 113 umount /tmp/udp/3/${HOSTNAME}3 114 umount /tmp/tcp/3/${HOSTNAME}4 115 echo " Testing Complete: PASS" 116 117 118