diff --git a/share/check_mk/agents/special/agent_unifi_controller b/agents/special/agent_unifi_controller old mode 100644 new mode 100755 similarity index 98% rename from share/check_mk/agents/special/agent_unifi_controller rename to agents/special/agent_unifi_controller index e229e5e..a29920e --- a/share/check_mk/agents/special/agent_unifi_controller +++ b/agents/special/agent_unifi_controller @@ -1,19 +1,19 @@ #!/usr/bin/env python3 # -*- encoding: utf-8; py-indent-offset: 4 -*- ## MIT License -## +## ## Copyright (c) 2021 Bash Club -## +## ## Permission is hereby granted, free of charge, to any person obtaining a copy ## of this software and associated documentation files (the "Software"), to deal ## in the Software without restriction, including without limitation the rights ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ## copies of the Software, and to permit persons to whom the Software is ## furnished to do so, subject to the following conditions: -## +## ## The above copyright notice and this permission notice shall be included in all ## copies or substantial portions of the Software. -## +## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,8 +22,8 @@ ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ## SOFTWARE. -### -__VERSION__ = 0.88 +### +__VERSION__ = "2.2.0" import sys import socket @@ -214,7 +214,7 @@ class unifi_network_ssid(unifi_object): ######################################## ###### -###### R A D I O +###### R A D I O ###### ######################################## class unifi_network_radio(unifi_object): @@ -233,7 +233,7 @@ class unifi_network_radio(unifi_object): continue _ret.append(f"{self.name}|{_k}|{_v}") return "\n".join(_ret) - + ######################################## ###### ###### P O R T @@ -253,9 +253,9 @@ class unifi_network_port(unifi_object): self.name = self.ifname if not hasattr(self,"port_idx") and hasattr(self,"ifname"): self.port_idx = int(self.ifname[-1])+1 ## ethX - + self.portconf = self._PARENT._PARENT._PORTCONFIGS.get(getattr(self,"portconf_id",None)) - + def _get_state(self,state): return { @@ -286,7 +286,7 @@ class unifi_device(unifi_object): self._NETWORK_PORTS = [] self._NETWORK_RADIO = [] self._NETWORK_SSIDS = [] - + for _k,_v in getattr(self,"sys_stats",{}).items(): _k = _k.replace("-","_") setattr(self,_k,_v) @@ -295,7 +295,7 @@ class unifi_device(unifi_object): ## change ip to local ip self.wan_ip = self.ip self.ip = self.connect_request_ip - + if getattr(self,"speedtest_status_saved",False): _speedtest = getattr(self,"speedtest_status",{}) self.speedtest_time = int(_speedtest.get("rundate","0")) @@ -303,11 +303,11 @@ class unifi_device(unifi_object): self.speedtest_ping = round(_speedtest.get("latency",-1),1) self.speedtest_download = round(_speedtest.get("xput_download",0.0),1) self.speedtest_upload = round(_speedtest.get("xput_upload",0.0),1) - + _temp = list(map(lambda x: x.get("value",0),getattr(self,"temperatures",[]))) if _temp: self.general_temperature = "{0:.1f}".format(mean(_temp)) - + for _port in getattr(self,"port_table",[]): self._NETWORK_PORTS.append(unifi_network_port(_PARENT=self,**_port)) @@ -370,7 +370,7 @@ class unifi_device(unifi_object): _ret += ["","<<>>"] + [str(_port) for _port in self._NETWORK_PORTS] if self._NETWORK_RADIO: _ret += ["","<<>>"] + [str(_radio) for _radio in self._NETWORK_RADIO] - + if self._NETWORK_SSIDS: _ret += ["","<<>>"] + [str(_ssid) for _ssid in sorted(self._NETWORK_SSIDS,key=lambda x: x.essid)] return "\n".join(_ret) @@ -390,7 +390,7 @@ class unifi_site(unifi_object): continue #print(f"{_k}:{_v}") setattr(self,f"{_name}_{_k}",_v) - + ##pprint(_api.get_data("/stat/rogueap")) self._SITE_DEVICES = [] self._PORTCONFIGS = {} @@ -438,7 +438,7 @@ class unifi_controller(unifi_object): for _dev in self._UNIFI_DEVICES: _dev._get_uplink() if hasattr(self,"cloudkey_version"): - self.cloudkey_version = re.sub(".*?v(\d+\.\d+\.\d+\.[a-z0-9]+).*","\\1",self.cloudkey_version) + self.cloudkey_version = re.sub(r".*?v(\d+\.\d+\.\d+\.[a-z0-9]+).*","\\1",self.cloudkey_version) self.type = getattr(self,"ubnt_device_type","unifi-sw-controller") self.controller_version = self.version delattr(self,"version") @@ -470,13 +470,13 @@ class unifi_controller(unifi_object): _dict = defaultdict(list) for _ssid in self._UNIFI_SSIDS: _dict[f"{_ssid.essid}@{_ssid._UNIFI_SITE.desc}"].append(_ssid) - + _ret = [] for _ssid,_obj in _dict.items(): #pprint(_obj) for _key in ("num_sta","ng_num_sta","na_num_sta","ng_tcp_packet_loss","na_tcp_packet_loss","ng_wifi_retries","na_wifi_retries","ng_wifi_latency","na_wifi_latency"): _ret.append("|".join([_ssid,_key,str(sum(map(lambda x: getattr(x,_key,0),_obj)))])) - + _signals = list(map(lambda x: getattr(x,"ng_avg_client_signal",0),filter(lambda x: x.radio == "ng",_obj))) _ret.append("|".join([_ssid,"ng_avg_client_signal",str(mean(_signals if _signals else [0]))])) _signals = list(map(lambda x: getattr(x,"na_avg_client_signal",0),filter(lambda x: x.radio == "na",_obj))) @@ -488,11 +488,11 @@ class unifi_controller(unifi_object): )])) _ret.append("|".join([_ssid,"avg_client_signal",str(mean(map(lambda x: getattr(x,"avg_client_signal",0),_obj))) ])) return _ret - + def __str__(self): _ret = ["<<>>"] for _k,_v in self.__dict__.items(): - if _k.startswith("_") or type(_v) not in (str,int,float): + if _k == "uptime" or _k.startswith("_") or type(_v) not in (str,int,float): continue _ret.append(f"{_k}|{_v}") @@ -503,6 +503,10 @@ class unifi_controller(unifi_object): _udm._piggy_back = False _ret.append(str(_udm)) + if "uptime" in self.__dict__: + _ret.append("<<>>") + _ret.append(f"{self.uptime}") + _ret.append("<<>>") _ret.append(f"{{\"unifi_device\":\"unifi-{self.type}\"}}") @@ -515,7 +519,7 @@ class unifi_controller(unifi_object): if _device._piggy_back: _ret.append(_device._get_short_info()) ## device list - + ## ssid list _ret.append("<<>>") _ret += self._get_ssidlist() @@ -552,7 +556,7 @@ class unifi_controller_api(object): def check_unifi_os(self): _response = self.request("GET",url=self.url,allow_redirects=False) - self.is_unifios= _response.status_code == 200 and _response.headers.get("x-csrf-token") + self.is_unifios= _response.status_code == 200 def get_sysinfo(self): return self.get_data("/stat/sysinfo") @@ -645,7 +649,7 @@ if __name__ == '__main__': if _api.is_unifios: labels = {"cmk/os_family": "UnifiOS"} - print("<<>>" + print("<<>>") print(json.dumps(labels)) ##pprint(_api.get_data("/stat/rogueap?within=4")) diff --git a/share/check_mk/checkman/unifi_controller b/checkman/unifi_controller similarity index 66% rename from share/check_mk/checkman/unifi_controller rename to checkman/unifi_controller index 66a19eb..5c19c01 100644 --- a/share/check_mk/checkman/unifi_controller +++ b/checkman/unifi_controller @@ -1,7 +1,8 @@ title: Unifi Controller agents: unifi_controller -catalog: networking -licence: MIT +catalog: networking/unifi +distribution: unifi +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each device - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_device b/checkman/unifi_device similarity index 65% rename from share/check_mk/checkman/unifi_device rename to checkman/unifi_device index c83defd..23f622c 100644 --- a/share/check_mk/checkman/unifi_device +++ b/checkman/unifi_device @@ -1,7 +1,8 @@ title: Unifi Device agents: unifi_controller -catalog: networking -licence: MIT +catalog: networking/unifi +distribution: unifi +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each device - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_device_shortlist b/checkman/unifi_device_shortlist similarity index 66% rename from share/check_mk/checkman/unifi_device_shortlist rename to checkman/unifi_device_shortlist index 5a3554c..2c0a400 100644 --- a/share/check_mk/checkman/unifi_device_shortlist +++ b/checkman/unifi_device_shortlist @@ -1,7 +1,8 @@ title: Unifi Devicelist -catalog: networking +catalog: networking/unifi +distribution: unifi agents: unifi_controller -licence: MIT +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each device - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_network_ports_if b/checkman/unifi_network_ports_if similarity index 65% rename from share/check_mk/checkman/unifi_network_ports_if rename to checkman/unifi_network_ports_if index ce4eae5..2f4b833 100644 --- a/share/check_mk/checkman/unifi_network_ports_if +++ b/checkman/unifi_network_ports_if @@ -1,7 +1,8 @@ title: Unifi Network Port agents: unifi_controller -catalog: networking -licence: MIT +catalog: networking/unifi +distribution: unifi +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each Port - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_network_radios b/checkman/unifi_network_radios similarity index 65% rename from share/check_mk/checkman/unifi_network_radios rename to checkman/unifi_network_radios index 7e5a223..a609554 100644 --- a/share/check_mk/checkman/unifi_network_radios +++ b/checkman/unifi_network_radios @@ -1,7 +1,8 @@ title: Unifi WLAN Radio agents: unifi_controller -catalog: networking -licence: MIT +catalog: networking/unifi +distribution: unifi +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each Radio - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_network_ssids b/checkman/unifi_network_ssids similarity index 64% rename from share/check_mk/checkman/unifi_network_ssids rename to checkman/unifi_network_ssids index 3dc339e..6ee6568 100644 --- a/share/check_mk/checkman/unifi_network_ssids +++ b/checkman/unifi_network_ssids @@ -1,7 +1,8 @@ title: Unifi SSID agents: unifi_controller -catalog: networking -licence: MIT +catalog: networking/unifi +distribution: unifi +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each SSID - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_sites b/checkman/unifi_sites similarity index 64% rename from share/check_mk/checkman/unifi_sites rename to checkman/unifi_sites index 7295cdf..603fb0f 100644 --- a/share/check_mk/checkman/unifi_sites +++ b/checkman/unifi_sites @@ -1,7 +1,8 @@ title: Unifi Site agents: unifi_controller -catalog: networking -licence: MIT +catalog: networking/unifi +distribution: unifi +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each Site - \ No newline at end of file + diff --git a/share/check_mk/checkman/unifi_ssid_list b/checkman/unifi_ssid_list similarity index 66% rename from share/check_mk/checkman/unifi_ssid_list rename to checkman/unifi_ssid_list index 5a3554c..2c0a400 100644 --- a/share/check_mk/checkman/unifi_ssid_list +++ b/checkman/unifi_ssid_list @@ -1,7 +1,8 @@ title: Unifi Devicelist -catalog: networking +catalog: networking/unifi +distribution: unifi agents: unifi_controller -licence: MIT +license: MIT description: plz fill me @@ -10,4 +11,4 @@ item: inventory: One Service for each device - \ No newline at end of file + diff --git a/share/check_mk/checks/agent_unifi_controller b/checks/agent_unifi_controller similarity index 100% rename from share/check_mk/checks/agent_unifi_controller rename to checks/agent_unifi_controller diff --git a/lib/check_mk/base/plugins/agent_based/unifi_controller.py b/lib/check_mk/base/plugins/agent_based/unifi_controller.py index a4b9b06..ff6b99a 100644 --- a/lib/check_mk/base/plugins/agent_based/unifi_controller.py +++ b/lib/check_mk/base/plugins/agent_based/unifi_controller.py @@ -270,7 +270,6 @@ def inventory_unifi_device_shortlist(section): def discovery_unifi_device(section): yield Service(item="Device Status") yield Service(item="Unifi Device") - yield Service(item="Unifi Device Uptime") yield Service(item="Active-User") if section.type != "uap": # kein satisfaction bei ap .. radio/ssid haben schon yield Service(item="Satisfaction") @@ -316,14 +315,6 @@ def check_unifi_device(item,section): ) yield Metric("user_sta",_active_user) 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": yield Result( state=State.OK, @@ -415,7 +406,7 @@ def inventory_unifi_device(section): ############ DEVICEPORT ########### @dataclass -class unifi_interface(interfaces.Interface): +class unifi_interface(interfaces.InterfaceWithCounters): jumbo : bool = False satisfaction : int = 0 poe_enable : bool = False @@ -430,8 +421,6 @@ class unifi_interface(interfaces.Interface): ip_address : Optional[str] = None portconf : Optional[str] = None - def __post_init__(self) -> None: - self.finalize() def _convert_unifi_counters_if(section: Section) -> interfaces.Section: ## 10|port_idx|10 @@ -488,25 +477,29 @@ def _convert_unifi_counters_if(section: Section) -> interfaces.Section: return [ unifi_interface( - index=str(netif.port_idx), - descr=netif.name, - alias=netif.name, - type='6', - speed=_safe_int(netif.speed)*1000000, - oper_status=netif.oper_status, - admin_status=netif.admin_status, - in_octets=_safe_int(netif.rx_bytes), - in_ucast=_safe_int(netif.rx_packets), - in_mcast=_safe_int(netif.rx_multicast), - in_bcast=_safe_int(netif.rx_broadcast), - in_discards=_safe_int(netif.rx_dropped), - in_errors=_safe_int(netif.rx_errors), - out_octets=_safe_int(netif.tx_bytes), - out_ucast=_safe_int(netif.tx_packets), - out_mcast=_safe_int(netif.tx_multicast), - out_bcast=_safe_int(netif.tx_broadcast), - out_discards=_safe_int(netif.tx_dropped), - out_errors=_safe_int(netif.tx_errors), + attributes=interfaces.Attributes( + index=str(netif.port_idx), + descr=netif.name, + alias=netif.name, + type='6', + speed=_safe_int(netif.speed)*1000000, + oper_status=netif.oper_status, + admin_status=netif.admin_status, + ), + counters=interfaces.Counters( + in_octets=_safe_int(netif.rx_bytes), + in_ucast=_safe_int(netif.rx_packets), + in_mcast=_safe_int(netif.rx_multicast), + in_bcast=_safe_int(netif.rx_broadcast), + in_disc=_safe_int(netif.rx_dropped), + in_err=_safe_int(netif.rx_errors), + out_octets=_safe_int(netif.tx_bytes), + out_ucast=_safe_int(netif.tx_packets), + out_mcast=_safe_int(netif.tx_multicast), + out_bcast=_safe_int(netif.tx_broadcast), + out_disc=_safe_int(netif.tx_dropped), + out_err=_safe_int(netif.tx_errors), + ), jumbo=True if netif.jumbo == "1" else False, 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, @@ -540,7 +533,7 @@ def check_unifi_network_port_if( ##fixme parsed_section_name section: Section, ) -> CheckResult: _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( item, params, @@ -673,41 +666,42 @@ def discovery_unifi_ssids(section): def check_unifi_ssids(item,section): ssid = section.get(item) - _channels = ",".join(list(filter(lambda x: _safe_int(x) > 0,[ssid.ng_channel,ssid.na_channel]))) - yield Result( - state=State.OK, - summary=f"Channels: {_channels}" - ) - if (_safe_int(ssid.ng_is_guest) + _safe_int(ssid.na_is_guest)) > 0: + if ssid: + _channels = ",".join(list(filter(lambda x: _safe_int(x) > 0,[ssid.ng_channel,ssid.na_channel]))) yield Result( state=State.OK, - summary="Guest" + summary=f"Channels: {_channels}" ) - _satisfaction = max(0,min(_safe_int(ssid.ng_satisfaction),_safe_int(ssid.na_satisfaction))) - yield Result( - state=State.OK, - summary=f"Satisfaction: {_satisfaction}" - ) - _num_sta = _safe_int(ssid.na_num_sta) + _safe_int(ssid.ng_num_sta) - if _num_sta > 0: + if (_safe_int(ssid.ng_is_guest) + _safe_int(ssid.na_is_guest)) > 0: + yield Result( + state=State.OK, + summary="Guest" + ) + _satisfaction = max(0,min(_safe_int(ssid.ng_satisfaction),_safe_int(ssid.na_satisfaction))) yield Result( state=State.OK, - summary=f"User: {_num_sta}" + summary=f"Satisfaction: {_satisfaction}" ) - yield Metric("satisfaction",max(0,_satisfaction)) - yield Metric("wlan_24Ghz_num_user",_safe_int(ssid.ng_num_sta) ) - yield Metric("wlan_5Ghz_num_user",_safe_int(ssid.na_num_sta) ) - - yield Metric("na_avg_client_signal",_safe_int(ssid.na_avg_client_signal)) - yield Metric("ng_avg_client_signal",_safe_int(ssid.ng_avg_client_signal)) + _num_sta = _safe_int(ssid.na_num_sta) + _safe_int(ssid.ng_num_sta) + if _num_sta > 0: + yield Result( + state=State.OK, + summary=f"User: {_num_sta}" + ) + yield Metric("satisfaction",max(0,_satisfaction)) + yield Metric("wlan_24Ghz_num_user",_safe_int(ssid.ng_num_sta) ) + yield Metric("wlan_5Ghz_num_user",_safe_int(ssid.na_num_sta) ) - yield Metric("na_tcp_packet_loss",_safe_int(ssid.na_tcp_packet_loss)) - yield Metric("ng_tcp_packet_loss",_safe_int(ssid.ng_tcp_packet_loss)) - - yield Metric("na_wifi_retries",_safe_int(ssid.na_wifi_retries)) - yield Metric("ng_wifi_retries",_safe_int(ssid.ng_wifi_retries)) - yield Metric("na_wifi_latency",_safe_int(ssid.na_wifi_latency)) - yield Metric("ng_wifi_latency",_safe_int(ssid.ng_wifi_latency)) + yield Metric("na_avg_client_signal",_safe_int(ssid.na_avg_client_signal)) + yield Metric("ng_avg_client_signal",_safe_int(ssid.ng_avg_client_signal)) + + yield Metric("na_tcp_packet_loss",_safe_int(ssid.na_tcp_packet_loss)) + yield Metric("ng_tcp_packet_loss",_safe_int(ssid.ng_tcp_packet_loss)) + + yield Metric("na_wifi_retries",_safe_int(ssid.na_wifi_retries)) + yield Metric("ng_wifi_retries",_safe_int(ssid.ng_wifi_retries)) + yield Metric("na_wifi_latency",_safe_int(ssid.na_wifi_latency)) + yield Metric("ng_wifi_latency",_safe_int(ssid.ng_wifi_latency)) @@ -732,26 +726,27 @@ def discovery_unifi_ssidlist(section): def check_unifi_ssidlist(item,section): ssid = section.get(item) - yield Result( - state=State.OK, - summary=f"Channels: {ssid.channels}" - ) - yield Result( - state=State.OK, - summary=f"User: {ssid.num_sta}" - ) - yield Metric("wlan_24Ghz_num_user",_safe_int(ssid.ng_num_sta) ) - yield Metric("wlan_5Ghz_num_user",_safe_int(ssid.na_num_sta) ) - yield Metric("na_avg_client_signal",_safe_int(ssid.na_avg_client_signal)) - yield Metric("ng_avg_client_signal",_safe_int(ssid.ng_avg_client_signal)) + if ssid: + yield Result( + state=State.OK, + summary=f"Channels: {ssid.channels}" + ) + yield Result( + state=State.OK, + summary=f"User: {ssid.num_sta}" + ) + yield Metric("wlan_24Ghz_num_user",_safe_int(ssid.ng_num_sta) ) + yield Metric("wlan_5Ghz_num_user",_safe_int(ssid.na_num_sta) ) + yield Metric("na_avg_client_signal",_safe_int(ssid.na_avg_client_signal)) + yield Metric("ng_avg_client_signal",_safe_int(ssid.ng_avg_client_signal)) + + yield Metric("na_tcp_packet_loss",_safe_int(ssid.na_tcp_packet_loss)) + yield Metric("ng_tcp_packet_loss",_safe_int(ssid.ng_tcp_packet_loss)) - yield Metric("na_tcp_packet_loss",_safe_int(ssid.na_tcp_packet_loss)) - yield Metric("ng_tcp_packet_loss",_safe_int(ssid.ng_tcp_packet_loss)) - - yield Metric("na_wifi_retries",_safe_int(ssid.na_wifi_retries)) - yield Metric("ng_wifi_retries",_safe_int(ssid.ng_wifi_retries)) - yield Metric("na_wifi_latency",_safe_int(ssid.na_wifi_latency)) - yield Metric("ng_wifi_latency",_safe_int(ssid.ng_wifi_latency)) + yield Metric("na_wifi_retries",_safe_int(ssid.na_wifi_retries)) + yield Metric("ng_wifi_retries",_safe_int(ssid.ng_wifi_retries)) + yield Metric("na_wifi_latency",_safe_int(ssid.na_wifi_latency)) + yield Metric("ng_wifi_latency",_safe_int(ssid.ng_wifi_latency)) register.agent_section( name = 'unifi_ssid_list', diff --git a/share/check_mk/inventory/unifi_controller b/share/check_mk/inventory/unifi_controller deleted file mode 100644 index 32b9be8..0000000 --- a/share/check_mk/inventory/unifi_controller +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8; py-indent-offset: 4 -*- - -from pprint import pprint -from collections import defaultdict - -class dictobject(defaultdict): - def __getattr__(self,name): - return self[name] if name in self else "" - -nested_dictobject = lambda: dictobject(nested_dictobject) - -def inv_unifi_controller(info): - node = inv_tree("software.os") - node["version"] = info.get("controller_version") - -def inv_unifi_device(info): - node = inv_tree("software.configuration.snmp_info") - node["name"] = info.get("name") - node["contact"] = info.get("snmp_contact") - node["location"] = info.get("snmp_location") - node = inv_tree("software.os") - node["version"] = info.get("version") - node = inv_tree("harware.system") - node["vendor"] = "ubiquiti" - for _key in ("model","board_rev","serial","mac"): - _val = info.get(_key) - if _val: - node[_key] = _val - -def inv_unifi_port(info,params,inventory_tree): - _parsed = nested_dictobject() - for _line in info: - _parsed[_line[0]][_line[1]] = _line[2] - - _interfaces = [] - _total_ethernet_ports = 0 - _available_ethernet_ports = 0 - def _saveint(num): - try: - return int(num) - except (TypeError,ValueError): - return 0 - for _iface in _parsed.values(): - _interfaces.append({ - "index" : int(_iface.port_idx), - "description" : _iface.name, - "alias" : _iface.name, - "speed" : _saveint(_iface.speed)*1000000, - "phys_address" : "", - "oper_status" : _saveint(_iface.oper_status), - "admin_status" : _saveint(_iface.admin_status), - "port_type" : 6, - "available" : _iface.oper_status == '2' - }) - _total_ethernet_ports+=1 - _available_ethernet_ports+=1 if _iface.oper_status == '2' else 0 - - node = inventory_tree.get_list("networking.interfaces:") - node.extend(sorted(_interfaces, key=lambda i: i.get('index'))) - node = inventory_tree.get_dict("networking.") - node["available_ethernet_ports"] = _available_ethernet_ports - node["total_ethernet_ports"] = _total_ethernet_ports - node["total_interfaces"] = len(_parsed) - -inv_info["unifi_controller"] = { - "inv_function" : inv_unifi_controller -} -inv_info["unifi_device"] = { - "inv_function" : inv_unifi_device -} - -inv_info["unifi_network_ports"] = { - "inv_function" : inv_unifi_port -} - diff --git a/unifi_controller-0.88.5.mkp b/unifi_controller-0.88.5.mkp new file mode 100644 index 0000000..8210023 Binary files /dev/null and b/unifi_controller-0.88.5.mkp differ diff --git a/share/check_mk/web/plugins/metrics/unifi_metrics.py b/web/plugins/metrics/unifi_metrics.py similarity index 100% rename from share/check_mk/web/plugins/metrics/unifi_metrics.py rename to web/plugins/metrics/unifi_metrics.py diff --git a/share/check_mk/web/plugins/perfometer/unifi_performeter.py b/web/plugins/perfometer/unifi_performeter.py similarity index 100% rename from share/check_mk/web/plugins/perfometer/unifi_performeter.py rename to web/plugins/perfometer/unifi_performeter.py diff --git a/share/check_mk/web/plugins/wato/datasource_unifi_controller.py b/web/plugins/wato/datasource_unifi_controller.py similarity index 100% rename from share/check_mk/web/plugins/wato/datasource_unifi_controller.py rename to web/plugins/wato/datasource_unifi_controller.py