diff --git a/scripts/watermarkstat b/scripts/watermarkstat index ffcec56fa9..9e953165cf 100755 --- a/scripts/watermarkstat +++ b/scripts/watermarkstat @@ -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): + 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): """