Skip to content

Instantly share code, notes, and snippets.

@ffeldhaus
Created December 3, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffeldhaus/4197449 to your computer and use it in GitHub Desktop.
Save ffeldhaus/4197449 to your computer and use it in GitHub Desktop.
Script for measuring the duration of nova get-vnc-console
#!/bin/bash
# first parameter is the ID of a nova instance
# second parameter may be the amount of runs
count=${2:-100}
timefile=/tmp/vnctime.out
fmt="%e"
# mv out file to old
mv $timefile $timefile.old
for i in `seq 1 $count`; do
/usr/bin/time -f "$fmt" -o $timefile -a nova get-vnc-console $1 novnc > /dev/null
sleep 1
done
min=`awk 'min=="" || $1 < min {min=$1} END{ print min}' /tmp/vnctime.out`
max=`awk 'max=="" || $1 > max {max=$1} END{ print max}' /tmp/vnctime.out`
sum=`awk '{ sum+=$1 } END {print sum}' /tmp/vnctime.out`
average=$(bc <<<"scale=2;$sum/$count")
echo "Minimum duration: $min seconds"
echo "Maximum duration: $max seconds"
echo "Total duration: $sum seconds"
printf "Average duration: %0g seconds\n" $average
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment