diff options
| author | Andrew Evans <aevans@nicira.com> | 2011-03-14 13:19:20 -0700 |
|---|---|---|
| committer | Andrew Evans <aevans@nicira.com> | 2011-03-14 13:19:26 -0700 |
| commit | 2cdcb8983d9e2f3d690ee5cb62593c05898fb26e (patch) | |
| tree | 84260b3ce0de2357172476cf3da06ea4d955227a /ofproto | |
| parent | 5eda645e36a9b5dd72c275b7e400dfefcba281d3 (diff) | |
| download | openvswitch-2cdcb8983d9e2f3d690ee5cb62593c05898fb26e.tar.gz | |
ofproto: Store time since last connect and disconnect in Controller table.
ovs-vswitchd writes only the duration of its connection to or disconnection
from each controller to the database. This changes that behavior to write the
time since both the last connection and disconnection events regardless of
connection state. This mirrors the new behavior for reporting database manager
connection status.
Requested-by: Peter Balland <peter@nicira.com>
Bug #4833.
Diffstat (limited to 'ofproto')
| -rw-r--r-- | ofproto/ofproto.c | 23 | ||||
| -rw-r--r-- | ofproto/ofproto.h | 4 |
2 files changed, 16 insertions, 11 deletions
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index c7872baf7..147ade3a0 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1367,7 +1367,7 @@ ofproto_is_alive(const struct ofproto *p) } void -ofproto_get_ofproto_controller_info(const struct ofproto * ofproto, +ofproto_get_ofproto_controller_info(const struct ofproto *ofproto, struct shash *info) { const struct ofconn *ofconn; @@ -1376,6 +1376,9 @@ ofproto_get_ofproto_controller_info(const struct ofproto * ofproto, HMAP_FOR_EACH (ofconn, hmap_node, &ofproto->controllers) { const struct rconn *rconn = ofconn->rconn; + time_t now = time_now(); + time_t last_connection = rconn_get_last_connection(rconn); + time_t last_disconnect = rconn_get_last_disconnect(rconn); const int last_error = rconn_get_last_error(rconn); struct ofproto_controller_info *cinfo = xmalloc(sizeof *cinfo); @@ -1396,14 +1399,16 @@ ofproto_get_ofproto_controller_info(const struct ofproto * ofproto, cinfo->pairs.values[cinfo->pairs.n++] = xstrdup(rconn_get_state(rconn)); - if (rconn_is_admitted(rconn)) { - cinfo->pairs.keys[cinfo->pairs.n] = "time_connected"; - cinfo->pairs.values[cinfo->pairs.n++] = - xasprintf("%ld", time_now() - rconn_get_last_connection(rconn)); - } else { - cinfo->pairs.keys[cinfo->pairs.n] = "time_disconnected"; - cinfo->pairs.values[cinfo->pairs.n++] = - xasprintf("%d", rconn_failure_duration(rconn)); + if (last_connection != TIME_MIN) { + cinfo->pairs.keys[cinfo->pairs.n] = "sec_since_connect"; + cinfo->pairs.values[cinfo->pairs.n++] + = xasprintf("%ld", (long int) (now - last_connection)); + } + + if (last_disconnect != TIME_MIN) { + cinfo->pairs.keys[cinfo->pairs.n] = "sec_since_disconnect"; + cinfo->pairs.values[cinfo->pairs.n++] + = xasprintf("%ld", (long int) (now - last_disconnect)); } } } diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index 2828c645b..a32b9b911 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -41,8 +41,8 @@ struct ofproto_controller_info { bool is_connected; enum nx_role role; struct { - const char *keys[3]; - const char *values[3]; + const char *keys[4]; + const char *values[4]; size_t n; } pairs; }; |
