1 | #!/bin/sh
|
---|
2 | ## @file
|
---|
3 | # ???
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2017 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 | #change device to select NAT${NAT_STAT_DEVICE} counters
|
---|
19 |
|
---|
20 | NAT_STAT_DEBUG=1
|
---|
21 | NAT_STAT_DEVICE=0
|
---|
22 | NAT_TMP=/tmp
|
---|
23 | NAT_STATS_FMT=wiki
|
---|
24 |
|
---|
25 | NAT_STATS_CONVERTER=$NAT_TMP/converter.awk
|
---|
26 | NAT_STATS_COUNTERS_RAW=${NAT_TMP}/counters.out.raw
|
---|
27 | NAT_STATS_COUNTERS=${NAT_TMP}/counters.out
|
---|
28 | NAT_STATS_REPORT=NAT_STATS_NAME.${NAT_STATS_FMT}
|
---|
29 |
|
---|
30 | NAT_IN_FILE=$1
|
---|
31 |
|
---|
32 | [ x"$TMP" != x ] && NAT_TMP=TMP
|
---|
33 |
|
---|
34 | grep NAT${NAT_STAT_DEVICE} $NAT_IN_FILE > $NAT_STATS_COUNTERS_RAW
|
---|
35 | [ $? -ne 0 ] && echo "error happens while grep'ing the NAT's counters" && exit 1
|
---|
36 |
|
---|
37 | #sed -ne "s/\ */\t/gp" $NAT_STATS_COUNTERS_RAW > $NAT_STATS_COUNTERS
|
---|
38 | cp $NAT_STATS_COUNTERS_RAW $NAT_STATS_COUNTERS
|
---|
39 |
|
---|
40 | cat > $NAT_STATS_CONVERTER <<EOF
|
---|
41 | BEGIN{
|
---|
42 | if (FMT == "tsv")
|
---|
43 | OFS="\t";
|
---|
44 | else if (FMT == "wiki")
|
---|
45 | OFS="</td><td>"
|
---|
46 |
|
---|
47 | FS=" ";
|
---|
48 | if (FMT == "wiki")
|
---|
49 | print "<table>"
|
---|
50 | if (COUNTERS == "counting")
|
---|
51 | {
|
---|
52 | NF = 2;
|
---|
53 | \$1 = "name"
|
---|
54 | \$2 = "count"
|
---|
55 | if (FMT == "wiki")
|
---|
56 | print "<tr><td>" \$0 "</td></tr>"
|
---|
57 | else
|
---|
58 | print \$0
|
---|
59 | }
|
---|
60 | else if (COUNTERS == "profiling")
|
---|
61 | {
|
---|
62 | NF=6
|
---|
63 | \$1 = "name"
|
---|
64 | \$2 = "ticks_per_count"
|
---|
65 | \$3 = "total_ticks"
|
---|
66 | \$4 = "times"
|
---|
67 | \$5 = "max"
|
---|
68 | \$6 = "min"
|
---|
69 | if (FMT == "wiki")
|
---|
70 | print "<tr><td>" \$0 "</td></tr>"
|
---|
71 | else
|
---|
72 | print \$0
|
---|
73 | }
|
---|
74 | }
|
---|
75 | /*counting counters */
|
---|
76 | NF == 3 && COUNTERS=="counting"{
|
---|
77 | name = \$1
|
---|
78 | count = \$2
|
---|
79 | NF=2
|
---|
80 | if (FMT == "wiki")
|
---|
81 | print "<tr><td>" \$0 "</td></tr>"
|
---|
82 | else
|
---|
83 | print \$0
|
---|
84 | }
|
---|
85 | /*profiling counters */
|
---|
86 | NF == 12 && COUNTERS=="profiling"{
|
---|
87 | name = \$1
|
---|
88 | ticks_per_count = \$2
|
---|
89 | total_ticks = \$5
|
---|
90 | times = \$7
|
---|
91 | max = \$10
|
---|
92 | min = \$12
|
---|
93 | NF=6
|
---|
94 | \$1 = name
|
---|
95 | \$2 = ticks_per_count
|
---|
96 | \$3 = total_ticks
|
---|
97 | \$4 = times
|
---|
98 | \$5 = substr(max,0, index(max, ",") -1)
|
---|
99 | \$6 = substr(min,0, index(min, ")") - 1)
|
---|
100 |
|
---|
101 | if (FMT == "wiki")
|
---|
102 | print "<tr><td>" \$0 "</td></tr>"
|
---|
103 | else
|
---|
104 | print \$0
|
---|
105 | }
|
---|
106 | END{
|
---|
107 | if (FMT == "wiki")
|
---|
108 | print "</table>"
|
---|
109 | }
|
---|
110 | EOF
|
---|
111 | awk -v FMT=$NAT_STATS_FMT -v COUNTERS=profiling -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS > $NAT_STATS_REPORT
|
---|
112 | awk -v FMT=$NAT_STATS_FMT -v COUNTERS=counting -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS >> $NAT_STATS_REPORT
|
---|
113 |
|
---|