cli: pretty print existing Ethernet frame stats

Pretty print all Ethernet frame statistics from the operational
datastore. Only in the detailed interface view.

Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
Richard Alpe
2023-10-17 18:17:59 +02:00
committed by Joachim Wiberg
parent 14dc3cf8a0
commit 1a3105c06d
2 changed files with 40 additions and 0 deletions
+17
View File
@@ -32,6 +32,16 @@ class Decore():
return Decore.decorate("32", txt, "39")
class Iface:
def get_json_data(self, default, *args):
data = self.data
for arg in args:
if data.get(arg):
data = data.get(arg)
else:
return default
return data
def __init__(self, data):
self.data = data
self.name = data.get('name', '')
@@ -181,6 +191,13 @@ class Iface:
print(f"{'in-octets':<{20}}: {self.in_octets}")
print(f"{'out-octets':<{20}}: {self.out_octets}")
frame = self.get_json_data([], 'ieee802-ethernet-interface:ethernet',
'statistics', 'frame')
if frame:
print(f"")
for key, val in frame.items():
print(f"eth-{key:<{16}}: {val}")
def find_iface(_ifaces, name):
for _iface in [Iface(data) for data in _ifaces]:
+23
View File
@@ -189,6 +189,29 @@
]
}
},
{
"TEST-DESCR": "Interface ieee802-ethernet-interface stats",
"name": "e13",
"type": "infix-if-type:ethernet",
"oper-status": "up",
"if-index": 4,
"phys-address": "02:ee:00:00:12:00",
"statistics": {
"in-octets": "11",
"out-octets": "22"
},
"ieee802-ethernet-interface:ethernet": {
"statistics": {
"frame": {
"in-frames": "1111",
"out-frames": "2222"
}
}
},
"ietf-ip:ipv4": {
"mtu": 1500
}
},
{
"TEST-DESCR": "Interface with VLAN on top",
"name": "e20",