######################################## # # Process the output iostat-x for Excel Auto Generator # # Version 2 # # 20-Dec-2012 EOS # Updated the csv file search # ######################################## fName=$1 header="Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util" echo "Check IOStat Monitor Version" numTime=$(more $fName | grep -i "Time" | wc -l) echo "NumTime " $numTime if [[ $numTime > 0 ]]; then echo "Generating Device List" deviceList=$(more $1 | awk '/Device/,/Time:/' | awk '{if($1 != "Device:" && $1 != ""){if(match($1,"/")){split($1,a,"/");print a[2];}else print $1;}}' | sort | uniq | sed 's/://g') for curDevice in $deviceList; do echo "Processing $curDevice" if [[ $curDevice == "Time" ]]; then echo "Time " > X-${curDevice}.csv more $1 | grep $curDevice | awk '{print $2" ";}' >> X-${curDevice}.csv else echo $header'-'$curDevice > X-${curDevice}.csv more $1 | grep $curDevice' ' >> X-${curDevice}.csv fi done else echo "Generating Device List" deviceList=$(more $fName | awk '{if(NF>7&&!match($1,"Device")){print $1;}}' | sort | uniq | sed 's/://g') echo "Extracting Time Stamps" # Create Time.csv echo "Time " > X-Time.csv curYear=$(date +"%Y") more $fName | awk -v currentYear=$curYear '{if(match($1,currentYear)&&(match($3,"AM")||match($3,"PM"))){print $2" ";}}' >> X-Time.csv for curDevice in $deviceList; do echo "Processing $curDevice" echo $header'-'$curDevice > X-${curDevice}.csv more $1 | grep $curDevice' ' >> X-${curDevice}.csv done fi #CommonCode for curDevice in $deviceList; do if [[ $curDevice != "Time" ]]; then paste X-Time.csv X-${curDevice}.csv > X-${curDevice}.csv.tmp mv X-${curDevice}.csv.tmp X-${curDevice}.csv sed -i "1iSPACE TEXT TEXT DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC DEC" X-${curDevice}.csv fi done rm X-Time.csv