summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-06-13 17:09:05 -0700
committerBen Pfaff <blp@ovn.org>2017-06-14 12:50:23 -0700
commit1b3758c36e88fd261377726f9ab958a0be53f2ca (patch)
tree12b68e5006754b9a43edc337e537cf25b6181377 /utilities
parent89cf41eca75e28b85423c04f0ed7665a0f160a26 (diff)
downloadopenvswitch-1b3758c36e88fd261377726f9ab958a0be53f2ca.tar.gz
ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".
It's pretty common to want to omit statistics from output, to make it easier to read. This commit adds an ovs-ofctl option to make that easy. A lot of the OVS internal tests could use this, too, in place of ofctl_strip. This commit adopts it for a subset. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Aaron Conole <aconole@redhat.com>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ofctl.8.in14
-rw-r--r--utilities/ovs-ofctl.c12
2 files changed, 21 insertions, 5 deletions
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 3b86c0d73..65525908a 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -222,8 +222,11 @@ syntax of \fIflows\fR. The output format is described in
.IP
By default, \fBovs\-ofctl\fR prints flow entries in the same order
that the switch sends them, which is unlikely to be intuitive or
-consistent. See the description of \fB\-\-sort\fR and \fB\-\-rsort\fR,
-under \fBOPTIONS\fR below, to influence the display order.
+consistent. Use \fB\-\-sort\fR and \fB\-\-rsort\fR to control display
+order. The \fB\-\-names\fR/\fB\-\-no\-names\fR and
+\fB\-\-stats\fR/\fB\-\-no\-stats\fR options also affect output
+formatting. See the descriptions of these options, under
+\fBOPTIONS\fR below, for more information
.
.TP
\fBdump\-aggregate \fIswitch \fR[\fIflows\fR]
@@ -2222,6 +2225,13 @@ be the same; when a switch has two ports with the same (truncated)
name, \fBovs\-ofctl\fR refuses to display or accept the name, using
the number instead.
.
+.IP "\fB\-\-stats\fR"
+.IQ "\fB\-\-no\-stats\fR"
+The \fBdump\-flows\fR command by default, or with \fB\-\-stats\fR,
+includes flow duration, packet and byte counts, and idle and hard age
+in its output. With \fB\-\-no\-stats\fR, it omits all of these, as
+well as cookie values and table IDs if they are zero.
+.
.IP "\fB\-\-read-only\fR"
Do not execute read/write commands.
.
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 95989eb11..d7e37e85f 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -135,6 +135,9 @@ static const struct ofputil_port_map *ports_to_show(const char *vconn_name);
static bool should_accept_ports(void);
static bool should_show_ports(void);
+/* --stats, --no-stats: Show statistics in flow dumps? */
+static int show_stats = 1;
+
static const struct ovs_cmdl_command *get_all_commands(void);
OVS_NO_RETURN static void usage(void);
@@ -212,6 +215,8 @@ parse_options(int argc, char *argv[])
{"rsort", optional_argument, NULL, OPT_RSORT},
{"names", no_argument, &use_port_names, 1},
{"no-names", no_argument, &use_port_names, 0},
+ {"stats", no_argument, &show_stats, 1},
+ {"no-stats", no_argument, &show_stats, 0},
{"unixctl", required_argument, NULL, OPT_UNIXCTL},
{"help", no_argument, NULL, 'h'},
{"option", no_argument, NULL, 'o'},
@@ -1357,7 +1362,7 @@ compare_flows(const void *afs_, const void *bfs_)
static void
ofctl_dump_flows(struct ovs_cmdl_context *ctx)
{
- if (!n_criteria && !should_show_ports()) {
+ if (!n_criteria && !should_show_ports() && show_stats) {
ofctl_dump_flows__(ctx->argc, ctx->argv, false);
return;
} else {
@@ -1378,8 +1383,9 @@ ofctl_dump_flows(struct ovs_cmdl_context *ctx)
struct ds s = DS_EMPTY_INITIALIZER;
for (size_t i = 0; i < n_fses; i++) {
ds_clear(&s);
- ofp_print_flow_stats(&s, &fses[i], ports_to_show(ctx->argv[1]));
- puts(ds_cstr(&s));
+ ofp_print_flow_stats(&s, &fses[i], ports_to_show(ctx->argv[1]),
+ show_stats);
+ printf(" %s\n", ds_cstr(&s));
}
ds_destroy(&s);