diff options
author | Ole Troan <ot@cisco.com> | 2021-03-18 11:12:01 +0100 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2021-03-25 08:37:46 +0000 |
commit | e66443c9b411368bf856b74580d19144bb28d236 (patch) | |
tree | 31ff82339f26a53737b242437ecfbfe593fd0389 /test/vpp_interface.py | |
parent | fd243741e09d579743148432c136c06d92b36647 (diff) |
stats: python vpp_stats rewrite to access stat segment directly
This module implement Python access to the VPP statistics segment. It
accesses the data structures directly in shared memory.
VPP uses optimistic locking, so data structures may change underneath
us while we are reading. Data is copied out and it's important to
spend as little time as possible "holding the lock".
Counters are stored in VPP as a two dimensional array.
Index by thread and index (typically sw_if_index).
Simple counters count only packets, Combined counters count packets
and octets.
Counters can be accessed in either dimension.
stat['/if/rx'] - returns 2D lists
stat['/if/rx'][0] - returns counters for all interfaces for thread 0
stat['/if/rx'][0][1] - returns counter for interface 1 on thread 0
stat['/if/rx'][0][1]['packets'] - returns the packet counter
for interface 1 on thread 0
stat['/if/rx'][:, 1] - returns the counters for interface 1 on all threads
stat['/if/rx'][:, 1].packets() - returns the packet counters for
interface 1 on all threads
stat['/if/rx'][:, 1].sum_packets() - returns the sum of packet counters for
interface 1 on all threads
stat['/if/rx-miss'][:, 1].sum() - returns the sum of packet counters for
interface 1 on all threads for simple counters
Type: refactor
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I1fe7f7c7d11378d06be8276db5e1900ecdb8f515
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test/vpp_interface.py')
-rw-r--r-- | test/vpp_interface.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/vpp_interface.py b/test/vpp_interface.py index 7eb586c010c..b7c830b06fd 100644 --- a/test/vpp_interface.py +++ b/test/vpp_interface.py @@ -478,12 +478,12 @@ class VppInterface(metaclass=abc.ABCMeta): return self.name def get_rx_stats(self): - c = self.test.statistics.get_counter("^/if/rx$") - return c[0][self.sw_if_index] + return (self.test.statistics["/if/rx"] + [:, self.sw_if_index].sum_packets()) def get_tx_stats(self): - c = self.test.statistics.get_counter("^/if/tx$") - return c[0][self.sw_if_index] + return (self.test.statistics["/if/tx"] + [:, self.sw_if_index].sum_packets()) def set_l3_mtu(self, mtu): self.test.vapi.sw_interface_set_mtu(self.sw_if_index, [mtu, 0, 0, 0]) |