######################################## # # Process the output iostat-p for Excel Auto Generator # # Version 2 # # 20-Dec-2012 - EOS # Update the csv file search ######################################## header="Device: tps Blk_read/s Blk_wrtn/s-" header_two=" Blk_read Blk_wrtn" fName=$1 echo "Check IOStat Monitor Version" numTime=$(more $fName | grep -i "Time" | wc -l) echo "NumTime " $numTime if [[ $numTime > 0 ]]; then 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 " > P-${curDevice}.csv more $1 | grep $curDevice | awk '{print $2" ";}' >> P-${curDevice}.csv else echo $header$curDevice$header_two > P-${curDevice}.csv more $1 | grep $curDevice' ' >> P-${curDevice}.csv fi done else deviceList=$(more $fName | awk '{if(NF==6&&!match($1,"Device")&&!match($1,"\\.")){print $1;}}' | sort | uniq | sed 's/://g') # Create Time.csv echo "Time " > P-Time.csv curYear=$(date +"%Y") more $fName | awk -v currentYear=$curYear '{if(match($1,currentYear)&&(match($3,"AM")||match($3,"PM"))){print $2" ";}}' >> P-Time.csv for curDevice in $deviceList; do echo "Processing $curDevice" echo $header$curDevice$header_two > P-${curDevice}.csv more $1 | grep $curDevice' ' >> P-${curDevice}.csv done fi for curDevice in $deviceList; do if [[ $curDevice != "Time" ]]; then paste P-Time.csv P-${curDevice}.csv > P-${curDevice}.csv.tmp mv P-${curDevice}.csv.tmp P-${curDevice}.csv sed -i "1iSPACE TEXT TEXT DEC DEC DEC DEC DEC" P-${curDevice}.csv fi done rm P-Time.csv