Skip to content

Commit a38a85e

Browse files
committedMar 6, 2022
Update to 0.87: Fix uptime
1 parent 7c03965 commit a38a85e

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed
 

‎lib/check_mk/base/plugins/agent_based/unifi_controller.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def check_unifi_controller(item,section):
115115
state=State.WARN,
116116
notice=_("Update available")
117117
)
118-
yield Metric("uptime",int(section.uptime))
119118
if item == "Cloudkey":
120119
yield Result(
121120
state=State.OK,
@@ -271,7 +270,6 @@ def inventory_unifi_device_shortlist(section):
271270
def discovery_unifi_device(section):
272271
yield Service(item="Device Status")
273272
yield Service(item="Unifi Device")
274-
yield Service(item="Uptime")
275273
yield Service(item="Active-User")
276274
if section.type != "uap": # kein satisfaction bei ap .. radio/ssid haben schon
277275
yield Service(item="Satisfaction")
@@ -317,14 +315,7 @@ def check_unifi_device(item,section):
317315
)
318316
yield Metric("user_sta",_active_user)
319317
yield Metric("guest_sta",_safe_int(section.guest_num_sta))
320-
if item == "Uptime":
321-
_uptime = int(section.uptime) if section.uptime else -1
322-
if _uptime > 0:
323-
yield Result(
324-
state=State.OK,
325-
summary=render.timespan(_uptime)
326-
)
327-
yield Metric("unifi_uptime",_uptime)
318+
328319
if item == "Satisfaction":
329320
yield Result(
330321
state=State.OK,

‎share/check_mk/agents/special/agent_unifi_controller

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
## SOFTWARE.
2424

2525
###
26-
__VERSION__ = 0.83
26+
__VERSION__ = 0.87
2727

2828
import sys
2929
import socket
@@ -353,7 +353,7 @@ class unifi_device(unifi_object):
353353
"lcm_idle_timeout_override","lcm_brightness_override","uplink_depth","mesh_sta_vap_enabled","mesh_uplink_2",
354354
"lcm_tracker_enabled","model_incompatible","model_in_lts","model_in_eol","country_code","wifi_caps",
355355
"meshv3_peer_mac","element_peer_mac","vwireEnabled","hide_ch_width","x_authkey","x_ssh_hostkey_fingerprint",
356-
"x_fingerprint","x_inform_authkey","op_mode"
356+
"x_fingerprint","x_inform_authkey","op_mode","uptime"
357357
]
358358
for _k,_v in self.__dict__.items():
359359
if _k.startswith("_") or _k in _unwanted or type(_v) not in (str,int,float):
@@ -362,7 +362,10 @@ class unifi_device(unifi_object):
362362

363363
_ret.append("<<<labels:sep(0)>>>")
364364
_ret.append(f"{{\"unifi_device\":\"unifi-{self.type}\"}}")
365-
365+
_uptime = getattr(self,"uptime",None)
366+
if _uptime:
367+
_ret.append("<<<uptime>>>")
368+
_ret.append(str(_uptime))
366369
if self._NETWORK_PORTS:
367370
_ret += ["","<<<unifi_network_ports:sep(124)>>>"] + [str(_port) for _port in self._NETWORK_PORTS]
368371
if self._NETWORK_RADIO:
@@ -470,7 +473,7 @@ class unifi_controller(unifi_object):
470473

471474
_ret = []
472475
for _ssid,_obj in _dict.items():
473-
pprint(_obj)
476+
#pprint(_obj)
474477
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"):
475478
_ret.append("|".join([_ssid,_key,str(sum(map(lambda x: getattr(x,_key,0),_obj)))]))
476479

0 commit comments

Comments
 (0)
Please sign in to comment.