Skip to content

Commit

Permalink
Fix watermarkstat CLI script.
Browse files Browse the repository at this point in the history
Since PG/Queue counters are created only if they are configured in the switch, it is not enough to relay only on the first entry in the DB.
We need to go over all configured counters, check what is the max configured, and build the table accordingly.

Signed-off-by: Shlomi Bitton <shlomibi@nvidia.com>
  • Loading branch information
Shlomi Bitton committed Jun 14, 2022
1 parent 29503ab commit 409da5f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ class Watermarkstat(object):

self.header_list = ['Port']
header_map = wm_type["obj_map"]
single_key = list(header_map.keys())[0]
header_len = len(header_map[single_key])
min_idx = sys.maxsize

for name, counter_oid in header_map[single_key].items():
curr_idx = int(wm_type["idx_func"](counter_oid))
min_idx = min(min_idx, curr_idx)

self.min_idx = min_idx
self.header_list += ["{}{}".format(wm_type["header_prefix"], idx) for idx in range(self.min_idx, self.min_idx + header_len)]
self.min_idx = 0
max_idx = 0
for port in header_map.keys():
for element in header_map[port].keys():
element_idx = int(element.split(':')[1])
if (element_idx > max_idx):
max_idx = element_idx

self.header_list += ["{}{}".format(wm_type["header_prefix"], idx) for idx in range(self.min_idx, max_idx)]

def get_counters(self, table_prefix, port_obj, idx_func, watermark):
"""
Expand Down

0 comments on commit 409da5f

Please sign in to comment.