open-switch / opx-cps

https://openswitch.net
6 stars 15 forks source link

Statistics values always return / show 0 #100

Closed nmmneves closed 5 years ago

nmmneves commented 6 years ago

Besides the timestamp, every value i try to retrieve regarding statistics returns 0 even in cases where i utilize other tools that clearly show that values change.

I also tried just checking values via the python commands detailed in the Readme file and they also do not work.

This is how i do it (tried with different OPX versions):

data = {'if/interfaces-state/interface/name': nameenc}

obj = cps_object.CPSObject(qual='observed',module='dell-base-if-cmn/if/interfaces-state/interface/statistics',data=data,)

response = []

if cps.get([obj.get()], response):
      for entry in response:
              octetsinbytes = entry["data"]["if/interfaces-state/interface/statistics/in-octets"]
              octetsoutbytes = entry["data"]["if/interfaces-state/interface/statistics/out-octets"]
rakeshdatta commented 5 years ago

Hi @nmmneves

It works for me. Please check my output below:

>>> import cps
>>> import cps_object
>>> import bytearray_utils as ba
>>>
>>> data = {'if/interfaces-state/interface/name': 'e101-003-1'}
>>> obj = cps_object.CPSObject(qual='observed',module='dell-base-if-cmn/if/interfaces-state/interface/statistics',data=data,)
>>>
>>> response = []
>>> if cps.get([obj.get()], response):
...       for entry in response:
...               octetsinbytes = entry["data"]["if/interfaces-state/interface/statistics/in-octets"]
...               octetsoutbytes = entry["data"]["if/interfaces-state/interface/statistics/out-octets"]
...
>>>
>>> print str(ba.from_ba(octetsinbytes, "uint64_t"))
20401
>>>
>>> print str(ba.from_ba(octetsoutbytes, "uint64_t"))
20316
>>>

Please make sure that your interface is up. Also, you can use 'opx-ethtool -S ' to ensure that statistics are displayed correctly. If both of these conditions satisfy, then above code should work. Plz let me know if you have any further queries.

Thanks, Rakesh.

nmmneves commented 5 years ago

Hi @rakeshdatta

I tried the piece of code you just gave me but did not work also. I am sure that the interface is up but the command 'opx-ethtool -S e101-001-0' ( where e101-001-0 is the interface that is up) returns :

Interface not valid :e101-001-0

I have no idea whats the problem that is happening.

jeff-yin commented 5 years ago

@nmmneves -- these may be silly questions, but just to make sure... (1) Is the interface fanned out? (e.g., 40G port fanned out to 4x 10G) (if so, then the first interface would be e101-001-1). (2) Or is this being run too soon after reboot? The interface may not yet be installed because the NPU will take another minute or so to initialize. (3) Have you tried running the command as root? (4) Does the interface show up for the ifconfig command? (also try as root)

rakeshdatta commented 5 years ago

@nmmneves As Jeff asked earlier, please verify that the interface is indeed UP. It is not for some reason, and that's why opx-ethtool is not working on that interface. Please show us the 'ifconfig e101-001-1' output along with other details that Jeff asked in the previous post.

Also, can you please let me know which platform it is?

nmmneves commented 5 years ago

I think i checked everything that Jeff suggested. In OPX 2.1.0 i get the following:

e101-001-0 Link encap:Ethernet  HWaddr 00:0c:29:db:d0:9b
          inet addr:10.1.1.1  Bcast:0.0.0.0  Mask:255.255.255.255
          inet6 addr: fe80::20c:29ff:fedb:d09b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:46 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8263 (8.0 KiB)  TX bytes:9326 (9.1 KiB)

and

opxUser@opx_vm:~$ sudo opx-ethtool -S e101-001-0
Statistics for interface e101-001-0

Ether statistics:

    rx_bytes: 0
    tx_bytes: 0
    rx_no_errors: 0
    tx_no_errors: 0
    tx_total_collision: 0
    rx_undersize_packets: 0
    rx_jabbers: 0
    rx_fragments: 0
    rx_discards: 0
    rx_mcast_packets: 0
    rx_bcast_packets: 0
    rx_oversize_packets: 0
    tx_oversize_packets: 0
    rx_64_byte_packets: 0
    rx_65_to_127_byte_packets: 0
    rx_128_to_255_byte_packets: 0
    rx_256_to_511_byte_packets: 0
    rx_512_to_1023_byte_packets: 0
    rx_1024_to_1518_byte_packets: 0
    rx_1519_to_2047_byte_packets: 0
    rx_2048_to_4095_byte_packets: 0
    rx_4096_to_9216_byte_packets: 0
    tx_64_byte_packets: 0
    tx_65_to_127_byte_packets: 0
    tx_128_to_255_byte_packets: 0
    tx_256_to_511_byte_packets: 0
    tx_512_to_1023_byte_packets: 0
    tx_1024_to_1518_byte_packets: 0
    tx_1519_to_2047_byte_packets: 0
    tx_2048_to_4095_byte_packets: 0
    tx_4096_to_9216_byte_packets: 0
    crc_align_errors: 0
    buffer-overrun errors:  0

in OPX 3.0

e101-001-0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.1.1  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 fe80::20c:29ff:fe82:a89e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:82:a8:9e  txqueuelen 1000  (Ethernet)
        RX packets 25  bytes 2626 (2.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1186 (1.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

and sudo opx-ethtool -S return invalid interface.

rakeshdatta commented 5 years ago

Hi @nmmneves,

So it is pretty clear that the primary problem is that the interface is not coming up. Also, it is not able to fetch the data from NPU. Let's fix that first.

Can you please provide the below info: 1) Which platform are you using? 2) What is the remote end of the connectivity through the given interface? 3) What kind of interface is it? 4) Please share the below outputs at both the boxes that are connected though this interface.

rakeshdatta commented 5 years ago

Hi @nmmneves Plz share the information asked, for us to be able to help you.

Thanks, Rakesh Datta.

rakeshdatta commented 5 years ago

Hi @nmmneves
Seems like either the issue is fixed or it's not in your priority list for now. Therefore, am closing it. In case you do face the issue further, please let us know the information asked above and we can take a look at it again.

Thanks, Rakesh