summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-02-07 16:17:13 -0800
committerBen Pfaff <blp@nicira.com>2012-02-27 09:30:28 -0800
commit0c9560b7ded6d556762f9fd74ffd9fdfac12afc0 (patch)
treeba761a91e1991aa33a4adeeb69cc29404228b6fb /utilities
parent2a3e30b27d11f77a8ce8ff87d0a2c0eaa925eaff (diff)
downloadopenvswitch-0c9560b7ded6d556762f9fd74ffd9fdfac12afc0.tar.gz
ovs-ofctl: Add --timestamp option to print time for each received packet.
Suggestion #9347. Suggested-by: Alan Shieh <ashieh@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ofctl.8.in4
-rw-r--r--utilities/ovs-ofctl.c18
2 files changed, 22 insertions, 0 deletions
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 8de6af947..48ff7afe9 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -1202,6 +1202,10 @@ will insist on the selected format. If the switch does not support the
requested format, \fBovs\-ofctl\fR will report a fatal error. This option only
affects the \fBmonitor\fR command.
.
+.IP "\fB\-\-timestamp\fR"
+Print a timestamp before each received packet. This option only
+affects the \fBmonitor\fR and \fBsnoop\fR commands.
+.
.IP "\fB\-m\fR"
.IQ "\fB\-\-more\fR"
Increases the verbosity of OpenFlow messages printed and logged by
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index d2efd7f23..bf7a2c126 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -79,6 +79,10 @@ static int preferred_packet_in_format = -1;
/* -m, --more: Additional verbosity for ofp-print functions. */
static int verbosity;
+/* --timestamp: Print a timestamp before each received packet on "monitor" and
+ * "snoop" command? */
+static bool timestamp;
+
static const struct command all_commands[];
static void usage(void) NO_RETURN;
@@ -100,6 +104,7 @@ parse_options(int argc, char *argv[])
enum {
OPT_STRICT = UCHAR_MAX + 1,
OPT_READD,
+ OPT_TIMESTAMP,
DAEMON_OPTION_ENUMS,
VLOG_OPTION_ENUMS
};
@@ -110,6 +115,7 @@ parse_options(int argc, char *argv[])
{"flow-format", required_argument, NULL, 'F'},
{"packet-in-format", required_argument, NULL, 'P'},
{"more", no_argument, NULL, 'm'},
+ {"timestamp", no_argument, NULL, OPT_TIMESTAMP},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
DAEMON_LONG_OPTIONS,
@@ -173,6 +179,10 @@ parse_options(int argc, char *argv[])
readd = true;
break;
+ case OPT_TIMESTAMP:
+ timestamp = true;
+ break;
+
DAEMON_OPTION_HANDLERS
VLOG_OPTION_HANDLERS
STREAM_SSL_OPTION_HANDLERS
@@ -231,6 +241,7 @@ usage(void)
" -F, --flow-format=FORMAT force particular flow format\n"
" -P, --packet-in-format=FRMT force particular packet in format\n"
" -m, --more be more verbose printing OpenFlow\n"
+ " --timestamp (monitor, snoop) print timestamps\n"
" -t, --timeout=SECS give up after SECS seconds\n"
" -h, --help display this help message\n"
" -V, --version display version information\n");
@@ -991,6 +1002,13 @@ monitor_vconn(struct vconn *vconn)
msg_type = ((const struct ofp_header *) b->data)->type;
run(retval, "vconn_recv");
+ if (timestamp) {
+ time_t now = time_wall();
+ char s[32];
+
+ strftime(s, sizeof s, "%Y-%m-%d %H:%M:%S: ", localtime(&now));
+ fputs(s, stderr);
+ }
ofp_print(stderr, b->data, b->size, verbosity + 2);
ofpbuf_delete(b);