Verified Commit 99b5bc66 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Additional metrics to interface queue.

parent 1b928a66
Pipeline #30297 passed with stages
in 16 minutes and 17 seconds
{
"name": "Metrics | QOS | Statistics",
"$collection": "inv.capabilities",
"uuid": "000d287c-4206-457c-80b2-8c9c5848e6f5",
"description": "QoS interface metrics is enable",
"type": "bool",
"card_template": null
}
{
"name": "Interface | QOS | Discards | In | Delta",
"$collection": "pm.metrictypes",
"uuid": "33079364-1e2d-4f6b-93a8-d11bf8af6f80",
"scope__name": "Interface",
"field_name": "qos_discards_in_delta",
"field_type": "UInt64",
"description": "Discards packet on input queue (delta)",
"measure": "packets"
}
{
"name": "Interface | QOS | Discards | Out | Delta",
"$collection": "pm.metrictypes",
"uuid": "2bb55d67-dfba-48a0-b646-6abaea47b711",
"scope__name": "Interface",
"field_name": "qos_discards_out_delta",
"field_type": "UInt64",
"description": "Discards packet on output queue (delta)",
"measure": "packets"
}
{
"name": "Interface | QOS | Octets | In",
"$collection": "pm.metrictypes",
"uuid": "08d33a7b-8227-41b0-a42e-c6860ff83460",
"scope__name": "Interface",
"field_name": "qos_octets_in",
"field_type": "UInt64",
"description": "The total number of received octets passed by the interface queue.",
"measure": "bytes"
}
{
"name": "Interface | QOS | Octets | Out",
"$collection": "pm.metrictypes",
"uuid": "b871d72f-0b94-40ae-a99d-fbfd4aab144a",
"scope__name": "Interface",
"field_name": "qos_octets_out",
"field_type": "UInt64",
"description": "The total number of transmitted out octets passed by the interface queue.",
"measure": "bytes"
}
{
"name": "Interface | QOS | Packets | In",
"$collection": "pm.metrictypes",
"uuid": "bd3590c9-b250-4c06-93e7-feacf0f82975",
"scope__name": "Interface",
"field_name": "qos_packets_in",
"field_type": "UInt64",
"description": "Packets on input interface queue",
"measure": "packet/s"
}
{
"name": "Interface | QOS | Packets | Out",
"$collection": "pm.metrictypes",
"uuid": "1baa32d0-c1c1-4e09-b2b8-cbe08b6c9806",
"scope__name": "Interface",
"field_name": "qos_packets_out",
"field_type": "UInt64",
"description": "Packets on output interface queue",
"measure": "packet/s"
}
......@@ -117,14 +117,29 @@ class Script(BaseScript):
r += [str(stack_num)]
return r
@false_on_snmp_error
def has_qos_interface_stats(self):
# eltCountersQosStatisticsEnable
# On config enabled by 'qos statistics interface'
r = self.snmp.get("1.3.6.1.4.1.35265.1.23.1.8.1.1.2.1.0")
if r == 1:
# qos statistics interface
return True
def execute_platform_cli(self, caps):
s = self.has_stack()
if s:
caps["Stack | Members"] = len(s) if len(s) >= 1 else 0
caps["Stack | Member Ids"] = " | ".join(s)
s = self.has_qos_interface_stats()
if s:
caps["Metrics | QOS | Statistics"] = True
def execute_platform_snmp(self, caps):
s = self.has_stack_snmp()
if s:
caps["Stack | Members"] = len(s) if len(s) >= 1 else 0
caps["Stack | Member Ids"] = " | ".join(s)
s = self.has_qos_interface_stats()
if s:
caps["Metrics | QOS | Statistics"] = True
......@@ -5,32 +5,62 @@
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from noc.sa.profiles.Generic.get_metrics import Script as GetMetricsScript, metrics
# Python Modules
from typing import List
# NOC Modules
from noc.sa.profiles.Generic.get_metrics import Script as GetMetricsScript, metrics, MetricConfig
class Script(GetMetricsScript):
name = "Eltex.MES.get_metrics"
QOS_OIDS_MAP = {
# oid, type, scale
"Interface | QOS | Discards | Out | Delta": (5, "delta", 1),
"Interface | QOS | Octets | Out": (6, "counter", 8),
"Interface | QOS | Packets | Out": (7, "counter", 1),
}
BASE_OID = "1.3.6.1.4.1.35265.1.23.1.8.1.2.1.1.1."
@metrics(
["Interface | Tail_Drop"],
has_capability="SNMP | Bulk",
matcher="is_3124",
volatile=False,
[
"Interface | QOS | Discards | Out | Delta",
"Interface | QOS | Octets | Out",
"Interface | QOS | Packets | Out",
],
has_capability="Metrics | QOS | Statistics",
volatile=True,
access="S",
)
def get_tail_drop_snmp(self, metrics):
# iso.3.6.1.4.1.35265.1.23.1.8.1.2.1.1.1.5.{ifindex}.{queue}.0
names = {x: y for y, x in self.scripts.get_ifindexes().items()}
for oid, v in self.snmp.getnext("1.3.6.1.4.1.35265.1.23.1.8.1.2.1.1.1.5", bulk=False):
oid2 = oid.split("1.3.6.1.4.1.35265.1.23.1.8.1.2.1.1.1.5.")
ifindex = oid2[1].split(".")
if ifindex[2] == "0":
iface_name = names[int(ifindex[0])]
queue = int(ifindex[1])
self.set_metric(
id=("Interface | Tail_Drop", None),
path=["", "", queue, iface_name],
value=int(v),
multi=True,
)
def get_interface_qos_discards(self, metrics: List["MetricConfig"]):
oids = {}
for mc in metrics:
if not mc.ifindex:
continue
for q in range(1, 8):
oids[
f"1.3.6.1.4.1.35265.1.23.1.8.1.2.1.1.1.{self.QOS_OIDS_MAP[mc.metric][0]}.{mc.ifindex}.{q}.0"
] = (mc, list(mc.path) + [str(q), "0"])
results = self.snmp.get_chunked(
oids=list(oids),
chunk_size=self.get_snmp_metrics_get_chunk(),
timeout_limits=self.get_snmp_metrics_get_timeout(),
)
ts = self.get_ts()
for r in results:
if not results[r]:
continue
mc, path = oids[r]
_, mtype, scale = self.QOS_OIDS_MAP[mc.metric]
self.set_metric(
id=(mc.metric, mc.path),
metric=mc.metric,
value=float(results[r]),
ts=ts,
path=path,
multi=True,
type=mtype,
scale=scale,
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment