Message ID | 1503394869-76348-8-git-send-email-bhanuprakash.bodireddy@intel.com |
---|---|
State | Superseded |
Headers | show |
Comments inline. > -----Original Message----- > From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-bounces@openvswitch.org] > On Behalf Of Bhanuprakash Bodireddy > Sent: Tuesday, August 22, 2017 10:41 AM > To: dev@openvswitch.org > Cc: i.maximets@samsung.com > Subject: [ovs-dev] [PATCH v4 7/7] keepalive: Add support to query keepalive > status and statistics. > > This commit adds support to query keepalive status and statistics. > > $ ovs-appctl keepalive/status > keepAlive Status: Enabled > > $ ovs-appctl keepalive/pmd-health-show > > Keepalive status > > keepalive status : Enabled > keepalive interval: 1000 ms > PMD threads : 4 > > PMD CORE STATE LAST SEEN TIMESTAMP(UTC) > pmd62 0 ALIVE 21 Aug 2017 16:29:31 > pmd63 1 ALIVE 21 Aug 2017 16:29:31 > pmd64 2 ALIVE 21 Aug 2017 16:29:31 > pmd65 3 GONE 21 Aug 2017 16:26:31 > > Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> > --- > lib/keepalive.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > > diff --git a/lib/keepalive.c b/lib/keepalive.c > index 2497f00..119e351 100644 > --- a/lib/keepalive.c > +++ b/lib/keepalive.c > @@ -22,10 +22,12 @@ > > #include "keepalive.h" > #include "lib/vswitch-idl.h" > +#include "openvswitch/dynamic-string.h" > #include "openvswitch/vlog.h" > #include "ovs-thread.h" > #include "process.h" > #include "timeval.h" > +#include "unixctl.h" > > VLOG_DEFINE_THIS_MODULE(keepalive); > > @@ -295,6 +297,95 @@ ka_stats_run(void) > return ka_stats; > } > > +static void > +ka_unixctl_status(struct unixctl_conn *conn, int argc OVS_UNUSED, > + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) > +{ > + struct ds ds = DS_EMPTY_INITIALIZER; > + > + ds_put_format(&ds, "keepAlive Status: %s", > + ka_is_enabled() ? "Enabled" : "Disabled"); > + > + unixctl_command_reply(conn, ds_cstr(&ds)); > + ds_destroy(&ds); > +} > + > +static void > +ka_unixctl_pmd_health_show(struct unixctl_conn *conn, int argc OVS_UNUSED, > + const char *argv[] OVS_UNUSED, void *ka_info_) > +{ > + struct ds ds = DS_EMPTY_INITIALIZER; > + ds_put_format(&ds, > + "\n\t\tKeepalive status\n\n"); > + > + ds_put_format(&ds, "keepalive status : %s\n", > + ka_is_enabled() ? "Enabled" : "Disabled"); > + > + if (!ka_is_enabled()) { > + goto out; > + } > + > + ds_put_format(&ds, "keepalive interval: %"PRIu32" ms\n", > + get_ka_interval()); > + > + struct keepalive_info *ka_info = (struct keepalive_info *)ka_info_; > + if (OVS_UNLIKELY(!ka_info)) { > + goto out; > + } > + > + ds_put_format(&ds, "PMD threads : %"PRIu32" \n", ka_info->pmd_cnt); > + ds_put_format(&ds, > + "\n PMD\tCORE\tSTATE\tLAST SEEN TIMESTAMP(UTC)\n"); > + > + struct ka_process_info *pinfo, *pinfo_next; > + > + ovs_mutex_lock(&ka_info->proclist_mutex); > + HMAP_FOR_EACH_SAFE (pinfo, pinfo_next, node, &ka_info->process_list) { > + char *state = NULL; > + > + if (pinfo->core_state == KA_STATE_UNUSED) { > + continue; > + } > + > + switch (pinfo->core_state) { > + case KA_STATE_ALIVE: > + state = "ALIVE"; > + break; > + case KA_STATE_MISSING: > + state = "MISSING"; > + break; > + case KA_STATE_DEAD: > + state = "DEAD"; > + break; > + case KA_STATE_GONE: > + state = "GONE"; > + break; > + case KA_STATE_DOZING: > + state = "DOZING"; > + break; > + case KA_STATE_SLEEP: > + state = "SLEEP"; > + break; > + case KA_STATE_UNUSED: > + break; > + } [Antonio] Quite similarly to comment in patch #2, I'd add to the switch statement at the end something like? + default: + VLOG_DBG("Unexpected %d value for core_state.", pinfo->core_state); > + > + char *utc = xastrftime_msec("%d %b %Y %H:%M:%S", > + pinfo->core_last_seen_times, true); > + > + ds_put_format(&ds, "%s\t%2d\t%s\t%s\n", > + pinfo->name, pinfo->core_id, state, utc); > + > + free(utc); > + } > + ovs_mutex_unlock(&ka_info->proclist_mutex); > + > + ds_put_format(&ds, "\n"); > +out: > + unixctl_command_reply(conn, ds_cstr(&ds)); > + ds_destroy(&ds); > +} > + > /* Dispatch heartbeats. */ > void > dispatch_heartbeats(void) > @@ -412,6 +503,12 @@ ka_init(const struct smap *ovs_other_config) > ka_init_status = ka_init_success; > } > > + unixctl_command_register("keepalive/status", "", 0, 0, > + ka_unixctl_status, NULL); > + > + unixctl_command_register("keepalive/pmd-health-show", "", 0, 0, > + ka_unixctl_pmd_health_show, ka_info); > + > ovsthread_once_done(&once_enable); > } > } > -- > 2.4.11 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff --git a/lib/keepalive.c b/lib/keepalive.c index 2497f00..119e351 100644 --- a/lib/keepalive.c +++ b/lib/keepalive.c @@ -22,10 +22,12 @@ #include "keepalive.h" #include "lib/vswitch-idl.h" +#include "openvswitch/dynamic-string.h" #include "openvswitch/vlog.h" #include "ovs-thread.h" #include "process.h" #include "timeval.h" +#include "unixctl.h" VLOG_DEFINE_THIS_MODULE(keepalive); @@ -295,6 +297,95 @@ ka_stats_run(void) return ka_stats; } +static void +ka_unixctl_status(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) +{ + struct ds ds = DS_EMPTY_INITIALIZER; + + ds_put_format(&ds, "keepAlive Status: %s", + ka_is_enabled() ? "Enabled" : "Disabled"); + + unixctl_command_reply(conn, ds_cstr(&ds)); + ds_destroy(&ds); +} + +static void +ka_unixctl_pmd_health_show(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *ka_info_) +{ + struct ds ds = DS_EMPTY_INITIALIZER; + ds_put_format(&ds, + "\n\t\tKeepalive status\n\n"); + + ds_put_format(&ds, "keepalive status : %s\n", + ka_is_enabled() ? "Enabled" : "Disabled"); + + if (!ka_is_enabled()) { + goto out; + } + + ds_put_format(&ds, "keepalive interval: %"PRIu32" ms\n", + get_ka_interval()); + + struct keepalive_info *ka_info = (struct keepalive_info *)ka_info_; + if (OVS_UNLIKELY(!ka_info)) { + goto out; + } + + ds_put_format(&ds, "PMD threads : %"PRIu32" \n", ka_info->pmd_cnt); + ds_put_format(&ds, + "\n PMD\tCORE\tSTATE\tLAST SEEN TIMESTAMP(UTC)\n"); + + struct ka_process_info *pinfo, *pinfo_next; + + ovs_mutex_lock(&ka_info->proclist_mutex); + HMAP_FOR_EACH_SAFE (pinfo, pinfo_next, node, &ka_info->process_list) { + char *state = NULL; + + if (pinfo->core_state == KA_STATE_UNUSED) { + continue; + } + + switch (pinfo->core_state) { + case KA_STATE_ALIVE: + state = "ALIVE"; + break; + case KA_STATE_MISSING: + state = "MISSING"; + break; + case KA_STATE_DEAD: + state = "DEAD"; + break; + case KA_STATE_GONE: + state = "GONE"; + break; + case KA_STATE_DOZING: + state = "DOZING"; + break; + case KA_STATE_SLEEP: + state = "SLEEP"; + break; + case KA_STATE_UNUSED: + break; + } + + char *utc = xastrftime_msec("%d %b %Y %H:%M:%S", + pinfo->core_last_seen_times, true); + + ds_put_format(&ds, "%s\t%2d\t%s\t%s\n", + pinfo->name, pinfo->core_id, state, utc); + + free(utc); + } + ovs_mutex_unlock(&ka_info->proclist_mutex); + + ds_put_format(&ds, "\n"); +out: + unixctl_command_reply(conn, ds_cstr(&ds)); + ds_destroy(&ds); +} + /* Dispatch heartbeats. */ void dispatch_heartbeats(void) @@ -412,6 +503,12 @@ ka_init(const struct smap *ovs_other_config) ka_init_status = ka_init_success; } + unixctl_command_register("keepalive/status", "", 0, 0, + ka_unixctl_status, NULL); + + unixctl_command_register("keepalive/pmd-health-show", "", 0, 0, + ka_unixctl_pmd_health_show, ka_info); + ovsthread_once_done(&once_enable); } }
This commit adds support to query keepalive status and statistics. $ ovs-appctl keepalive/status keepAlive Status: Enabled $ ovs-appctl keepalive/pmd-health-show Keepalive status keepalive status : Enabled keepalive interval: 1000 ms PMD threads : 4 PMD CORE STATE LAST SEEN TIMESTAMP(UTC) pmd62 0 ALIVE 21 Aug 2017 16:29:31 pmd63 1 ALIVE 21 Aug 2017 16:29:31 pmd64 2 ALIVE 21 Aug 2017 16:29:31 pmd65 3 GONE 21 Aug 2017 16:26:31 Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> --- lib/keepalive.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)