ngsdn-tutorial
ngsdn-tutorial copied to clipboard
how to fetch counters from the switch?
I've added certain counters to check packets in-out stats.
srv6_transit_table_counter
But I'm not able to fetch them using that util/gnmi-cli
command.
Can someone please let me know how can I fetch the newly added counters from switch,
util/gnmi-cli --grpc-addr localhost:50001 get /interfaces
P4 counters can be read using P4Runtime, not gNMI. Unfortunately in ONOS we don't have an API for reading indirect counters (yet). ONOS can read direct counters when periodically reading table entries, and displaythem as part of flow rule stats (onos> flows
command in the ONOS CLI).
I'm assuming you are dealing with indirect ones, I see two options:
- Hard: write an ONOS CLI command that uses the
P4RuntimeClient
class to read the counter of interest. You can see an example here. - Easy: use p4runtime-shell (in parallel with ONOS)
@ccascone Thanks for the response and the clarifying the problem I'm debugging on.
To elaborate more, I did the declaration of the counters as below:
direct_counter(CounterType.packets_and_bytes) ue_counter;
direct_counter(CounterType.packets_and_bytes) gtp_decap_counter;
The above declaration suggest these are direct counters. (I'm not sure about it as I have just started learning about the P4 and going through basic understandings).
onos> flows
is not showing these counters.
Apologies for the next questions but I'm not exactly getting what is the Easy: use p4runtime-shell (in parallel with ONOS)
means here.
I tried as below:
*** Connecting to P4Runtime server at localhost:50001 ...
You are not master, you only have read access to the server
*** Welcome to the IPython shell for P4Runtime ***
P4Runtime sh >>> for te in direct_counter_entry["gtp_decap_counter"].read():
...: print(te)
...:
---------------------------------------------------------------------------
P4RuntimeException Traceback (most recent call last)
<ipython-input-1-8dc7f7218aa1> in <module>
----> 1 for te in direct_counter_entry["gtp_decap_counter"].read():
2 print(te)
3
/p4runtime-sh/p4runtime_sh/p4runtime.py in handle(*args, **kwargs)
132 return f(*args, **kwargs)
133 except grpc.RpcError as e:
--> 134 raise P4RuntimeException(e) from None
135 return handle
136
P4RuntimeException: P4Runtime RPC error (UNIMPLEMENTED):
P4Runtime sh >>>
With the reference from the issue, P4RuntimeClient
also not showing the counters.
Can you please revert me what is wrong in this from below list ?
- Declaration of Direct counters
- Execution of P4Runtime