mirror of
https://github.com/bashclub/check-unifi-controller.git
synced 2024-12-26 05:10:12 +01:00
Ensure upcoming checkmk 2.2.0 compatibility
Unfortunately the rquired changes make it incompatible with versions before 2.2.0.
This commit is contained in:
parent
f3646613fd
commit
9ae12023e5
@ -270,7 +270,6 @@ register.inventory_plugin(
|
|||||||
def discovery_unifi_device(section):
|
def discovery_unifi_device(section):
|
||||||
yield Service(item="Device Status")
|
yield Service(item="Device Status")
|
||||||
yield Service(item="Unifi Device")
|
yield Service(item="Unifi Device")
|
||||||
yield Service(item="Unifi Device Uptime")
|
|
||||||
yield Service(item="Active-User")
|
yield Service(item="Active-User")
|
||||||
if section.type != "uap": # kein satisfaction bei ap .. radio/ssid haben schon
|
if section.type != "uap": # kein satisfaction bei ap .. radio/ssid haben schon
|
||||||
yield Service(item="Satisfaction")
|
yield Service(item="Satisfaction")
|
||||||
@ -316,14 +315,7 @@ def check_unifi_device(item,section):
|
|||||||
)
|
)
|
||||||
yield Metric("user_sta",_active_user)
|
yield Metric("user_sta",_active_user)
|
||||||
yield Metric("guest_sta",_safe_int(section.guest_num_sta))
|
yield Metric("guest_sta",_safe_int(section.guest_num_sta))
|
||||||
if item == "Unifi Device Uptime":
|
|
||||||
_uptime = int(section.uptime) if section.uptime else -1
|
|
||||||
if _uptime > 0:
|
|
||||||
yield Result(
|
|
||||||
state=State.OK,
|
|
||||||
summary=render.timespan(_uptime)
|
|
||||||
)
|
|
||||||
yield Metric("unifi_uptime",_uptime)
|
|
||||||
if item == "Satisfaction":
|
if item == "Satisfaction":
|
||||||
yield Result(
|
yield Result(
|
||||||
state=State.OK,
|
state=State.OK,
|
||||||
@ -415,7 +407,7 @@ register.inventory_plugin(
|
|||||||
|
|
||||||
############ DEVICEPORT ###########
|
############ DEVICEPORT ###########
|
||||||
@dataclass
|
@dataclass
|
||||||
class unifi_interface(interfaces.Interface):
|
class unifi_interface(interfaces.InterfaceWithCounters):
|
||||||
jumbo : bool = False
|
jumbo : bool = False
|
||||||
satisfaction : int = 0
|
satisfaction : int = 0
|
||||||
poe_enable : bool = False
|
poe_enable : bool = False
|
||||||
@ -430,8 +422,6 @@ class unifi_interface(interfaces.Interface):
|
|||||||
ip_address : Optional[str] = None
|
ip_address : Optional[str] = None
|
||||||
portconf : Optional[str] = None
|
portconf : Optional[str] = None
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
|
||||||
self.finalize()
|
|
||||||
|
|
||||||
def _convert_unifi_counters_if(section: Section) -> interfaces.Section:
|
def _convert_unifi_counters_if(section: Section) -> interfaces.Section:
|
||||||
## 10|port_idx|10
|
## 10|port_idx|10
|
||||||
@ -488,6 +478,7 @@ def _convert_unifi_counters_if(section: Section) -> interfaces.Section:
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
unifi_interface(
|
unifi_interface(
|
||||||
|
attributes=interfaces.Attributes(
|
||||||
index=str(netif.port_idx),
|
index=str(netif.port_idx),
|
||||||
descr=netif.name,
|
descr=netif.name,
|
||||||
alias=netif.name,
|
alias=netif.name,
|
||||||
@ -495,18 +486,21 @@ def _convert_unifi_counters_if(section: Section) -> interfaces.Section:
|
|||||||
speed=_safe_int(netif.speed)*1000000,
|
speed=_safe_int(netif.speed)*1000000,
|
||||||
oper_status=netif.oper_status,
|
oper_status=netif.oper_status,
|
||||||
admin_status=netif.admin_status,
|
admin_status=netif.admin_status,
|
||||||
|
),
|
||||||
|
counters=interfaces.Counters(
|
||||||
in_octets=_safe_int(netif.rx_bytes),
|
in_octets=_safe_int(netif.rx_bytes),
|
||||||
in_ucast=_safe_int(netif.rx_packets),
|
in_ucast=_safe_int(netif.rx_packets),
|
||||||
in_mcast=_safe_int(netif.rx_multicast),
|
in_mcast=_safe_int(netif.rx_multicast),
|
||||||
in_bcast=_safe_int(netif.rx_broadcast),
|
in_bcast=_safe_int(netif.rx_broadcast),
|
||||||
in_discards=_safe_int(netif.rx_dropped),
|
in_disc=_safe_int(netif.rx_dropped),
|
||||||
in_errors=_safe_int(netif.rx_errors),
|
in_err=_safe_int(netif.rx_errors),
|
||||||
out_octets=_safe_int(netif.tx_bytes),
|
out_octets=_safe_int(netif.tx_bytes),
|
||||||
out_ucast=_safe_int(netif.tx_packets),
|
out_ucast=_safe_int(netif.tx_packets),
|
||||||
out_mcast=_safe_int(netif.tx_multicast),
|
out_mcast=_safe_int(netif.tx_multicast),
|
||||||
out_bcast=_safe_int(netif.tx_broadcast),
|
out_bcast=_safe_int(netif.tx_broadcast),
|
||||||
out_discards=_safe_int(netif.tx_dropped),
|
out_disc=_safe_int(netif.tx_dropped),
|
||||||
out_errors=_safe_int(netif.tx_errors),
|
out_err=_safe_int(netif.tx_errors),
|
||||||
|
),
|
||||||
jumbo=True if netif.jumbo == "1" else False,
|
jumbo=True if netif.jumbo == "1" else False,
|
||||||
satisfaction=_safe_int(netif.satisfaction) if netif.satisfaction and netif.oper_status == "1" else 0,
|
satisfaction=_safe_int(netif.satisfaction) if netif.satisfaction and netif.oper_status == "1" else 0,
|
||||||
poe_enable=True if netif.poe_enable == "1" else False,
|
poe_enable=True if netif.poe_enable == "1" else False,
|
||||||
@ -540,7 +534,7 @@ def check_unifi_network_port_if( ##fixme parsed_section_name
|
|||||||
section: Section,
|
section: Section,
|
||||||
) -> CheckResult:
|
) -> CheckResult:
|
||||||
_converted_ifs = _convert_unifi_counters_if(section)
|
_converted_ifs = _convert_unifi_counters_if(section)
|
||||||
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
|
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
|
||||||
yield from interfaces.check_multiple_interfaces(
|
yield from interfaces.check_multiple_interfaces(
|
||||||
item,
|
item,
|
||||||
params,
|
params,
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
## SOFTWARE.
|
## SOFTWARE.
|
||||||
|
|
||||||
###
|
###
|
||||||
__VERSION__ = 0.88
|
__VERSION__ = 2.2.0
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
|
Loading…
Reference in New Issue
Block a user