diff options
author | 2017-11-30 07:00:31 +0100 | |
---|---|---|
committer | 2018-03-16 19:16:02 +0000 | |
commit | ff92efe1074e338f91e59d9c27125d102516e7bf (patch) | |
tree | 8ab08f2ff0aa215b509dcf974102cc4a85f60895 /src/vpp | |
parent | ce8805c6a62893ec52a09c6acec48cce32c76706 (diff) |
stats: allow configuring poller delay
This introduces a startup config option for configuring stats poller delay.
Use `stats { interval <seconds> }` to configure the delay at startup.
The default value remains unchanged - 10 seconds.
Change-Id: If12cb1f7f6f1f8ecfa461561bc77847cdf260388
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vpp')
-rw-r--r-- | src/vpp/stats/stats.api | 22 | ||||
-rw-r--r-- | src/vpp/stats/stats.c | 79 |
2 files changed, 98 insertions, 3 deletions
diff --git a/src/vpp/stats/stats.api b/src/vpp/stats/stats.api index 2913d242d19..79816dbe83e 100644 --- a/src/vpp/stats/stats.api +++ b/src/vpp/stats/stats.api @@ -414,6 +414,28 @@ define vnet_get_summary_stats_reply f64 vector_rate; }; +/** \brief Get delay between polling statistics + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request +*/ +define stats_get_poller_delay +{ + u32 client_index; + u32 context; +}; + +/** \brief Get delay between polling statistics reply + @param context - sender context, to match reply w/ request + @param retval - return code for request + @param delay - poller delay +*/ +define stats_get_poller_delay_reply +{ + u32 context; + i32 retval; + u32 delay; +}; + /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vpp/stats/stats.c b/src/vpp/stats/stats.c index ef9f61bbf60..05950b6e5aa 100644 --- a/src/vpp/stats/stats.c +++ b/src/vpp/stats/stats.c @@ -62,7 +62,8 @@ _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \ _(WANT_IP4_NBR_STATS, want_ip4_nbr_stats) \ _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \ _(WANT_IP6_NBR_STATS, want_ip6_nbr_stats) \ -_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) +_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \ +_(STATS_GET_POLLER_DELAY, stats_get_poller_delay) #define vl_msg_name_crc_list @@ -2068,6 +2069,78 @@ again: vl_msg_api_free (mp); } +int +stats_set_poller_delay (u32 poller_delay_sec) +{ + stats_main_t *sm = &stats_main; + if (!poller_delay_sec) + { + return VNET_API_ERROR_INVALID_ARGUMENT; + } + else + { + sm->stats_poll_interval_in_seconds = poller_delay_sec; + return 0; + } +} + +static clib_error_t * +stats_config (vlib_main_t * vm, unformat_input_t * input) +{ + u32 sec; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "interval %u", &sec)) + { + int rv = stats_set_poller_delay (sec); + if (rv) + { + return clib_error_return (0, + "`stats_set_poller_delay' API call failed, rv=%d:%U", + (int) rv, format_vnet_api_errno, rv); + } + return 0; + } + else + { + return clib_error_return (0, "unknown input '%U'", + format_unformat_error, input); + } + } + return 0; +} + +/* stats { ... } configuration. */ +/*? + * + * @cfgcmd{interval, <seconds>} + * Configure stats poller delay to be @c seconds. + * +?*/ +VLIB_CONFIG_FUNCTION (stats_config, "stats"); + +static void + vl_api_stats_get_poller_delay_t_handler + (vl_api_stats_get_poller_delay_t * mp) +{ + stats_main_t *sm = &stats_main; + vl_api_registration_t *reg; + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + vl_api_stats_get_poller_delay_reply_t *rmp; + + rmp = vl_msg_api_alloc (sizeof (*rmp)); + rmp->_vl_msg_id = ntohs (VL_API_WANT_PER_INTERFACE_SIMPLE_STATS_REPLY); + rmp->context = mp->context; + rmp->retval = 0; + rmp->delay = clib_host_to_net_u32 (sm->stats_poll_interval_in_seconds); + + vl_api_send_msg (reg, (u8 *) rmp); + +} + static void stats_thread_fn (void *arg) { @@ -2090,8 +2163,8 @@ stats_thread_fn (void *arg) while (1) { - /* 10 second poll interval */ - ip46_fib_stats_delay (sm, 10 /* secs */ , 0 /* nsec */ ); + ip46_fib_stats_delay (sm, sm->stats_poll_interval_in_seconds, + 0 /* nsec */ ); if (!(sm->enable_poller)) { |