[ovs-dev] [PATCH] ovsdb-server: Record both time connected and disconnected for managers.
Andrew Evans
aevans at nicira.com
Thu Mar 10 20:18:31 UTC 2011
Rather than writing just time connected or disconnected to Manager.status
depending on current connection state, write both regardless. This can help
diagnose certain connectivity problems, e.g. flapping.
Requested-by: Keith Amidon <keith at nicira.com>
Bug #4833.
---
ovsdb/jsonrpc-server.c | 6 ++----
ovsdb/jsonrpc-server.h | 3 ++-
ovsdb/ovsdb-server.c | 9 +++++----
vswitchd/vswitch.xml | 15 +++++++++++----
4 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 713c518..6b779b5 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -470,10 +470,8 @@ 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->connected_secs = rstats.current_connection_duration / 1000;
+ status->disconnected_secs = rstats.current_disconnect_duration / 1000;
return;
}
diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h
index 691b55e..4e4cc93 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 connected_secs;
+ unsigned int disconnected_secs;
bool is_connected;
};
void ovsdb_jsonrpc_server_get_remote_status(
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 9eb58eb..475ed8d 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,10 @@ 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);
+ keys[n] = xstrdup("time_connected");
+ values[n++] = xasprintf("%u", status->connected_secs);
+ keys[n] = xstrdup("time_disconnected");
+ values[n++] = xasprintf("%u", status->disconnected_secs);
if (status->last_error) {
keys[n] = xstrdup("last_error");
values[n++] =
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index e0245cd..95484f8 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -2092,15 +2092,22 @@
<dd>The state of the connection to the manager. Possible values
are: <code>VOID</code> (connection is disabled),
<code>BACKOFF</code> (attempting to reconnect at an increasing
- period), <code>CONNECT_IN_PROGRESS</code> (attempting to connect),
+ period), <code>CONNECTING</code> (attempting to connect),
<code>ACTIVE</code> (connected, remote host responsive), and
- <code>IDLE</code> (remote host unresponsive, disconnecting). These
+ <code>IDLE</code> (remote host idle, sending keep-alive). These
values may change in the future. They are provided only for human
consumption.</dd>
</dl>
<dl>
- <dt><code>time_in_state</code></dt>
- <dd>Milliseconds since the <code>state</code> key changed.</dd>
+ <dt><code>time_connected</code></dt>
+ <dd>The amount of time this manager has been connected to the
+ database (in seconds). <code>0</code> if currently
+ disconnected.</dd>
+ </dl>
+ <dl>
+ <dt><code>time_disconnected</code></dt>
+ <dd>The amount of time this manager has been disconnected from the
+ database (in seconds). <code>0</code> if currently connected.</dd>
</dl>
</column>
</group>
--
1.7.2.3
More information about the dev
mailing list