VBoxConvertNATStats.sh revision c7814cf6e1240a519cbec0441e033d0e2470ed00
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync# Copyright (C) 2009-2010 Oracle Corporation
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# available from http://www.virtualbox.org. This file is free software;
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# you can redistribute it and/or modify it under the terms of the GNU
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# General Public License (GPL) as published by the Free Software
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
82bcaaf8077ba892f39afb721dca149353c63d2cvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync#change device to select NAT${NAT_STAT_DEVICE} counters
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsyncgrep NAT${NAT_STAT_DEVICE} $NAT_IN_FILE > $NAT_STATS_COUNTERS_RAW
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync[ $? -ne 0 ] && echo "error happens while grep'ing the NAT's counters" && exit 1
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync#sed -ne "s/\ */\t/gp" $NAT_STATS_COUNTERS_RAW > $NAT_STATS_COUNTERS
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "tsv")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync else if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync OFS="</td><td>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync print "<table>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (COUNTERS == "counting")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$1 = "name"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$2 = "count"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync print "<tr><td>" \$0 "</td></tr>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync else if (COUNTERS == "profiling")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$1 = "name"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$2 = "ticks_per_count"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$3 = "total_ticks"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$4 = "times"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$5 = "max"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$6 = "min"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync print "<tr><td>" \$0 "</td></tr>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync/*counting counters */
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsyncNF == 3 && COUNTERS=="counting"{
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync count = \$2
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync print "<tr><td>" \$0 "</td></tr>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync/*profiling counters */
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsyncNF == 12 && COUNTERS=="profiling"{
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync ticks_per_count = \$2
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync total_ticks = \$5
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync times = \$7
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$2 = ticks_per_count
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$3 = total_ticks
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$4 = times
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$5 = substr(max,0, index(max, ",") -1)
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync \$6 = substr(min,0, index(min, ")") - 1)
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync print "<tr><td>" \$0 "</td></tr>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync if (FMT == "wiki")
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsync print "</table>"
d9a56535f83f926b52a6c3bc55da1cb37bf23b96vboxsyncawk -v FMT=$NAT_STATS_FMT -v COUNTERS=profiling -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS > $NAT_STATS_REPORT