Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix watermarkstat CLI script for unconfigured PG counters #2220

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,22 @@ 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)]
min_idx_found = False
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
if (not min_idx_found):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dprital imho, need to revisit this part of code. Not sure whether we need it.

self.min_idx = element_idx
min_idx_found = True
if (self.min_idx > element_idx):
self.min_idx = element_idx

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

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