Skip to content

Commit

Permalink
utilities: a top like tool for ovs-dpctl dump-flows.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
Mark Hamilton authored and shettyg committed Sep 17, 2013
1 parent 1394054 commit 14b4c57
Show file tree
Hide file tree
Showing 9 changed files with 1,844 additions and 1 deletion.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Description: Open vSwitch common components
Package: openvswitch-switch
Architecture: linux-any
Suggests: openvswitch-datapath-module
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, openvswitch-common (= ${binary:Version}), module-init-tools, procps, uuid-runtime, netbase
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, openvswitch-common (= ${binary:Version}), module-init-tools, procps, uuid-runtime, netbase, python-argparse
Description: Open vSwitch switch implementations
Open vSwitch is a production quality, multilayer, software-based,
Ethernet virtual switch. It is designed to enable massive network
Expand Down
1 change: 1 addition & 0 deletions debian/openvswitch-switch.install
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
usr/bin/ovs-dpctl
usr/bin/ovs-dpctl-top
usr/bin/ovs-pcap
usr/bin/ovs-tcpundump
usr/bin/ovs-vlan-test
Expand Down
1 change: 1 addition & 0 deletions debian/openvswitch-switch.manpages
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
_debian/ovsdb/ovsdb-server.1
_debian/utilities/ovs-dpctl.8
_debian/utilities/ovs-dpctl-top.8
_debian/utilities/ovs-pcap.1
_debian/utilities/ovs-tcpundump.1
_debian/utilities/ovs-vlan-test.8
Expand Down
4 changes: 4 additions & 0 deletions manpages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ utilities/ovs-dpctl.8.in:
lib/common.man:
lib/vlog.man:

utilities/ovs-dpctl-top.8: \
utilities/ovs-dpctl-top.8.in
utilities/ovs-dpctl-top.8.in:

utilities/ovs-l3ping.8: \
utilities/ovs-l3ping.8.in \
lib/common-syn.man \
Expand Down
2 changes: 2 additions & 0 deletions rhel/openvswitch.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ exit 0
/usr/bin/ovs-appctl
/usr/bin/ovs-benchmark
/usr/bin/ovs-dpctl
/usr/bin/ovs-dpctl-top
/usr/bin/ovs-ofctl
/usr/bin/ovs-parse-backtrace
/usr/bin/ovs-pcap
Expand All @@ -137,6 +138,7 @@ exit 0
/usr/share/man/man8/ovs-bugtool.8.gz
/usr/share/man/man8/ovs-ctl.8.gz
/usr/share/man/man8/ovs-dpctl.8.gz
/usr/share/man/man8/ovs-dpctl-top.8.gz
/usr/share/man/man8/ovs-ofctl.8.gz
/usr/share/man/man8/ovs-parse-backtrace.8.gz
/usr/share/man/man8/ovs-pki.8.gz
Expand Down
6 changes: 6 additions & 0 deletions utilities/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bin_PROGRAMS += \
bin_SCRIPTS += utilities/ovs-pki
if HAVE_PYTHON
bin_SCRIPTS += \
utilities/ovs-dpctl-top \
utilities/ovs-l3ping \
utilities/ovs-parse-backtrace \
utilities/ovs-pcap \
Expand All @@ -24,6 +25,7 @@ EXTRA_DIST += \
utilities/ovs-check-dead-ifs.in \
utilities/ovs-ctl.in \
utilities/ovs-dev.py \
utilities/ovs-dpctl-top.in \
utilities/ovs-l3ping.in \
utilities/ovs-lib.in \
utilities/ovs-parse-backtrace.in \
Expand All @@ -39,6 +41,7 @@ MAN_ROOTS += \
utilities/ovs-controller.8.in \
utilities/ovs-ctl.8 \
utilities/ovs-dpctl.8.in \
utilities/ovs-dpctl-top.8.in \
utilities/ovs-l3ping.8.in \
utilities/ovs-ofctl.8.in \
utilities/ovs-parse-backtrace.8 \
Expand All @@ -57,6 +60,8 @@ DISTCLEANFILES += \
utilities/ovs-check-dead-ifs \
utilities/ovs-controller.8 \
utilities/ovs-dpctl.8 \
utilities/ovs-dpctl-top \
utilities/ovs-dpctl-top.8 \
utilities/ovs-l3ping \
utilities/ovs-l3ping.8 \
utilities/ovs-lib \
Expand All @@ -80,6 +85,7 @@ man_MANS += \
utilities/ovs-benchmark.1 \
utilities/ovs-controller.8 \
utilities/ovs-dpctl.8 \
utilities/ovs-dpctl-top.8 \
utilities/ovs-l3ping.8 \
utilities/ovs-ofctl.8 \
utilities/ovs-parse-backtrace.8 \
Expand Down
140 changes: 140 additions & 0 deletions utilities/ovs-dpctl-top.8.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
.de IQ
. br
. ns
. IP "\\$1"
..
.TH ovs\-dpctl\-top "8" "@VERSION@" "Open vSwitch" "Open vSwitch Manual"
.
.SH NAME
\fBovs\-dpctl\-top\fR \- Top like behavior for ovs\-dpctl dump\-flows
.
.SH SYNOPSIS
\fBovs\-dpctl\-top\fR [\-h] [\-v] [\-f FLOWFILES] [\-V] [\-s] [\-\-host HOST]
[\-a | \-\-accumulate] [\-\-accumulate\-decay ACCUMULATEDECAY] [\-d DELAY]
.
.SH DESCRIPTION
.PP
This program summarizes \fBovs\-dpctl\fR flow content by aggregating the number
of packets, total bytes and occurrence of the following fields:
.IP
\- Datapath in_port
.IP
\- Ethernet type
.IP
\- Source and destination MAC addresses
.IP
\- IP protocol
.IP
\- Source and destination IPv4 addresses
.IP
\- Source and destination IPv6 addresses
.IP
\- UDP and TCP destination port
.IP
\- Tunnel source and destination addresses
.
.SS "Output shows four values:"
.IP
\- FIELDS: the flow fields for example in_port(1).
.IP
\- COUNT: the number of lines in the dump\-flow output contain the flow field.
.IP
\- PACKETS: the total number of packets containing the flow field.
.IP
\- BYTES: the total number of bytes containing the flow field. If units are
not present then values are in bytes.
.IP
\- AVERAGE: the average packets size (BYTES/PACKET).
.PP
.SS "Top Behavior"
.PP
While in top mode, the default behavior, the following single character commands
are supported:
.IP
a \- toggles top in accumulate and live mode. Accumulate mode is described
below.
.IP
s \- toggles which column is used to sort content in decreasing order. A
DESC title is placed over the column.
.IP
_ \- a space indicating to collect dump\-flow content again
.IP
h \- halt output. Any character will restart sampling
.IP
f \- cycle through flow fields
.IP
q \- q for quit.
.PP
.SS "Accumulate Mode"
.PP
There are two supported modes: live and accumulate. The default is live.
The parameter \fB\-\-accumulate\fR or the 'a' character in top mode enables the
latter. In live mode, recent dump\-flow content is presented.
Where as accumulate mode keeps track of the prior historical
information until the flow is reset not when the flow is purged. Reset
flows are determined when the packet count for a flow has decreased from
its previous sample. There is one caveat, eventually the system will
run out of memory if, after the accumulate\-decay period any flows that
have not been refreshed are purged. The goal here is to free memory
of flows that are not active. Statistics are not decremented. Their purpose
is to reflect the overall history of the flow fields.
.PP
.SS "Debugging Errors"
.PP
Parsing errors are counted and displayed in the status line at the beginning
of the output. Use the \fB\-\-verbose\fR option with \fB\-\-script to see
what output was not parsed, like this:
.PP
$ ovs\-dpctl dump\-flows | ovs\-dpctl\-top \fB\-\-script\fR \fB\-\-verbose\fR
.PP
Error messages will identify content that failed to parse.
.PP
.SS "Access Remote Hosts"
.PP
The \fB\-\-host\fR must follow the format user@hostname. This script simply
calls \&'ssh user@Hostname' without checking for login credentials therefore
public keys should be installed on the system identified by hostname, such as:
.PP
$ ssh\-copy\-id user@hostname
.PP
Consult ssh\-copy\-id man pages for more details.
.PP
.SS "Expected usage"
.PP
$ ovs\-dpctl\-top
.PP
or to run as a script:
.PP
$ ovs\-dpctl dump\-flows > dump\-flows.log
.PP
$ ovs\-dpctl\-top \fB\-\-script\fR \fB\-\-flow\-file\fR dump\-flows.log
.SS "OPTIONS"
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit.
.TP
\fB\-v\fR, \fB\-\-version\fR
show program's version number and exit.
.TP
\fB\-f\fR FLOWFILES, \fB\-\-flow\-file\fR FLOWFILES
file containing flows from ovs\-dpctl dump\-flow.
.TP
\fB\-V\fR, \fB\-\-verbose\fR
enable debug level verbosity.
.TP
\fB\-s\fR, \fB\-\-script\fR
Run from a script (no user interface).
.TP
\fB\-\-host\fR HOST
Specify a user@host for retrieving flows see Accessing
Remote Hosts for more information.
.TP
\fB\-a\fR, \fB\-\-accumulate\fR
Accumulate dump\-flow content.
.TP
\fB\-\-accumulate\-decay\fR ACCUMULATEDECAY
Decay old accumulated flows. The default is 5 minutes. A value of 0 disables
decay.
.TP
\fB\-d\fR DELAY, \fB\-\-delay\fR DELAY
Delay in milliseconds to collect dump\-flow content (sample rate).
Loading

0 comments on commit 14b4c57

Please sign in to comment.