Skip to content

Commit

Permalink
Updated the the fix for pfc/queue counters also.
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi committed Oct 19, 2020
1 parent ba00bdf commit 5bb9a2d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
12 changes: 1 addition & 11 deletions scripts/pfcstat
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ from natsort import natsorted
from tabulate import tabulate

from sonic_py_common.multi_asic import get_external_ports
from utilities_common.netstat import ns_diff, STATUS_NA
from utilities_common import multi_asic as multi_asic_util
from utilities_common import constants

Expand Down Expand Up @@ -63,7 +64,6 @@ counter_bucket_tx_dict = {
'SAI_PORT_STAT_PFC_7_TX_PKTS': 7
}

STATUS_NA = 'N/A'

COUNTER_TABLE_PREFIX = "COUNTERS:"
COUNTERS_PORT_NAME_MAP = "COUNTERS_PORT_NAME_MAP"
Expand Down Expand Up @@ -155,16 +155,6 @@ class Pfcstat(object):
"""
Print the difference between two cnstat results.
"""
def ns_diff(newstr, oldstr):
"""
Calculate the diff.
"""
if newstr == STATUS_NA or oldstr == STATUS_NA:
return STATUS_NA
else:
new, old = int(newstr), int(oldstr)
return '{:,}'.format(new - old)

table = []

for key, cntr in cnstat_new_dict.iteritems():
Expand Down
3 changes: 1 addition & 2 deletions scripts/portstat
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ class Portstat(object):
"""
# Get speed from APPL_DB
full_table_id = PORT_STATUS_TABLE_PREFIX + port_name
speed = PORT_RATE
for ns in self.multi_asic.get_ns_list_based_on_options():
self.db = multi_asic.connect_to_all_dbs_for_ns(ns)
speed = self.db.get(self.db.APPL_DB, full_table_id, PORT_SPEED_FIELD)
if speed is not None:
return int(speed)//1000
return speed
return PORT_RATE

def get_port_state(self, port_name):
"""
Expand Down
13 changes: 1 addition & 12 deletions scripts/queuestat
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ counter_bucket_dict = {
'SAI_QUEUE_STAT_DROPPED_BYTES': 5,
}

STATUS_NA = 'N/A'
STATUS_INVALID = 'INVALID'
from utilities_common.netstat import ns_diff, STATUS_NA

QUEUE_TYPE_MC = 'MC'
QUEUE_TYPE_UC = 'UC'
Expand Down Expand Up @@ -158,16 +157,6 @@ class Queuestat(object):
"""
Print the difference between two cnstat results.
"""
def ns_diff(newstr, oldstr):
"""
Calculate the diff.
"""
if newstr == STATUS_NA or oldstr == STATUS_NA:
return STATUS_NA
else:
new, old = int(newstr), int(oldstr)
return '{:,}'.format(new - old)

table = []

for key, cntr in cnstat_new_dict.iteritems():
Expand Down

0 comments on commit 5bb9a2d

Please sign in to comment.