#!/bin/bash OS=$(uname -o) PID=$$ if [[ ${OS} == "solaris" ]] then IOSTAT='/usr/bin/iostat -xrn' else IOSTAT='/usr/bin/iostat -x' fi TEMPFILE=${BBTMP}/diskstat.tmp.${PID} SHOW_NFS=no # Set this to yes on server side clientlocal.cfg to change it # DISKSTAT:SHOW_NFS=yes DURATION=270 # The duration of the iostat sample # This can be updated in the same way as above # Now we redefine some variables, if they are set in clientlocal LOGFETCH=${BBTMP}/logfetch.$(uname -n).cfg if [ -f ${LOGFETCH} ] then grep "^DISKSTAT:" ${LOGFETCH} | cut -d":" -f2 \ | while read NEW_DEF do ${NEW_DEF} done fi > ${TEMPFILE} # Make sure it's empty TEMPFILERAW="${TEMPFILE}.raw" ${IOSTAT} $DURATION 2 > ${TEMPFILERAW} # And collect some data to work with. # We have to collect 2 sets, because the first set is the average since boot. # Define where the second set of data starts LINE=$(cat ${TEMPFILERAW} | grep -n "^Device:" | tail -1 | cut -d":" -f1) # take the second set, and massage it into usable data TEMPFILEDATA="${TEMPFILE}.data" if [[ ${OS} == "solaris" ]] then cat ${TEMPFILERAW} | awk "NR>${LINE}" \ | sed "s/,/ /g" \ | awk '{ print $NF" "$0 }' \ | awk '{ $NF="";print }' > ${TEMPFILEDATA} else cat ${TEMPFILERAW} | awk "NR>${LINE}" \ | awk '{ print $0" "$1 }' \ | awk '{ $NF="";print }' > ${TEMPFILEDATA} fi rm ${TEMPFILERAW} # Now we format the data and send it off to the server if [[ ${OS} == "solaris" ]] then COLUMNS="reads writes kreads kwrites wait actv svct pw pb" else COLUMNS="rrqm wrqm r w rsec wsec avgrq-sz avgqu-sz await svctm util" fi count=1 for subtest in ${COLUMNS} do ((count=count+1)) echo "" >> ${TEMPFILE} cat ${TEMPFILEDATA} | cut -d" " -f1,${count} \ | while read DEVICE VAL do echo "${DEVICE}" | grep ":/" > /dev/null if [ $? -eq 0 -a "${SHOW_NFS}" = "no" ] then break else DEVICE=$(echo ${DEVICE} | tr : - ) fi echo "${DEVICE}:${VAL}" >> ${TEMPFILE} done echo "" >> ${TEMPFILE} ${BB} ${BBDISP} "data ${MACHINE}.diskstat-${subtest} $(echo; cat ${TEMPFILE} ;echo "" ;echo "ignore this" )" # Without the last echo "ignore this", it seems to not graph the last entry. # Odd really, but that seems to fix it. rm ${TEMPFILE} done rm ${TEMPFILEDATA}