VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/scripts/VBoxConvertNATStats.sh@ 27870

Last change on this file since 27870 was 27870, checked in by vboxsync, 15 years ago

OSE fixes for NAT

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2009 Sun Microsystems, Inc.
4#
5# Sun Microsystems, Inc. confidential
6# All rights reserved
7#
8
9#change device to select NAT${NAT_STAT_DEVICE} counters
10
11NAT_STAT_DEBUG=1
12NAT_STAT_DEVICE=0
13NAT_TMP=/tmp
14NAT_STATS_FMT=wiki
15
16NAT_STATS_CONVERTER=$NAT_TMP/converter.awk
17NAT_STATS_COUNTERS_RAW=${NAT_TMP}/counters.out.raw
18NAT_STATS_COUNTERS=${NAT_TMP}/counters.out
19NAT_STATS_REPORT=NAT_STATS_NAME.${NAT_STATS_FMT}
20
21NAT_IN_FILE=$1
22
23[ x"$TMP" != x ] && NAT_TMP=TMP
24
25grep NAT${NAT_STAT_DEVICE} $NAT_IN_FILE > $NAT_STATS_COUNTERS_RAW
26[ $? -ne 0 ] && echo "error happens while grep'ing the NAT's counters" && exit 1
27
28#sed -ne "s/\ */\t/gp" $NAT_STATS_COUNTERS_RAW > $NAT_STATS_COUNTERS
29cp $NAT_STATS_COUNTERS_RAW $NAT_STATS_COUNTERS
30
31cat > $NAT_STATS_CONVERTER <<EOF
32BEGIN{
33 if (FMT == "tsv")
34 OFS="\t";
35 else if (FMT == "wiki")
36 OFS="</td><td>"
37
38 FS=" ";
39 if (FMT == "wiki")
40 print "<table>"
41 if (COUNTERS == "counting")
42 {
43 NF = 2;
44 \$1 = "name"
45 \$2 = "count"
46 if (FMT == "wiki")
47 print "<tr><td>" \$0 "</td></tr>"
48 else
49 print \$0
50 }
51 else if (COUNTERS == "profiling")
52 {
53 NF=6
54 \$1 = "name"
55 \$2 = "ticks_per_count"
56 \$3 = "total_ticks"
57 \$4 = "times"
58 \$5 = "max"
59 \$6 = "min"
60 if (FMT == "wiki")
61 print "<tr><td>" \$0 "</td></tr>"
62 else
63 print \$0
64 }
65}
66/*counting counters */
67NF == 3 && COUNTERS=="counting"{
68 name = \$1
69 count = \$2
70 NF=2
71 if (FMT == "wiki")
72 print "<tr><td>" \$0 "</td></tr>"
73 else
74 print \$0
75}
76/*profiling counters */
77NF == 12 && COUNTERS=="profiling"{
78 name = \$1
79 ticks_per_count = \$2
80 total_ticks = \$5
81 times = \$7
82 max = \$10
83 min = \$12
84 NF=6
85 \$1 = name
86 \$2 = ticks_per_count
87 \$3 = total_ticks
88 \$4 = times
89 \$5 = substr(max,0, index(max, ",") -1)
90 \$6 = substr(min,0, index(min, ")") - 1)
91
92 if (FMT == "wiki")
93 print "<tr><td>" \$0 "</td></tr>"
94 else
95 print \$0
96}
97END{
98 if (FMT == "wiki")
99 print "</table>"
100}
101EOF
102awk -v FMT=$NAT_STATS_FMT -v COUNTERS=profiling -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS > $NAT_STATS_REPORT
103awk -v FMT=$NAT_STATS_FMT -v COUNTERS=counting -f $NAT_STATS_CONVERTER $NAT_STATS_COUNTERS >> $NAT_STATS_REPORT
104
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette