#!/bin/bash ((verbose = 0)) ((iterations = 10)) ((delay = 1)) progress='' tmpDir='/tmp/io-use' server[1]='MDS' server[2]='OSS' while [[ "X" != "X$1" ]] do if [[ "-v" == "$1" ]] then ((verbose = 1)) progress='.' elif [[ "-i" == "$1" ]] then shift x="$1" ((iterations = x)) elif [[ "-d" == "$1" ]] then shift x="$1" ((delay = x)) else echo "Usage: $0 [-v] [-c #]" echo " -v is verbose" echo " -i # performs # iterations (default is 10)" echo " -d # delays # time between iterations (default is 1 second)" exit fi shift done if ((1 == verbose)) then echo "Options:" echo " Provide verbose feedback" echo " ${iterations} iterations to be performed" echo " ${delay} second(s) between each iteration" echo " " fi COMMANDS=() # if we have an MDT mount kind=$(mount | grep -i 'mdt') if [[ 'X' != "X${kind}" ]] then char[1]='m' procFile='/proc/fs/lustre/mds/MDS/mdt/req_history' if [[ -f ${procFile} ]] then COMMANDS[1]="cat ${procFile}" else COMMANDS[1]="lctl get_param mds.MDS.mdt.req_history" fi fi # if we have an OST mount kind=$(mount | grep -i 'ost') if [[ 'X' != "X${kind}" ]] then char[2]='o' procFile='/proc/fs/lustre/ost/OSS/ost_io/req_history' if [[ -f ${procFile} ]] then COMMANDS[2]="cat ${procFile}" else COMMANDS[2]="lctl get_param ost.OSS.ost_io.req_history" fi fi # set count to parameter 1 if passed if [[ "X" == "X$1" ]] then ((count = 10)) else count="$1" fi # big command loop for idx in "${!COMMANDS[@]}" do # get rid of existing DIR and its contents if [[ -d ${tmpDir} ]] then rm -rf ${tmpDir} fi mkdir ${tmpDir} cd ${tmpDir} # touch an empty file so that if no I/O is going on, we do not get a grep error touch dummy if ((1 == verbose)) then echo "using: ${COMMANDS[${idx}]}" fi ((count = iterations)) while ((0 < count)) do ${COMMANDS[${idx}]} | grep -v req_history | grep -v Complete | awk -F':' '{print $3}' | sed 's/12345-//' | awk -F'@' '{print $1}' | while read num do name=$(grep ${num} /etc/hosts | head -1 | awk '{print $2}') if [[ 'X' == "X${name}" ]] then name="${num}" fi echo -n ${char[${idx}]} >> ${name} done ((count = count - 1)) echo -n ${progress} sleep ${delay} done if ((1 == verbose)) then echo " " fi idle=$(ls -1 | wc -l) if ((1 == idle)) then echo "${server[${idx}]} idle" else grep -H ${char[${idx}]} * fi cd - >/dev/null rm -rf ${tmpDir} done