VBoxConvertNATStats.sh revision 82bcaaf8077ba892f39afb721dca149353c63d2c
#
# Copyright (C) 2009 Sun Microsystems, Inc.
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#
#change device to select NAT${NAT_STAT_DEVICE} counters
NAT_IN_FILE=$1
cat > $NAT_STATS_CONVERTER <<EOF
BEGIN{
if (FMT == "tsv")
OFS="\t";
else if (FMT == "wiki")
OFS="</td><td>"
FS=" ";
if (FMT == "wiki")
print "<table>"
if (COUNTERS == "counting")
{
NF = 2;
\$1 = "name"
\$2 = "count"
if (FMT == "wiki")
print "<tr><td>" \$0 "</td></tr>"
else
print \$0
}
else if (COUNTERS == "profiling")
{
NF=6
\$1 = "name"
\$2 = "ticks_per_count"
\$3 = "total_ticks"
\$4 = "times"
\$5 = "max"
\$6 = "min"
if (FMT == "wiki")
print "<tr><td>" \$0 "</td></tr>"
else
print \$0
}
}
/*counting counters */
NF == 3 && COUNTERS=="counting"{
name = \$1
count = \$2
NF=2
if (FMT == "wiki")
print "<tr><td>" \$0 "</td></tr>"
else
print \$0
}
/*profiling counters */
NF == 12 && COUNTERS=="profiling"{
name = \$1
ticks_per_count = \$2
total_ticks = \$5
times = \$7
max = \$10
min = \$12
NF=6
\$1 = name
\$2 = ticks_per_count
\$3 = total_ticks
\$4 = times
\$5 = substr(max,0, index(max, ",") -1)
\$6 = substr(min,0, index(min, ")") - 1)
if (FMT == "wiki")
print "<tr><td>" \$0 "</td></tr>"
else
print \$0
}
END{
if (FMT == "wiki")
print "</table>"
}
EOF
awk -v FMT=$NAT_STATS_FMT -v COUNTERS=profiling -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS > $NAT_STATS_REPORT
awk -v FMT=$NAT_STATS_FMT -v COUNTERS=counting -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS >> $NAT_STATS_REPORT