Merge branch 'main' into patch-1

This commit is contained in:
Thorsten Spille 2023-02-18 21:04:09 +01:00 committed by GitHub
commit c6f9b80fac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -1,2 +1,16 @@
# check-unifi-controller # check-unifi-controller
Checkmk special agent for checking unifi controller Checkmk special agent for checking unifi controller
### Usage:
Login into your checkmk instnace user on your checkmk server (e.g. via SSH).
Download and install the checkmk agent:
~~~
wget https://github.com/bashclub/check-unifi-controller/releases/download/v0.87/unifi_controller-0.87.mkp
mkp install ./unifi_controller-0.87.mkp
~~~
### Configure Agent
Login into your checkmk website and go to "Setup" -> "Agents" -> "Other integrations" (Datasource programs). Under the category "Hardware" click on "Unifi Controller via API" and create a new rule.
Fill in the credentials of your Unifi controller, set the HTTPS Port, define the site name (if other than default), check "Ignore certificate validation" if using a self signed certificate, select Hostname or IP for storing piggyback data.
Under "Conditions" assign an "Explicit host" with your Unifi Controller Machine.
The agent will carry piggyback data for switches and access points and you can create new hosts to monitor, where piggyback data will be assignesd on exact match (IP or hostname).

View File

@ -115,7 +115,6 @@ def check_unifi_controller(item,section):
state=State.WARN, state=State.WARN,
notice=_("Update available") notice=_("Update available")
) )
yield Metric("uptime",int(section.uptime))
if item == "Cloudkey": if item == "Cloudkey":
yield Result( yield Result(
state=State.OK, state=State.OK,

View File

@ -23,7 +23,7 @@
## SOFTWARE. ## SOFTWARE.
### ###
__VERSION__ = 0.83 __VERSION__ = 0.87
import sys import sys
import socket import socket
@ -353,7 +353,7 @@ class unifi_device(unifi_object):
"lcm_idle_timeout_override","lcm_brightness_override","uplink_depth","mesh_sta_vap_enabled","mesh_uplink_2", "lcm_idle_timeout_override","lcm_brightness_override","uplink_depth","mesh_sta_vap_enabled","mesh_uplink_2",
"lcm_tracker_enabled","model_incompatible","model_in_lts","model_in_eol","country_code","wifi_caps", "lcm_tracker_enabled","model_incompatible","model_in_lts","model_in_eol","country_code","wifi_caps",
"meshv3_peer_mac","element_peer_mac","vwireEnabled","hide_ch_width","x_authkey","x_ssh_hostkey_fingerprint", "meshv3_peer_mac","element_peer_mac","vwireEnabled","hide_ch_width","x_authkey","x_ssh_hostkey_fingerprint",
"x_fingerprint","x_inform_authkey","op_mode" "x_fingerprint","x_inform_authkey","op_mode","uptime"
] ]
for _k,_v in self.__dict__.items(): for _k,_v in self.__dict__.items():
if _k.startswith("_") or _k in _unwanted or type(_v) not in (str,int,float): if _k.startswith("_") or _k in _unwanted or type(_v) not in (str,int,float):
@ -362,7 +362,10 @@ class unifi_device(unifi_object):
_ret.append("<<<labels:sep(0)>>>") _ret.append("<<<labels:sep(0)>>>")
_ret.append(f"{{\"unifi_device\":\"unifi-{self.type}\"}}") _ret.append(f"{{\"unifi_device\":\"unifi-{self.type}\"}}")
_uptime = getattr(self,"uptime",None)
if _uptime:
_ret.append("<<<uptime>>>")
_ret.append(str(_uptime))
if self._NETWORK_PORTS: if self._NETWORK_PORTS:
_ret += ["","<<<unifi_network_ports:sep(124)>>>"] + [str(_port) for _port in self._NETWORK_PORTS] _ret += ["","<<<unifi_network_ports:sep(124)>>>"] + [str(_port) for _port in self._NETWORK_PORTS]
if self._NETWORK_RADIO: if self._NETWORK_RADIO:
@ -470,7 +473,7 @@ class unifi_controller(unifi_object):
_ret = [] _ret = []
for _ssid,_obj in _dict.items(): for _ssid,_obj in _dict.items():
pprint(_obj) #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"): 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)))])) _ret.append("|".join([_ssid,_key,str(sum(map(lambda x: getattr(x,_key,0),_obj)))]))