1 #!/bin/bash 2 3 # Runs the bonnie++ test on filesystems... 4 5 # Copyright (C) 2003-2006 IBM 6 # 7 # This program is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU General Public License as 9 # published by the Free Software Foundation; either version 2 of the 10 # License, or (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, but 13 # WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 # General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 # 02111-1307, USA. 21 22 TEST_PID=$$ 23 24 # Try to find bonnie++ on the system 25 BONNIE=`which bonnie++ 2> /dev/null` 26 27 if [ -z "$BONNIE" ]; then 28 BONNIE=`ls $POUNDER_OPTDIR/bonnie++*/bonnie++` 29 if [ -z "$BONNIE" ]; then 30 echo "Cannot find bonnie++; did you run Install?" 31 exit -1 32 fi 33 fi 34 35 # Note old errors 36 LOGFILE=/proc/$$/fd/1 37 OLD_ERRORS=`egrep -ic "(err|fail|invalid|cannot|denied)" $LOGFILE` 38 39 # Now figure out where we have mounted filesystems 40 MOUNTS=`egrep "(ext|reiser)" /proc/mounts | awk -F " " '{print $2}'` 41 42 rm -rf $POUNDER_TMPDIR/bonnie-script-$TEST_PID 43 echo '#/bin/bash' > $POUNDER_TMPDIR/bonnie-script-$TEST_PID 44 echo >> $POUNDER_TMPDIR/bonnie-script-$TEST_PID 45 46 echo $MOUNTS | sed -e 's/ /\n/g' | while read f; do 47 # Clean out space for bonnie 48 rm -rf "$f/bonnie/" 49 50 # Set up for bonnie 51 mkdir -p "$f/bonnie/" 52 53 # Engage! 54 echo $BONNIE -u 0 -d \"$f/bonnie/\" \& >> $POUNDER_TMPDIR/bonnie-script-$TEST_PID 55 done 56 57 echo wait >> $POUNDER_TMPDIR/bonnie-script-$TEST_PID 58 59 # Are we actually going to start any bonnie's? 60 if [ `wc -l < $POUNDER_TMPDIR/bonnie-script-$TEST_PID` -lt 4 ]; then 61 echo "Not running bonnie at all. Abort." 62 exit -1 63 fi 64 65 bash $POUNDER_TMPDIR/bonnie-script-$TEST_PID 66 rm -rf $POUNDER_TMPDIR/bonnie-script-$TEST_PID 67 68 # Clean ourselves up 69 echo $MOUNTS | sed -e 's/ /\n/g' | while read f; do 70 # Clean out space for bonnie 71 rm -rf "$f/bonnie/" 72 done 73 74 # Did we find any new errors? 75 NEW_ERRORS=`egrep -ic "(err|fail|invalid|cannot|denied)" $LOGFILE` 76 ERRORS=$(( NEW_ERRORS - OLD_ERRORS )) 77 if [ $ERRORS -eq 255 ]; then 78 ERRORS=254 79 fi 80 81 exit $ERRORS 82