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@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
44echo -n "Please enter the server location of the NFS exported filesystem: "
45read RHOST
46echo -n "Please enter the name of the NFS exported filesystem: "
47read FILESYSTEM
48echo -n "Please enter the test duration in hours: "
49read DURATION
50
51HOSTNAME=$(hostname | awk {'print $1'})
52
53#Convert to seconds
54DURATION=$(( $DURATION * 60 * 60 ))
55
56echo "Setting up local mount points"
57mkdir -p /tmp/udp/2/${HOSTNAME}1
58mkdir -p /tmp/tcp/2/${HOSTNAME}2
59mkdir -p /tmp/udp/3/${HOSTNAME}3
60mkdir -p /tmp/tcp/3/${HOSTNAME}4
61
62echo "Mounting NFS filesystem"
63mount -o "intr,soft,proto=udp,vers=2" $RHOST:$FILESYSTEM /tmp/udp/2/${HOSTNAME}1 >/dev/null 2>&1
64if [ $? -ne 0 ];then
65  echo "Error: mount using UDP & version 2 failed"
66  exit 1
67fi
68mount -o "intr,soft,proto=tcp,vers=2" $RHOST:$FILESYSTEM /tmp/tcp/2/${HOSTNAME}2 >/dev/null 2>&1
69if [ $? -ne 0 ];then
70  echo "Error: mount using TCP & version 2 failed"
71  exit 1
72fi
73mount -o "intr,soft,proto=udp,vers=3" $RHOST:$FILESYSTEM /tmp/udp/3/${HOSTNAME}3 >/dev/null 2>&1
74if [ $? -ne 0 ];then
75  echo "Error: mount using UDP & version 3 failed"
76  exit 1
77fi
78mount -o "intr,soft,proto=tcp,vers=3" $RHOST:$FILESYSTEM /tmp/tcp/3/${HOSTNAME}4 >/dev/null 2>&1
79if [ $? -ne 0 ];then
80  echo "Error: mount using TCP & version 3 failed"
81  exit 1
82fi
83
84echo "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
90echo "Starting sar"
91sar -o /tmp/nfs_fsstress.sardata 30 0 &
92
93echo "Testing in progress"
94sleep $DURATION
95echo "Testing done. Killing processes."
96killall -9 sadc
97killall -9 fsstress
98ps -ef | grep -v grep | grep fsstress > /dev/null 2>&1
99TESTING=$?
100while [ $TESTING -eq 0 ]
101do
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=$?
107done
108echo " "
109echo "All processes killed."
110echo "Unmounting NFS filesystem"
111umount /tmp/udp/2/${HOSTNAME}1
112umount /tmp/tcp/2/${HOSTNAME}2
113umount /tmp/udp/3/${HOSTNAME}3
114umount /tmp/tcp/3/${HOSTNAME}4
115echo " Testing Complete: PASS"
116
117
118