Hi there,

As of 17.10 you can now register for statistics on a per interface level.

You need the sw_if_index of the interface you want stats for, but the calls
are in
https://git.fd.io/vpp/tree/src/vpp/stats/stats.api

but as an example:
Register:

autoreply define want_per_interface_simple_stats
{
  u32 client_index;
  u32 context;
  u32 enable_disable;
  u32 pid;
  u32 num;
  u32 sw_ifs[num];

};


So calling "want_per_interface_simple_stats" with enable_disable=1,
num=1 and sw_ifs[4] will give you

interface_simple_stats every 10sec for sw_if_index=4.


The content of "interface_simple_stats" looks like:


/** \brief Simple per interface stats counters structure
    @param count - number of elements in message
    @param timestamp - u32 vlib timestamp for control plane
    @param data[count] - vl_api_vnet_simple_counter_t

*/
manual_print manual_endian define vnet_per_interface_simple_counters
{
  u32 count;
  u32 timestamp;
  vl_api_vnet_simple_counter_t data[count];
};


Where each "vnet_simple_counter_t" looks like:


https://git.fd.io/vpp/tree/src/vnet/interface.api

/** \brief Simple interface counter data type for vnet_interface_simple_counters
    @param sw_if_index - interface indexes for counters
    @param drop - RX or TX drops due to buffer starvation
    @param punt - used with VNET "punt" disposition
    @param rx_ip4 - received IP4 packets
    @param rx_ip6 - received IP6 packets
    @param rx_no_buffer - no RX buffers available
    @param rx_miss - receive misses
    @param rx_error - receive errors
    @param tx_error - transmit errors
    @param rx_mpls - received MPLS packet

*/
typeonly manual_print manual_endian define vnet_simple_counter
{
  u32 sw_if_index;
  u64 drop;
  u64 punt;
  u64 rx_ip4;
  u64 rx_ip6;
  u64 rx_no_buffer;
  u64 rx_miss;
  u64 rx_error;
  u64 tx_error;
  u64 rx_mpls;
};


So you will get back an array of counter structs for each sw_if_index
you registered for.


At the moment the impl sends on sw_if_index per reply but that is
going to change so that for each client we send as much in one message
as possible.





On Tue, Sep 26, 2017 at 4:50 AM 重新开始 <15803846...@qq.com> wrote:

> Hi,  everyone!
> How to get interface stats using C api?
> For example, I want to know "GigabitEthernete/0/1" rx packets , what should I 
> do?
>
> Thanks
>
> _______________________________________________
> vpp-dev mailing list
> vpp-dev@lists.fd.io
> https://lists.fd.io/mailman/listinfo/vpp-dev
_______________________________________________
vpp-dev mailing list
vpp-dev@lists.fd.io
https://lists.fd.io/mailman/listinfo/vpp-dev
  • [vpp-dev] How... ????????
    • Re: [vpp... Keith Burns
      • [vpp... ????????
        • ... Keith Burns
          • ... ????????
            • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
              • ... ????????
                • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
                • ... ????????
                • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
          • ... Jon Loeliger

Reply via email to