Skip to content

Commit

Permalink
Merge pull request #40 from uProxy/trevj-zork-stats
Browse files Browse the repository at this point in the history
add a script to pull interesting stats from a zork log
  • Loading branch information
trevj committed Jan 19, 2016
2 parents 6e69e01 + 3faa4ac commit add28e9
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions testing/run-scripts/zork-stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Outputs some interesting stats from a zork log.

# TODO: this is preposterously slow
# TODO: mean negotiation time
# TODO: mean connection length

set -e

function usage () {
echo "$0 [-h] logfile"
exit 1
}

while getopts h? opt; do
case $opt in
*) usage ;;
esac
done
shift $((OPTIND-1))

if [ $# -lt 1 ]
then
usage
fi

# Split on newlines, for easy looping through log lines.
IFS="
"
num_sessions=0
num_successes=0
for opening in `grep ^zork $1|grep 'new client from'`
do
num_sessions=$((num_sessions+1))
# ID includes a trailing :.
session_id=`echo $opening|cut -d" " -f 4`
echo -n "$session_id "
if grep -q -i -m 1 "^zork.*$session_id.*rtctonet connected" $1; then
echo "SUCCESS"
num_successes=$((num_successes+1))
elif grep -q -i -m 1 "^zork.*$session_id.*failed to start rtctonet" $1; then
echo "FAILED"
echo "***"
grep $session_id $1
echo "***"
else
echo "unknown"
fi
done
percent_successes=`echo "scale=2;(($num_successes/$num_sessions)*100)"|bc`
echo "$num_sessions proxying sessions, $num_successes succeeded ($percent_successes%)"

0 comments on commit add28e9

Please sign in to comment.