[ovs-dev] [PATCH 12/20] keepalive: Add support to query keepalive statistics.

Bhanuprakash Bodireddy bhanuprakash.bodireddy at intel.com
Mon Jul 3 20:27:25 UTC 2017


This commit adds support to query keepalive statistics. Datapath health
status can be retrieved as follows:

  $ ovs-appctl keepalive/pmd-health-show

          Keepalive status

    keepalive status  : Enabled
    keepalive interval: 1000 ms
    PMD threads       : 8

     PMD    CORE    STATE   LAST SEEN TIMESTAMP
    pmd62    0      ALIVE   8632183482028293
    pmd63    1      ALIVE   8632183482028425
    pmd64    2      ALIVE   8632190191004294
    pmd65    3      ALIVE   8632183482028525
    pmd66    4      GONE    8612183482028117
    pmd67    5      ALIVE   8632190191004984
    pmd68    6      ALIVE   8632190191005713
    pmd69    7      ALIVE   8632190191006555

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
---
 lib/keepalive.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/lib/keepalive.c b/lib/keepalive.c
index db5a2dc..ce03e52 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -24,9 +24,11 @@
 #include "dpdk.h"
 #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 "unixctl.h"
 
 VLOG_DEFINE_THIS_MODULE(keepalive);
 
@@ -355,6 +357,79 @@ ka_stats_run(void)
     return ka_stats;
 }
 
+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\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 ||
+              pinfo->core_state == KA_STATE_SLEEP)
+            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_CHECK:
+            state = "HEALTH_CHECK_RUNNING";
+            break;
+        case KA_STATE_UNUSED:
+            break;
+        }
+        ds_put_format(&ds, "%s\t%2d\t%s\t%"PRIu64"\n",
+                      pinfo->name, pinfo->core_id, state,
+                      pinfo->core_last_seen_times);
+    }
+    ovs_mutex_unlock(&ka_info->proclist_mutex);
+
+    ds_put_format(&ds, "\n");
+out:
+    unixctl_command_reply(conn, ds_cstr(&ds));
+    ds_destroy(&ds);
+}
+
 static int
 ka_init__(void)
 {
@@ -397,6 +472,9 @@ ka_init(const struct smap *ovs_other_config)
             }
         }
 
+        unixctl_command_register("keepalive/pmd-health-show", "", 0, 0,
+                                  ka_unixctl_pmd_health_show, ka_info);
+
         ovsthread_once_done(&once_enable);
     }
 }
-- 
2.4.11



More information about the dev mailing list