| #!/bin/sh |
| |
| # Copyright (c) International Business Machines Corp., 2003 |
| # |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| # the GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program; if not, write to the Free Software |
| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| # |
| # FILE : ltpstress.sh |
| # DESCRIPTION : A script that will stress your system using the LTP testsuite. |
| # REQUIREMENTS: |
| # 1) The 'rsh' daemon must be running and NFS (versions 2 &3) must be |
| # configured into the kernel and installed. |
| # 2) The 'sar' application must be installed to use the "-S" option |
| # HISTORY : |
| # 02/11/2003 Robbie Williamson (robbiew@austin.ibm.com) |
| # written |
| #################################################### |
| |
| export LTPROOT=${PWD} |
| export TMPBASE="/tmp" |
| export TMP="${TMPBASE}/ltpstress-$$" |
| export PATH=$PATH:$LTPROOT/testcases/bin |
| memsize=0 |
| duration=86400 |
| datafile="/tmp/ltpstress.data" |
| interval=10 |
| Sar=0 |
| |
| usage() |
| { |
| |
| cat <<-END >&2 |
| usage: ${0##*/} [ -d datafile ] [ -i # (in seconds) ] [ -l logfile ] [ -m # (in Mb) ] [ -t duration ] [-S] |
| |
| -d datafile Data file for 'sar' to log to. Default is "/tmp/ltpstress.data". |
| -i # (in sec) Interval that 'sar' should take snapshots. Default is 10 seconds. |
| -l logfile Log results of test in a logfile. |
| -m # (in Mb) Specify the _minimum_ memory load of # megabytes in background. Default is 64Mb. |
| -S Use 'sar' to measure data. |
| -t duration Execute the testsuite for given duration in hours. Default is 24. |
| |
| example: ${0##*/} -d /tmp/topdata -l /tmp/ltplog.$$ -m 128 -t 24 -S |
| END |
| exit |
| } |
| |
| mkdir -p ${TMP} |
| |
| cd ${TMP} |
| if [ $? -ne 0 ]; then |
| echo "could not cd ${TMP} ... exiting" |
| exit |
| fi |
| |
| while getopts d:hi:l:St:m:\? arg |
| do case $arg in |
| |
| d) datafile="$OPTARG";; |
| |
| h) echo "Help info:" |
| usage;; |
| |
| i) interval=$OPTARG;; |
| |
| l) logfile="-l $OPTARG";; |
| |
| m) memsize=$(($OPTARG * 1024 * 1024));; |
| |
| S) Sar=1;; |
| |
| t) hours=$OPTARG |
| duration=$(($hours * 60 * 60));; |
| |
| \?) echo "Help info:" |
| usage;; |
| esac |
| done |
| |
| # Networking setup |
| echo `hostname` >> /root/.rhosts |
| chmod 644 /root/.rhosts |
| |
| netstat -an | grep 514 |
| if [ $? -eq 1 ];then |
| echo "Error: 'rsh' deamon not active on this machine." |
| exit 1 |
| fi |
| |
| ps -ef | grep portmap | grep -v grep |
| if [ $? -eq 1 ];then |
| /sbin/portmap & |
| fi |
| sleep 1 |
| ps -ef | grep portmap | grep -v grep |
| if [ $? -eq 1 ];then |
| echo "Error: Could not start portmap daemon." |
| exit 1 |
| fi |
| |
| rpcinfo -p | grep status |
| if [ $? -eq 1 ];then |
| /sbin/rpc.statd |
| fi |
| sleep 1 |
| rpcinfo -p | grep status |
| if [ $? -eq 1 ];then |
| echo "Error: Could not start statd daemon." |
| exit 1 |
| fi |
| |
| rpcinfo -p | grep nfs |
| if [ $? -eq 1 ];then |
| /usr/sbin/rpc.nfsd |
| fi |
| sleep 1 |
| rpcinfo -p | grep nfs |
| if [ $? -eq 1 ];then |
| echo "Error: Could not start nfs server daemon." |
| exit 1 |
| fi |
| |
| rpcinfo -p | grep mount |
| if [ $? -eq 1 ];then |
| /usr/sbin/rpc.mountd |
| fi |
| sleep 1 |
| rpcinfo -p | grep mount |
| if [ $? -eq 1 ];then |
| echo "Error: Could not start mountd daemon." |
| exit 1 |
| fi |
| # End of network setup |
| |
| |
| |
| if [ $memsize -eq 0 ]; then |
| memsize=$((64 * 1024 * 1024)) |
| fi |
| |
| genload --vm 0 --vm-bytes $memsize 2>&1 1>/dev/null & |
| |
| netpipe.sh >/dev/null 2>/dev/null & |
| |
| ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part1 > ${TMP}/stress.part1 |
| ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part2 > ${TMP}/stress.part2 |
| ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part3 > ${TMP}/stress.part3 |
| ${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/stress.part4 > ${TMP}/stress.part4 |
| |
| sleep 2 |
| |
| if [ $Sar -eq 1 ]; then |
| sar -o $datafile $interval 0 & |
| fi |
| |
| sleep 2 |
| |
| ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress1 -n stress1 $logfile -f ${TMP}/stress.part1 >/dev/null 2>&1 & |
| ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress2 -n stress2 $logfile -f ${TMP}/stress.part2 >/dev/null 2>&1 & |
| ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress3 -n stress3 $logfile -f ${TMP}/stress.part3 >/dev/null 2>&1 & |
| ${LTPROOT}/pan/pan -e -p -q -S -t ${hours}h -a stress4 -n stress4 $logfile -f ${TMP}/stress.part4 >/dev/null 2>&1 & |
| |
| echo "Running LTP Stress for $hours hour(s)" |
| |
| # Sleep a little longer than duration to let pan "try" to gracefully end itself. |
| sleep $(($duration + 10)) |
| |
| if [ $Sar -eq 1 ]; then |
| killall -9 sadc >/dev/null 2>&1 |
| fi |
| killall -9 pan >/dev/null 2>&1 |
| killall -9 genload >/dev/null 2>&1 |
| killall -9 netpipe.sh >/dev/null 2>&1 |
| killall -9 NPtcp >/dev/null 2>&1 |
| |
| rm -rf ${TMP} |
| echo "Testing done" |
| |