Suggestion #9347.
Suggested-by: Alan Shieh <ashieh@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
should maintain by updating with ofproto_rule_update_used().
- The default MAC learning timeout has been increased from 60 seconds
to 300 seconds. The MAC learning timeout is now configurable.
+ - ovsdb-client:
+ - The new option --timestamp causes the "monitor" command to print
+ a timestamp with every update.
v1.5.0 - xx xxx xxxx
/*
- * Copyright (c) 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "json.h"
#include "ovsdb-data.h"
#include "ovsdb-error.h"
+#include "timeval.h"
#include "util.h"
struct column {
table->caption = caption;
}
+/* Turns printing a timestamp along with 'table' on or off, according to
+ * 'timestamp'. */
+void
+table_set_timestamp(struct table *table, bool timestamp)
+{
+ table->timestamp = timestamp;
+}
+
/* Adds a new column to 'table' just to the right of any existing column, with
* 'heading' as a title for the column. 'heading' must be a valid printf()
* format specifier.
ds_clear(line);
}
+static void
+table_format_timestamp__(char *s, size_t size)
+{
+ time_t now = time_wall();
+ strftime(s, size, "%Y-%m-%d %H:%M:%S", localtime(&now));
+}
+
+static void
+table_print_timestamp__(const struct table *table)
+{
+ if (table->timestamp) {
+ char s[32];
+
+ table_format_timestamp__(s, sizeof s);
+ puts(s);
+ }
+}
+
static void
table_print_table__(const struct table *table, const struct table_style *style)
{
putchar('\n');
}
+ table_print_timestamp__(table);
+
if (table->caption) {
puts(table->caption);
}
putchar('\n');
}
+ table_print_timestamp__(table);
+
if (table->caption) {
puts(table->caption);
}
{
size_t x, y;
+ table_print_timestamp__(table);
+
fputs("<table border=1>\n", stdout);
if (table->caption) {
putchar('\n');
}
+ table_print_timestamp__(table);
+
if (table->caption) {
puts(table->caption);
}
if (table->caption) {
json_object_put_string(json, "caption", table->caption);
}
+ if (table->timestamp) {
+ char s[32];
+
+ table_format_timestamp__(s, sizeof s);
+ json_object_put_string(json, "time", s);
+ }
headings = json_array_create_empty();
for (x = 0; x < table->n_columns; x++) {
/*
- * Copyright (c) 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
size_t n_rows, allocated_rows;
size_t current_column;
char *caption;
+ bool timestamp;
};
void table_init(struct table *);
void table_destroy(struct table *);
void table_set_caption(struct table *, char *caption);
+void table_set_timestamp(struct table *, bool timestamp);
void table_add_column(struct table *, const char *heading, ...)
PRINTF_FORMAT(2, 3);
[\fB\-\-pretty\fR]
[\fB\-\-bare\fR]
[\fB\-\-no\-heading\fR]
+[\fB\-\-timestamp\fR]
.so lib/daemon-syn.man
.so lib/vlog-syn.man
.so lib/ssl-syn.man
.ds TD (default)
.so lib/table.man
.
+.IP "\fB\-\-timestamp\fR"
+For the \fB\-\-monitor\fR command, adds a timestamp to each table
+update. Most output formats add the timestamp on a line of its own
+just above the table. The JSON output format puts the timestamp in a
+member of the top-level JSON object named \fBtime\fR.
+.
.SS "Daemon Options"
The daemon options apply only to the \fBmonitor\fR command. With any
other command, they have no effect.
int argc, char *argv[]);
};
+/* --timestamp: Print a timestamp before each update on "monitor" command? */
+static bool timestamp;
+
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
{
enum {
OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1,
+ OPT_TIMESTAMP,
DAEMON_OPTION_ENUMS,
TABLE_OPTION_ENUMS
};
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
+ {"timestamp", no_argument, NULL, OPT_TIMESTAMP},
DAEMON_LONG_OPTIONS,
#ifdef HAVE_OPENSSL
{"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT},
stream_ssl_set_ca_cert_file(optarg, true);
break;
+ case OPT_TIMESTAMP:
+ timestamp = true;
+ break;
+
case '?':
exit(EXIT_FAILURE);
" (\"table\", \"html\", \"csv\", "
"or \"json\")\n"
" --no-headings omit table heading row\n"
- " --pretty pretty-print JSON in output");
+ " --pretty pretty-print JSON in output\n"
+ " --timestamp timestamp \"monitor\" output");
daemon_usage();
vlog_usage();
printf("\nOther options:\n"
size_t i;
table_init(&t);
+ table_set_timestamp(&t, timestamp);
if (table_updates->type != JSON_OBJECT) {
ovs_error(0, "<table-updates> is not object");