Counters

Retrieves the performance and interface counters from OPBNOS device.

Import OPBNOS API

from opbclient import opb_api as opbapi

Initialize client

Use the appropriate JSON file that corresponds to the targetted device name. This JSON file should contain request body parameters corresponding to any potential configuration/post requests.

node = opbapi.connect_to('SN2010')

Show Interface Counters

Retrieves available performance counter

node.execute(['show interface counters'])

Output

b'{"Ethernet1_1": {"IF_IN_OCTETS": 0, "IF_IN_UCAST_PKTS": 0, "IF_IN_NON_UCAST_PKTS": 0, "IF_IN_DISCARDS": 0, "IF_IN_ERRORS": 0, "IF_OUT_OCTETS": 0, "IF_OUT_UCAST_PKTS": 0, "IF_OUT_NON_UCAST_PKTS": 0, "IF_OUT_DISCARDS": 0, "IF_OUT_ERRORS": 0, "IF_IN_MULTICAST_PKTS": 0, "IF_OUT_MULTICAST_PKTS": 0}, "Ethernet2_1":{...}...}

Clear Interface Counters

In order to delete all interface counters, the API, configInterfacesCounters(), can be invoked with no paramters.

node.clearInterfaceCounters()

Get/Show Interface Counters - Ethernet specific

Retrieves Interface counter information as per the specified ethernet

node.execute(['show interface counters <Ethernet1_1>'])

Output

b'{"Ethernet1_1": {"IF_IN_OCTETS": 0, "IF_IN_UCAST_PKTS": 0, "IF_IN_NON_UCAST_PKTS": 0, "IF_IN_DISCARDS": 0, "IF_IN_ERRORS": 0, "IF_OUT_OCTETS": 0, "IF_OUT_UCAST_PKTS": 0, "IF_OUT_NON_UCAST_PKTS": 0, "IF_OUT_DISCARDS": 0, "IF_OUT_ERRORS": 0, "IF_IN_MULTICAST_PKTS": 0, "IF_OUT_MULTICAST_PKTS": 0}}

Show Flow Counters

Retrieves Interface counter information as per the specified flow and rule id. Flow and rule id must contain a space character between each other and the rule id needs to be in integer format.

node.execute(['show flow counters <flow1 1>'])

Output

Note: Client will receive the below error messege if flow has not been configured.

b'{"[ERROR]": "Flow not configured!"}'

Output

If flow has been previously configured (see here for flow configuration), the following is an example of an output:

b'{"map_name": "flow1","ASIC-Stat-Id": "27","rule_id": "1","Total-packets-mirrored": "0"}'

Clear Flow Counters

In order to clear opb flow counters, the API, clearFlowCounters(), can be invoked with no paramters.

node.clearFlowCounters(flow="flow1", r_id="1")

The below table lists and describes input attributes:

Attribute Values Description
"flow" "flow1" flow identification
"r_id" int rule id number
Note: Output of clear APIs

APIs will not produce any output unless the below status code in produced, indicating a server error.

Status : 500 -> Response : b'500'