robbiew | 1294778 | 2003-02-12 17:02:45 +0000 | [diff] [blame] | 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 implied 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | # |
| 19 | # FILE : ltpstress.sh |
| 20 | # DESCRIPTION : A script that will stress your system using the LTP testsuite. |
| 21 | # REQUIREMENTS: |
| 22 | # 1) The 'rsh' daemon must be running and NFS (versions 2 &3) must be |
| 23 | # configured into the kernel and installed. |
| 24 | # 2) The 'sar' application must be installed to use the "-S" option |
| 25 | # HISTORY : |
| 26 | # 02/11/2003 Robbie Williamson (robbiew@austin.ibm.com) |
| 27 | # written |
| 28 | #################################################### |
| 29 | |
| 30 | export LTPROOT=${PWD} |
| 31 | export TMPBASE="/tmp" |
| 32 | export TMP="${TMPBASE}/ltpstress-$$" |
| 33 | export PATH=$PATH:$LTPROOT/testcases/bin |
| 34 | memsize=0 |
| 35 | duration=86400 |
| 36 | datafile="/tmp/ltpstress.data" |
| 37 | interval=10 |
| 38 | Sar=0 |
| 39 | |
| 40 | usage() |
| 41 | { |
| 42 | |
| 43 | cat <<-END >&2 |
| 44 | usage: ${0##*/} [ -d datafile ] [ -i # (in seconds) ] [ -l logfile ] [ -m # (in Mb) ] [ -t duration ] [-S] |
| 45 | |
| 46 | -d datafile Data file for 'sar' to log to. Default is "/tmp/ltpstress.data". |
| 47 | -i # (in sec) Interval that 'sar' should take snapshots. Default is 10 seconds. |
| 48 | -l logfile Log results of test in a logfile. |
| 49 | -m # (in Mb) Specify the _minimum_ memory load of # megabytes in background. Default is 64Mb. |
| 50 | -S Use 'sar' to measure data. |
| 51 | -t duration Execute the testsuite for given duration in hours. Default is 24. |
| 52 | |
| 53 | example: ${0##*/} -d /tmp/topdata -l /tmp/ltplog.$$ -m 128 -t 24 -S |
| 54 | END |
| 55 | exit |
| 56 | } |
| 57 | |
| 58 | mkdir -p ${TMP} |
| 59 | |
| 60 | cd ${TMP} |
| 61 | if [ $? -ne 0 ]; then |
| 62 | echo "could not cd ${TMP} ... exiting" |
| 63 | exit |
| 64 | fi |
| 65 | |
| 66 | while getopts d:hi:l:St:m:\? arg |
| 67 | do case $arg in |
| 68 | |
| 69 | d) datafile="$OPTARG";; |
| 70 | |
| 71 | h) echo "Help info:" |
| 72 | usage;; |
| 73 | |
| 74 | i) interval=$OPTARG;; |
| 75 | |
| 76 | l) logfile="-l $OPTARG";; |
| 77 | |
| 78 | m) memsize=$(($OPTARG * 1024 * 1024));; |
| 79 | |
| 80 | S) Sar=1;; |
| 81 | |
| 82 | t) hours=$OPTARG |
| 83 | duration=$(($hours * 60 * 60));; |
| 84 | |
| 85 | \?) echo "Help info:" |
| 86 | usage;; |
| 87 | esac |
| 88 | done |
| 89 | |
| 90 | # Networking setup |
| 91 | echo `hostname` >> /root/.rhosts |
| 92 | chmod 644 /root/.rhosts |
| 93 | |
| 94 | netstat -an | grep 514 |
| 95 | if [ $? -eq 1 ];then |
| 96 | echo "Error: 'rsh' deamon not active on this machine." |
| 97 | exit 1 |
| 98 | fi |
| 99 | |
| 100 | ps -ef | grep portmap | grep -v grep |
| 101 | if [ $? -eq 1 ];then |
| 102 | /sbin/portmap & |
| 103 | fi |
| 104 | sleep 1 |
| 105 | ps -ef | grep portmap | grep -v grep |
| 106 | if [ $? -eq 1 ];then |
| 107 | echo "Error: Could not start portmap daemon." |
| 108 | exit 1 |
| 109 | fi |
| 110 | |
| 111 | rpcinfo -p | grep status |
| 112 | if [ $? -eq 1 ];then |
| 113 | /sbin/rpc.statd |
| 114 | fi |
| 115 | sleep 1 |
| 116 | rpcinfo -p | grep status |
| 117 | if [ $? -eq 1 ];then |
| 118 | echo "Error: Could not start statd daemon." |
| 119 | exit 1 |
| 120 | fi |
| 121 | |
| 122 | rpcinfo -p | grep nfs |
| 123 | if [ $? -eq 1 ];then |
| 124 | /usr/sbin/rpc.nfsd |
| 125 | fi |
| 126 | sleep 1 |
| 127 | rpcinfo -p | grep nfs |
| 128 | if [ $? -eq 1 ];then |
| 129 | echo "Error: Could not start nfs server daemon." |
| 130 | exit 1 |
| 131 | fi |
| 132 | |
| 133 | rpcinfo -p | grep mount |
| 134 | if [ $? -eq 1 ];then |
| 135 | /usr/sbin/rpc.mountd |
| 136 | fi |
| 137 | sleep 1 |
| 138 | rpcinfo -p | grep mount |
| 139 | if [ $? -eq 1 ];then |
| 140 | echo "Error: Could not start mountd daemon." |
| 141 | exit 1 |
| 142 | fi |
| 143 | # End of network setup |
| 144 | |
| 145 | |
| 146 | |
| 147 | if [ $memsize -eq 0 ]; then |
| 148 | memsize=$((64 * 1024 * 1024)) |
| 149 | fi |
| 150 | |
| 151 | genload --vm 0 --vm-bytes $memsize 2>&1 1>/dev/null & |
| 152 | |
| 153 | netpipe.sh >/dev/null 2>/dev/null & |
| 154 | |
| 155 | ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part1 > ${TMP}/stress.part1 |
| 156 | ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part2 > ${TMP}/stress.part2 |
| 157 | ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part3 > ${TMP}/stress.part3 |
| 158 | ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part4 > ${TMP}/stress.part4 |
| 159 | |
| 160 | sleep 2 |
| 161 | |
| 162 | if [ $Sar -eq 1 ]; then |
| 163 | sar -o $datafile $interval 0 & |
| 164 | fi |
| 165 | |
| 166 | sleep 2 |
| 167 | |
| 168 | ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress1 -n stress1 $logfile -f ${TMP}/stress.part1 >/dev/null 2>&1 & |
| 169 | ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress2 -n stress2 $logfile -f ${TMP}/stress.part2 >/dev/null 2>&1 & |
| 170 | ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress3 -n stress3 $logfile -f ${TMP}/stress.part3 >/dev/null 2>&1 & |
| 171 | ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress4 -n stress4 $logfile -f ${TMP}/stress.part4 >/dev/null 2>&1 & |
| 172 | |
| 173 | echo "Running LTP Stress for $hours hour(s)" |
| 174 | |
| 175 | # Sleep a little longer than duration to let pan "try" to gracefully end itself. |
| 176 | sleep $(($duration + 10)) |
| 177 | |
| 178 | if [ $Sar -eq 1 ]; then |
| 179 | killall -9 sadc >/dev/null 2>&1 |
| 180 | fi |
| 181 | killall -9 pan >/dev/null 2>&1 |
| 182 | killall -9 genload >/dev/null 2>&1 |
| 183 | killall -9 netpipe.sh >/dev/null 2>&1 |
| 184 | killall -9 NPtcp >/dev/null 2>&1 |
| 185 | |
| 186 | rm -rf ${TMP} |
| 187 | echo "Testing done" |
| 188 | |