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 16c31c6..8f2ec88 --- a/share/check_mk/agents/special/agent_unifi_controller +++ b/agents/special/agent_unifi_controller @@ -23,7 +23,7 @@ ## SOFTWARE. ### -__VERSION__ = 2.2.0 +__VERSION__ = "2.2.0" import sys import socket @@ -492,7 +492,7 @@ class unifi_controller(unifi_object): 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}\"}}") @@ -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 100% rename from share/check_mk/checkman/unifi_controller rename to checkman/unifi_controller diff --git a/share/check_mk/checkman/unifi_device b/checkman/unifi_device similarity index 100% rename from share/check_mk/checkman/unifi_device rename to checkman/unifi_device diff --git a/share/check_mk/checkman/unifi_device_shortlist b/checkman/unifi_device_shortlist similarity index 100% rename from share/check_mk/checkman/unifi_device_shortlist rename to checkman/unifi_device_shortlist diff --git a/share/check_mk/checkman/unifi_network_ports_if b/checkman/unifi_network_ports_if similarity index 100% rename from share/check_mk/checkman/unifi_network_ports_if rename to checkman/unifi_network_ports_if diff --git a/share/check_mk/checkman/unifi_network_radios b/checkman/unifi_network_radios similarity index 100% rename from share/check_mk/checkman/unifi_network_radios rename to checkman/unifi_network_radios diff --git a/share/check_mk/checkman/unifi_network_ssids b/checkman/unifi_network_ssids similarity index 100% rename from share/check_mk/checkman/unifi_network_ssids rename to checkman/unifi_network_ssids diff --git a/share/check_mk/checkman/unifi_sites b/checkman/unifi_sites similarity index 100% rename from share/check_mk/checkman/unifi_sites rename to checkman/unifi_sites diff --git a/share/check_mk/checkman/unifi_ssid_list b/checkman/unifi_ssid_list similarity index 100% rename from share/check_mk/checkman/unifi_ssid_list rename to checkman/unifi_ssid_list 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 10914e4..ff6b99a 100644 --- a/lib/check_mk/base/plugins/agent_based/unifi_controller.py +++ b/lib/check_mk/base/plugins/agent_based/unifi_controller.py @@ -115,7 +115,6 @@ def check_unifi_controller(item,section): state=State.WARN, notice=_("Update available") ) - yield Metric("uptime",int(section.uptime)) if item == "Cloudkey": yield Result( state=State.OK, @@ -271,7 +270,6 @@ register.inventory_plugin( def discovery_unifi_device(section): yield Service(item="Device Status") yield Service(item="Unifi Device") - yield Service(item="Uptime") yield Service(item="Active-User") if section.type != "uap": # kein satisfaction bei ap .. radio/ssid haben schon yield Service(item="Satisfaction") @@ -317,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 == "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, 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.2.mkp b/unifi_controller-0.88.2.mkp new file mode 100644 index 0000000..76eab87 Binary files /dev/null and b/unifi_controller-0.88.2.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