From patchwork Wed Jun 7 16:15:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 772515 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wjYwR3vdYz9s7m for ; Thu, 8 Jun 2017 02:31:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C5249C44; Wed, 7 Jun 2017 16:24:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 75E4EC43 for ; Wed, 7 Jun 2017 16:24:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0496117D for ; Wed, 7 Jun 2017 16:24:40 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2017 09:24:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,311,1493708400"; d="scan'208";a="271374256" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by fmsmga004.fm.intel.com with ESMTP; 07 Jun 2017 09:24:10 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Wed, 7 Jun 2017 17:15:08 +0100 Message-Id: <1496852117-71097-13-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1496852117-71097-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1496852117-71097-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [RFC PATCH 12/21] keepalive: Add support to query keepalive statistics. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This commit adds support to query keepalive statistics stored in posix shared memory block. Datapath health status can be retrieved as follows: $ ovs-appctl keepalive/pmd-health-show Keepalive status keepalive status : Enabled keepalive interval: 1000 ms CORE STATE LAST SEEN TIMESTAMP 0 ALIVE 8632183482028293 1 ALIVE 8632183482028425 2 ALIVE 8632190191004294 3 ALIVE 8632183482028525 4 GONE 8612183482028117 5 ALIVE 8632190191004984 6 ALIVE 8632190191005713 7 ALIVE 8632190191006555 Datapath status : BAD Signed-off-by: Bhanuprakash Bodireddy --- lib/keepalive.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/lib/keepalive.c b/lib/keepalive.c index acb4dd2..3048527 100644 --- a/lib/keepalive.c +++ b/lib/keepalive.c @@ -24,8 +24,10 @@ #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 "unixctl.h" VLOG_DEFINE_THIS_MODULE(keepalive); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); @@ -271,6 +273,71 @@ 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_shm_) +{ + struct keepalive_shm *ka_shm = (struct keepalive_shm *)ka_shm_; + if (!ka_shm) { + VLOG_ERR_RL(&rl, "KeepAlive: Invalid shared memory block\n"); + return; + } + + struct ds ds = DS_EMPTY_INITIALIZER; + ds_put_format(&ds, + "\t\tKeepalive status\n"); + + ds_put_format(&ds, "keepalive status : %s\n", + is_ka_enabled() ? "Enabled" : "Disabled"); + ds_put_format(&ds, "keepalive interval: %"PRIu32" ms\n", + get_ka_interval()); + ds_put_format(&ds, + "\nCORE\tSTATE\tLAST SEEN TIMESTAMP\n"); + + int datapath_failure = 0; + for (int idx_core = 0; idx_core < KEEPALIVE_MAXCORES; idx_core++) { + char *state = NULL; + if (ka_shm->core_state[idx_core] == KA_STATE_UNUSED || + ka_shm->core_state[idx_core] == KA_STATE_SLEEP) + continue; + + switch (ka_shm->core_state[idx_core]) { + 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"; + datapath_failure++; + 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, "%2d\t%s\t%"PRIu64"\n", + idx_core, state, ka_shm->core_last_seen_times[idx_core]); + } + + ds_put_format(&ds, "\n"); + ds_put_format(&ds, "Datapath Status : %s\n", + datapath_failure ? "BAD" : "HEALTHY"); + + unixctl_command_reply(conn, ds_cstr(&ds)); +} + static int ka_init__(void) { @@ -306,6 +373,9 @@ ka_init(const struct smap *ovs_other_config) VLOG_INFO("OvS Keepalive - initialized."); ka_init_status = ka_init_success; } + + unixctl_command_register("keepalive/pmd-health-show", "", 0, 0, + ka_unixctl_pmd_health_show, ka_shm); } else { VLOG_ERR("keepalive_shm_create() failed."); }