Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esxitopdirectory="$(ls)"
- outputcsv="output_foo.csv"
- if [ ! -f "output_foo.csv" ]
- then
- echo "vcpuname, %ready result, status" > "${outputcsv}"
- else
- echo "{outputcsv} already exists"
- fi
- for FILE in "${esxitopdirectory}"
- do
- collistcount=$(head -1 $FILE | tr ',' '\n' | nl | sed -e 's/^[[:space:]]*//' | sed -r 's/\s/,/' | grep "Ready" | grep "vcpu" | wc -l)
- if [ "$collistcount" != "0" ]
- then
- collist=$(head -1 $FILE | tr ',' '\n' | nl | sed -e 's/^[[:space:]]*//' | sed -r 's/\s+/,/' | grep "Ready" | grep "vcpu")
- colnumber=$(echo -en "$collist" | awk -F "," '{print $1}')
- #echo "${collist}"
- #echo "${colnumber}"
- echo "==========================================="
- while IFS= read -r line
- do
- echo ""
- line=$(( $line - 1 ))
- # line -1, havent' checked why colnumber might be one off
- echo "Line: $line"
- vcpuname=$(cat $FILE | awk -F "," -v var=$line 'BEGIN{ans=var} {print $ans}' | head -1)
- echo "${vcpuname}"
- echo "==========================================="
- readyresult=$(cat $FILE | awk -F "," -v var=$line 'BEGIN{ans=var} {print $ans}' | tail -n +2 | tr -d '"'| sort -r | head -1)
- readyresultin=$(echo "${readyresult}" | tr -dc '0-9')
- #echo $readyresult
- #echo $readyresultin
- if [ "${readyresultin}" -ge "499" ];then
- echo "$readyresult FAIL"
- echo "${vcpuname},${readyresult},FAIL" >> "${outputcsv}"
- else
- echo "${readyresult} PASS"
- echo "${vcpuname},${readyresult},PASS" >> "${outputcsv}"
- fi
- echo "==========================================="
- done <<<"${colnumber}"
- else
- echo "skipping $FILE no virtual machines found"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement