diff --git a/collections/inv.capabilities/Huawei/OID/hwCBQoSPolicyStatisticsClassifierTable.json b/collections/inv.capabilities/Huawei/OID/hwCBQoSPolicyStatisticsClassifierTable.json new file mode 100644 index 0000000000000000000000000000000000000000..ecb5f9a688746b0a83ed6d9f498541f10702ccef --- /dev/null +++ b/collections/inv.capabilities/Huawei/OID/hwCBQoSPolicyStatisticsClassifierTable.json @@ -0,0 +1,8 @@ +{ + "name": "Huawei | OID | hwCBQoSPolicyStatisticsClassifierTable", + "$collection": "inv.capabilities", + "uuid": "2384f9fa-a34c-44e7-9c99-0ddcd0fd4e26", + "description": "Supported CBQoS stat on hwCBQoSPolicyStatisticsClassifierTable OIDs", + "type": "bool", + "card_template": null +} diff --git a/sa/profiles/Huawei/VRP/get_capabilities.py b/sa/profiles/Huawei/VRP/get_capabilities.py index af050655fa6b3a1fbc439e90831f5b386dd47947..c6c5b9b20a9d1cef1d5f834a49f829a8d7a73543 100644 --- a/sa/profiles/Huawei/VRP/get_capabilities.py +++ b/sa/profiles/Huawei/VRP/get_capabilities.py @@ -22,6 +22,9 @@ class Script(BaseScript): "Huawei | OID | hwCBQoSClassifierStatisticsTable": mib[ "HUAWEI-CBQOS-MIB::hwCBQoSClassifierMatchedPackets" ], + "Huawei | OID | hwCBQoSPolicyStatisticsClassifierTable": mib[ + "HUAWEI-CBQOS-MIB::hwCBQoSPolicyStatClassifierMatchedPassPackets" + ], } CHECK_SNMP_GET = { diff --git a/sa/profiles/Huawei/VRP/get_metrics.py b/sa/profiles/Huawei/VRP/get_metrics.py index 4f00ac2aadf554602dc46c25c0b7f2246f5c5486..59d8b242ffa2b732b9072cd50d9a7c66d3baf942 100644 --- a/sa/profiles/Huawei/VRP/get_metrics.py +++ b/sa/profiles/Huawei/VRP/get_metrics.py @@ -68,16 +68,27 @@ class Script(GetMetricsScript): [ "Interface | CBQOS | Drops | In | Delta", "Interface | CBQOS | Drops | Out | Delta", - "Interface | CBQOS | Octets | In", "Interface | CBQOS | Octets | In | Delta", - "Interface | CBQOS | Octets | Out", "Interface | CBQOS | Octets | Out | Delta", + "Interface | CBQOS | Packets | In | Delta", + "Interface | CBQOS | Packets | Out | Delta", ], volatile=False, - has_capability="Huawei | OID | hwCBQoSClassifierStatisticsTable", access="S", # CLI version ) def get_interface_cbqos_metrics_snmp(self, metrics): + """ + Use available SNMP Table for collecting value + :param metrics: + :return: + """ + if self.has_capability("Huawei | OID | hwCBQoSPolicyStatisticsClassifierTable"): + self.get_interface_cbqos_metrics_policy_snmp(metrics) + elif self.has_capability("Huawei | OID | hwCBQoSClassifierStatisticsTable"): + self.get_interface_cbqos_metrics_classifier_snmp(metrics) + + def get_interface_cbqos_metrics_classifier_snmp(self, metrics): + self.logger.debug("Use hwCBQoSClassifierStatisticsTable for collected metrics") ifaces = {m.ifindex: m.labels for m in metrics if m.ifindex} direction_map = {1: "In", 2: "Out"} class_map = {} @@ -97,9 +108,9 @@ class Script(GetMetricsScript): for metric, value in [ (f"Interface | CBQOS | Drops | {direction_map[direction]} | Delta", discards), (f"Interface | CBQOS | Octets | {direction_map[direction]} | Delta", bytes), - (f"Interface | CBQOS | Octets | {direction_map[direction]}", bytes), + # (f"Interface | CBQOS | Octets | {direction_map[direction]}", bytes), (f"Interface | CBQOS | Packets | {direction_map[direction]} | Delta", packets), - (f"Interface | CBQOS | Packets | {direction_map[direction]}", packets), + # (f"Interface | CBQOS | Packets | {direction_map[direction]}", packets), ]: scale = 1 self.set_metric( @@ -113,6 +124,46 @@ class Script(GetMetricsScript): scale=scale, ) + def get_interface_cbqos_metrics_policy_snmp(self, metrics): + self.logger.debug("Use hwCBQoSPolicyStatisticsClassifierTable for collected metrics") + ifaces = {m.ifindex: m.labels for m in metrics if m.ifindex} + direction_map = {"1": "In", "2": "Out"} + for index, packets, bytes, discards in self.snmp.get_tables( + [ + mib["HUAWEI-CBQOS-MIB::hwCBQoSPolicyStatClassifierMatchedPassPackets"], + mib["HUAWEI-CBQOS-MIB::hwCBQoSPolicyStatClassifierMatchedPassBytes"], + mib["HUAWEI-CBQOS-MIB::hwCBQoSPolicyStatClassifierMatchedDropPackets"], + ] + ): + ifindex, ifvlanid1, direction, classifier = index.split(".", 3) + ifindex = int(ifindex) + if not ifindex or ifindex not in ifaces: + self.logger.info("Interface Vlan %s not collected", ifvlanid1) + # Interface vlan + continue + traffic_class = "".join(chr(int(c)) for c in classifier.split(".")[1:]) + ts = self.get_ts() + for metric, value in [ + (f"Interface | CBQOS | Drops | {direction_map[direction]} | Delta", discards), + (f"Interface | CBQOS | Octets | {direction_map[direction]} | Delta", bytes), + # (f"Interface | CBQOS | Load | {direction_map[direction]}", bytes), + (f"Interface | CBQOS | Packets | {direction_map[direction]} | Delta", packets), + # (f"Interface | CBQOS | Packets | {direction_map[direction]}", packets), + ]: + mtype, scale = "gauge", 1 + if metric.endswith("Delta"): + mtype = "delta" + self.set_metric( + id=(metric, ifaces[ifindex]), + metric=metric, + value=float(value), + ts=ts, + labels=ifaces[ifindex] + [f"noc::traffic_class::{traffic_class}"], + multi=True, + type=mtype, + scale=scale, + ) + # @metrics( # ["Interface | Errors | CRC", "Interface | Errors | Frame"], # has_capability="DB | Interfaces",