@@ -415,7 +415,7 @@ def inventory_unifi_device(section):
415
415
416
416
############ DEVICEPORT ###########
417
417
@dataclass
418
- class unifi_interface (interfaces .Interface ):
418
+ class unifi_interface (interfaces .InterfaceWithCounters ):
419
419
jumbo : bool = False
420
420
satisfaction : int = 0
421
421
poe_enable : bool = False
@@ -430,9 +430,6 @@ class unifi_interface(interfaces.Interface):
430
430
ip_address : Optional [str ] = None
431
431
portconf : Optional [str ] = None
432
432
433
- def __post_init__ (self ) -> None :
434
- self .finalize ()
435
-
436
433
def _convert_unifi_counters_if (section : Section ) -> interfaces .Section :
437
434
## 10|port_idx|10
438
435
## 10|port_poe|1
@@ -488,25 +485,31 @@ def _convert_unifi_counters_if(section: Section) -> interfaces.Section:
488
485
489
486
return [
490
487
unifi_interface (
491
- index = str (netif .port_idx ),
492
- descr = netif .name ,
493
- alias = netif .name ,
494
- type = '6' ,
495
- speed = _safe_int (netif .speed )* 1000000 ,
496
- oper_status = netif .oper_status ,
497
- admin_status = netif .admin_status ,
498
- in_octets = _safe_int (netif .rx_bytes ),
499
- in_ucast = _safe_int (netif .rx_packets ),
500
- in_mcast = _safe_int (netif .rx_multicast ),
501
- in_bcast = _safe_int (netif .rx_broadcast ),
502
- in_discards = _safe_int (netif .rx_dropped ),
503
- in_errors = _safe_int (netif .rx_errors ),
504
- out_octets = _safe_int (netif .tx_bytes ),
505
- out_ucast = _safe_int (netif .tx_packets ),
506
- out_mcast = _safe_int (netif .tx_multicast ),
507
- out_bcast = _safe_int (netif .tx_broadcast ),
508
- out_discards = _safe_int (netif .tx_dropped ),
509
- out_errors = _safe_int (netif .tx_errors ),
488
+ attributes = interfaces .Attributes (
489
+ index = str (netif .port_idx ),
490
+ descr = netif .name ,
491
+ type = "6" ,
492
+ speed = int (netif .speed ) * 1000000 ,
493
+ oper_status = "1" if netif .oper_status_name == "up" else "2" ,
494
+ out_qlen = None ,
495
+ alias = netif .name ,
496
+ phys_address = None ,
497
+ ),
498
+ counters = interfaces .Counters (
499
+ in_octets = int (netif .rx_bytes ),
500
+ in_ucast = int (netif .rx_packets ),
501
+ in_mcast = int (netif .rx_multicast ),
502
+ in_bcast = int (netif .rx_broadcast ),
503
+ in_disc = int (netif .rx_dropped ),
504
+ in_err = int (netif .rx_errors ),
505
+ out_octets = int (netif .tx_bytes ),
506
+ out_ucast = int (netif .tx_packets ),
507
+ out_mcast = int (netif .tx_multicast ),
508
+ out_bcast = int (netif .tx_broadcast ),
509
+ out_disc = int (netif .tx_dropped ),
510
+ out_err = int (netif .tx_errors ),
511
+ ),
512
+
510
513
jumbo = True if netif .jumbo == "1" else False ,
511
514
satisfaction = _safe_int (netif .satisfaction ) if netif .satisfaction and netif .oper_status == "1" else 0 ,
512
515
poe_enable = True if netif .poe_enable == "1" else False ,
@@ -540,7 +543,7 @@ def check_unifi_network_port_if( ##fixme parsed_section_name
540
543
section : Section ,
541
544
) -> CheckResult :
542
545
_converted_ifs = _convert_unifi_counters_if (section )
543
- iface = next (filter (lambda x : _safe_int (item ,- 1 ) == _safe_int (x .index ) or item == x .alias ,_converted_ifs ),None ) ## fix Service Discovery appearance alias/descr
546
+ iface = next (filter (lambda x : _safe_int (item ,- 1 ) == _safe_int (x .attributes . index ) or item == x . attributes .alias ,_converted_ifs ),None ) ## fix Service Discovery appearance alias/descr
544
547
yield from interfaces .check_multiple_interfaces (
545
548
item ,
546
549
params ,
0 commit comments