Skip to content

Commit 14b4c57

Browse files
Mark Hamiltonshettyg
authored andcommitted
utilities: a top like tool for ovs-dpctl dump-flows.
This python script summarizes ovs-dpctl dump-flows content by aggregating the number of packets, total bytes and occurrence of the following fields: - Datapath in_port - Ethernet type - Source and destination MAC addresses - IP protocol - Source and destination IPv4 addresses - Source and destination IPv6 addresses - UDP and TCP destination port - Tunnel source and destination addresses Testing included confirming both mega-flows and non-megaflows are properly parsed. Bit masks are applied in the case of mega-flows prior to aggregation. Test --script parameter which runs in non-interactive mode. Tested syntax against python 2.4.3, 2.6 and 2.7. Confirmed script passes pep8 and pylint run as: pylint --disable=I0011 --include-id=y --reports=n This tool has been added to these distribution: - add ovs-dpctl-top to debian distribution - add ovs-dpctl-top to rpm distribution. - add ovs-dpctl-top to XenServer RPM. Signed-off-by: Mark Hamilton <mhamilton@nicira.com> Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
1 parent 1394054 commit 14b4c57

9 files changed

Lines changed: 1844 additions & 1 deletion

File tree

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Description: Open vSwitch common components
6666
Package: openvswitch-switch
6767
Architecture: linux-any
6868
Suggests: openvswitch-datapath-module
69-
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, openvswitch-common (= ${binary:Version}), module-init-tools, procps, uuid-runtime, netbase
69+
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, openvswitch-common (= ${binary:Version}), module-init-tools, procps, uuid-runtime, netbase, python-argparse
7070
Description: Open vSwitch switch implementations
7171
Open vSwitch is a production quality, multilayer, software-based,
7272
Ethernet virtual switch. It is designed to enable massive network

debian/openvswitch-switch.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
usr/bin/ovs-dpctl
2+
usr/bin/ovs-dpctl-top
23
usr/bin/ovs-pcap
34
usr/bin/ovs-tcpundump
45
usr/bin/ovs-vlan-test

debian/openvswitch-switch.manpages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
_debian/ovsdb/ovsdb-server.1
22
_debian/utilities/ovs-dpctl.8
3+
_debian/utilities/ovs-dpctl-top.8
34
_debian/utilities/ovs-pcap.1
45
_debian/utilities/ovs-tcpundump.1
56
_debian/utilities/ovs-vlan-test.8

manpages.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ utilities/ovs-dpctl.8.in:
124124
lib/common.man:
125125
lib/vlog.man:
126126

127+
utilities/ovs-dpctl-top.8: \
128+
utilities/ovs-dpctl-top.8.in
129+
utilities/ovs-dpctl-top.8.in:
130+
127131
utilities/ovs-l3ping.8: \
128132
utilities/ovs-l3ping.8.in \
129133
lib/common-syn.man \

rhel/openvswitch.spec.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ exit 0
114114
/usr/bin/ovs-appctl
115115
/usr/bin/ovs-benchmark
116116
/usr/bin/ovs-dpctl
117+
/usr/bin/ovs-dpctl-top
117118
/usr/bin/ovs-ofctl
118119
/usr/bin/ovs-parse-backtrace
119120
/usr/bin/ovs-pcap
@@ -137,6 +138,7 @@ exit 0
137138
/usr/share/man/man8/ovs-bugtool.8.gz
138139
/usr/share/man/man8/ovs-ctl.8.gz
139140
/usr/share/man/man8/ovs-dpctl.8.gz
141+
/usr/share/man/man8/ovs-dpctl-top.8.gz
140142
/usr/share/man/man8/ovs-ofctl.8.gz
141143
/usr/share/man/man8/ovs-parse-backtrace.8.gz
142144
/usr/share/man/man8/ovs-pki.8.gz

utilities/automake.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bin_PROGRAMS += \
77
bin_SCRIPTS += utilities/ovs-pki
88
if HAVE_PYTHON
99
bin_SCRIPTS += \
10+
utilities/ovs-dpctl-top \
1011
utilities/ovs-l3ping \
1112
utilities/ovs-parse-backtrace \
1213
utilities/ovs-pcap \
@@ -24,6 +25,7 @@ EXTRA_DIST += \
2425
utilities/ovs-check-dead-ifs.in \
2526
utilities/ovs-ctl.in \
2627
utilities/ovs-dev.py \
28+
utilities/ovs-dpctl-top.in \
2729
utilities/ovs-l3ping.in \
2830
utilities/ovs-lib.in \
2931
utilities/ovs-parse-backtrace.in \
@@ -39,6 +41,7 @@ MAN_ROOTS += \
3941
utilities/ovs-controller.8.in \
4042
utilities/ovs-ctl.8 \
4143
utilities/ovs-dpctl.8.in \
44+
utilities/ovs-dpctl-top.8.in \
4245
utilities/ovs-l3ping.8.in \
4346
utilities/ovs-ofctl.8.in \
4447
utilities/ovs-parse-backtrace.8 \
@@ -57,6 +60,8 @@ DISTCLEANFILES += \
5760
utilities/ovs-check-dead-ifs \
5861
utilities/ovs-controller.8 \
5962
utilities/ovs-dpctl.8 \
63+
utilities/ovs-dpctl-top \
64+
utilities/ovs-dpctl-top.8 \
6065
utilities/ovs-l3ping \
6166
utilities/ovs-l3ping.8 \
6267
utilities/ovs-lib \
@@ -80,6 +85,7 @@ man_MANS += \
8085
utilities/ovs-benchmark.1 \
8186
utilities/ovs-controller.8 \
8287
utilities/ovs-dpctl.8 \
88+
utilities/ovs-dpctl-top.8 \
8389
utilities/ovs-l3ping.8 \
8490
utilities/ovs-ofctl.8 \
8591
utilities/ovs-parse-backtrace.8 \

utilities/ovs-dpctl-top.8.in

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
.de IQ
2+
. br
3+
. ns
4+
. IP "\\$1"
5+
..
6+
.TH ovs\-dpctl\-top "8" "@VERSION@" "Open vSwitch" "Open vSwitch Manual"
7+
.
8+
.SH NAME
9+
\fBovs\-dpctl\-top\fR \- Top like behavior for ovs\-dpctl dump\-flows
10+
.
11+
.SH SYNOPSIS
12+
\fBovs\-dpctl\-top\fR [\-h] [\-v] [\-f FLOWFILES] [\-V] [\-s] [\-\-host HOST]
13+
[\-a | \-\-accumulate] [\-\-accumulate\-decay ACCUMULATEDECAY] [\-d DELAY]
14+
.
15+
.SH DESCRIPTION
16+
.PP
17+
This program summarizes \fBovs\-dpctl\fR flow content by aggregating the number
18+
of packets, total bytes and occurrence of the following fields:
19+
.IP
20+
\- Datapath in_port
21+
.IP
22+
\- Ethernet type
23+
.IP
24+
\- Source and destination MAC addresses
25+
.IP
26+
\- IP protocol
27+
.IP
28+
\- Source and destination IPv4 addresses
29+
.IP
30+
\- Source and destination IPv6 addresses
31+
.IP
32+
\- UDP and TCP destination port
33+
.IP
34+
\- Tunnel source and destination addresses
35+
.
36+
.SS "Output shows four values:"
37+
.IP
38+
\- FIELDS: the flow fields for example in_port(1).
39+
.IP
40+
\- COUNT: the number of lines in the dump\-flow output contain the flow field.
41+
.IP
42+
\- PACKETS: the total number of packets containing the flow field.
43+
.IP
44+
\- BYTES: the total number of bytes containing the flow field. If units are
45+
not present then values are in bytes.
46+
.IP
47+
\- AVERAGE: the average packets size (BYTES/PACKET).
48+
.PP
49+
.SS "Top Behavior"
50+
.PP
51+
While in top mode, the default behavior, the following single character commands
52+
are supported:
53+
.IP
54+
a \- toggles top in accumulate and live mode. Accumulate mode is described
55+
below.
56+
.IP
57+
s \- toggles which column is used to sort content in decreasing order. A
58+
DESC title is placed over the column.
59+
.IP
60+
_ \- a space indicating to collect dump\-flow content again
61+
.IP
62+
h \- halt output. Any character will restart sampling
63+
.IP
64+
f \- cycle through flow fields
65+
.IP
66+
q \- q for quit.
67+
.PP
68+
.SS "Accumulate Mode"
69+
.PP
70+
There are two supported modes: live and accumulate. The default is live.
71+
The parameter \fB\-\-accumulate\fR or the 'a' character in top mode enables the
72+
latter. In live mode, recent dump\-flow content is presented.
73+
Where as accumulate mode keeps track of the prior historical
74+
information until the flow is reset not when the flow is purged. Reset
75+
flows are determined when the packet count for a flow has decreased from
76+
its previous sample. There is one caveat, eventually the system will
77+
run out of memory if, after the accumulate\-decay period any flows that
78+
have not been refreshed are purged. The goal here is to free memory
79+
of flows that are not active. Statistics are not decremented. Their purpose
80+
is to reflect the overall history of the flow fields.
81+
.PP
82+
.SS "Debugging Errors"
83+
.PP
84+
Parsing errors are counted and displayed in the status line at the beginning
85+
of the output. Use the \fB\-\-verbose\fR option with \fB\-\-script to see
86+
what output was not parsed, like this:
87+
.PP
88+
$ ovs\-dpctl dump\-flows | ovs\-dpctl\-top \fB\-\-script\fR \fB\-\-verbose\fR
89+
.PP
90+
Error messages will identify content that failed to parse.
91+
.PP
92+
.SS "Access Remote Hosts"
93+
.PP
94+
The \fB\-\-host\fR must follow the format user@hostname. This script simply
95+
calls \&'ssh user@Hostname' without checking for login credentials therefore
96+
public keys should be installed on the system identified by hostname, such as:
97+
.PP
98+
$ ssh\-copy\-id user@hostname
99+
.PP
100+
Consult ssh\-copy\-id man pages for more details.
101+
.PP
102+
.SS "Expected usage"
103+
.PP
104+
$ ovs\-dpctl\-top
105+
.PP
106+
or to run as a script:
107+
.PP
108+
$ ovs\-dpctl dump\-flows > dump\-flows.log
109+
.PP
110+
$ ovs\-dpctl\-top \fB\-\-script\fR \fB\-\-flow\-file\fR dump\-flows.log
111+
.SS "OPTIONS"
112+
.TP
113+
\fB\-h\fR, \fB\-\-help\fR
114+
show this help message and exit.
115+
.TP
116+
\fB\-v\fR, \fB\-\-version\fR
117+
show program's version number and exit.
118+
.TP
119+
\fB\-f\fR FLOWFILES, \fB\-\-flow\-file\fR FLOWFILES
120+
file containing flows from ovs\-dpctl dump\-flow.
121+
.TP
122+
\fB\-V\fR, \fB\-\-verbose\fR
123+
enable debug level verbosity.
124+
.TP
125+
\fB\-s\fR, \fB\-\-script\fR
126+
Run from a script (no user interface).
127+
.TP
128+
\fB\-\-host\fR HOST
129+
Specify a user@host for retrieving flows see Accessing
130+
Remote Hosts for more information.
131+
.TP
132+
\fB\-a\fR, \fB\-\-accumulate\fR
133+
Accumulate dump\-flow content.
134+
.TP
135+
\fB\-\-accumulate\-decay\fR ACCUMULATEDECAY
136+
Decay old accumulated flows. The default is 5 minutes. A value of 0 disables
137+
decay.
138+
.TP
139+
\fB\-d\fR DELAY, \fB\-\-delay\fR DELAY
140+
Delay in milliseconds to collect dump\-flow content (sample rate).

0 commit comments

Comments
 (0)