summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorAndrew Evans <aevans@nicira.com>2011-03-14 13:10:02 -0700
committerAndrew Evans <aevans@nicira.com>2011-03-14 13:10:02 -0700
commit5eda645e36a9b5dd72c275b7e400dfefcba281d3 (patch)
tree60a687958694aa067bc705a91bbadef89d916d88 /ovsdb
parent6d38ac7cb9fc65ee94ebeb3e9cde11b27c2173bb (diff)
downloadopenvswitch-5eda645e36a9b5dd72c275b7e400dfefcba281d3.tar.gz
ovsdb-server: Report time since last connect and disconnect for each manager.
Only the time connected (if connected) or disconnected (if disconnected) is currently reported for each manager. Change to reporting both in seconds since the last connect and disconnect events respectively. An empty value indicates no previous connection or disconnection. This can help diagnose certain connectivity problems, e.g. flapping. Requested-by: Peter Balland <peter@nicira.com> Bug #4833.
Diffstat (limited to 'ovsdb')
-rw-r--r--ovsdb/jsonrpc-server.c8
-rw-r--r--ovsdb/jsonrpc-server.h3
-rw-r--r--ovsdb/ovsdb-server.c13
3 files changed, 15 insertions, 9 deletions
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 713c51828..fc9c60478 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -470,10 +470,10 @@ ovsdb_jsonrpc_session_get_status(const struct ovsdb_jsonrpc_remote *remote,
jsonrpc_session_get_reconnect_stats(js, &rstats);
status->state = rstats.state;
- status->conn_secs = (rstats.is_connected
- ? rstats.current_connection_duration
- : rstats.current_disconnect_duration
- ) / 1000;
+ status->sec_since_connect = rstats.msec_since_connect == UINT_MAX
+ ? UINT_MAX : rstats.msec_since_connect / 1000;
+ status->sec_since_disconnect = rstats.msec_since_disconnect == UINT_MAX
+ ? UINT_MAX : rstats.msec_since_disconnect / 1000;
return;
}
diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h
index 691b55e2b..dc786352e 100644
--- a/ovsdb/jsonrpc-server.h
+++ b/ovsdb/jsonrpc-server.h
@@ -38,7 +38,8 @@ void ovsdb_jsonrpc_server_set_remotes(struct ovsdb_jsonrpc_server *,
struct ovsdb_jsonrpc_remote_status {
const char *state;
int last_error;
- unsigned int conn_secs;
+ unsigned int sec_since_connect;
+ unsigned int sec_since_disconnect;
bool is_connected;
};
void ovsdb_jsonrpc_server_get_remote_status(
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 9eb58ebf1..8d44d8485 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -469,7 +469,7 @@ update_remote_row(const struct ovsdb_row *row, struct ovsdb_txn *txn,
struct ovsdb_row *rw_row;
const char *target;
const struct ovsdb_jsonrpc_remote_status *status;
- char *keys[3], *values[3];
+ char *keys[4], *values[4];
size_t n = 0;
/* Get the "target" (protocol/host/port) spec. */
@@ -495,9 +495,14 @@ update_remote_row(const struct ovsdb_row *row, struct ovsdb_txn *txn,
keys[n] = xstrdup("state");
values[n++] = xstrdup(status->state);
- keys[n] = xstrdup(status->is_connected ? "time_connected"
- : "time_disconnected");
- values[n++] = xasprintf("%u", status->conn_secs);
+ if (status->sec_since_connect != UINT_MAX) {
+ keys[n] = xstrdup("sec_since_connect");
+ values[n++] = xasprintf("%u", status->sec_since_connect);
+ }
+ if (status->sec_since_disconnect != UINT_MAX) {
+ keys[n] = xstrdup("sec_since_disconnect");
+ values[n++] = xasprintf("%u", status->sec_since_disconnect);
+ }
if (status->last_error) {
keys[n] = xstrdup("last_error");
values[n++] =