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

[watermarkstat] Fix CLI script for unconfigured PG counters #2239

Merged
merged 1 commit into from
Jul 28, 2022
Merged
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
21 changes: 14 additions & 7 deletions scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,23 @@ 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)
max_idx = 0
min_idx = sys.maxsize
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 min_idx > element_idx:
min_idx = element_idx

if min_idx == sys.maxsize:
print("Object map is empty!", file=sys.stderr)
sys.exit(1)

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.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