Skip to content

Commit

Permalink
Update to 0.87: Fix uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
spille-edv committed Mar 6, 2022
1 parent 7c03965 commit a38a85e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 1 addition & 10 deletions lib/check_mk/base/plugins/agent_based/unifi_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -271,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="Uptime")
yield Service(item="Active-User")
if section.type != "uap": # kein satisfaction bei ap .. radio/ssid haben schon
yield Service(item="Satisfaction")
Expand Down Expand Up @@ -317,14 +315,7 @@ 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,
Expand Down
11 changes: 7 additions & 4 deletions share/check_mk/agents/special/agent_unifi_controller
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
## SOFTWARE.

###
__VERSION__ = 0.83
__VERSION__ = 0.87

import sys
import socket
Expand Down Expand Up @@ -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_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",
"x_fingerprint","x_inform_authkey","op_mode"
"x_fingerprint","x_inform_authkey","op_mode","uptime"
]
for _k,_v in self.__dict__.items():
if _k.startswith("_") or _k in _unwanted or type(_v) not in (str,int,float):
Expand All @@ -362,7 +362,10 @@ class unifi_device(unifi_object):

_ret.append("<<<labels:sep(0)>>>")
_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:
_ret += ["","<<<unifi_network_ports:sep(124)>>>"] + [str(_port) for _port in self._NETWORK_PORTS]
if self._NETWORK_RADIO:
Expand Down Expand Up @@ -470,7 +473,7 @@ class unifi_controller(unifi_object):

_ret = []
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"):
_ret.append("|".join([_ssid,_key,str(sum(map(lambda x: getattr(x,_key,0),_obj)))]))

Expand Down

0 comments on commit a38a85e

Please sign in to comment.