@@ -158,7 +158,7 @@ def discovery_unifi_sites(section):
158158 for _item in section .values ():
159159 yield Service (item = f"{ _item .desc } " )
160160
161- def check_unifi_sites (item ,section ):
161+ def check_unifi_sites (item ,params , section ):
162162 site = next (filter (lambda x : x .desc == item ,section .values ()))
163163 yield Metric ("satisfaction" ,max (0 ,_safe_int (site .satisfaction )))
164164
@@ -169,7 +169,8 @@ def check_unifi_sites(item,section):
169169 #yield Metric("if_in_bps",_safe_int(site.lan_rx_bytes_r)*8)
170170 yield Metric ("if_out_octets" ,_safe_int (site .lan_tx_bytes_r ))
171171 #yield Metric("if_out_bps",_safe_int(site.lan_tx_bytes_r)*8)
172-
172+ yield Metric ("lan_active_sw" ,_safe_int (site .lan_num_sw ))
173+ yield Metric ("lan_total_sw" ,_safe_int (site .lan_num_adopted ))
173174 yield Result (
174175 state = _unifi_status2state (site .lan_status ),
175176 summary = f"LAN: { site .lan_num_sw } /{ site .lan_num_adopted } Switch ({ site .lan_status } )"
@@ -185,6 +186,8 @@ def check_unifi_sites(item,section):
185186 yield Metric ("wlan_iot_sta" ,_safe_int (site .wlan_num_iot ))
186187 yield Metric ("wlan_if_in_octets" ,_safe_int (site .wlan_rx_bytes_r ))
187188 yield Metric ("wlan_if_out_octets" ,_safe_int (site .wlan_tx_bytes_r ))
189+ yield Metric ("wlan_active_ap" ,_safe_int (site .wlan_num_ap ))
190+ yield Metric ("wlan_total_ap" ,_safe_int (site .wlan_num_adopted ))
188191 yield Result (
189192 state = _unifi_status2state (site .wlan_status ),
190193 summary = f"WLAN: { site .wlan_num_ap } /{ site .wlan_num_adopted } AP ({ site .wlan_status } )"
@@ -208,8 +211,14 @@ def check_unifi_sites(item,section):
208211 state = _unifi_status2state (site .vpn_status ),
209212 notice = f"WWW Status: { site .vpn_status } "
210213 )
214+
215+ if params .get ("ignore_alarms" ):
216+ _alarmstate = State .OK
217+ else :
218+ _alarmstate = _expect_number (site .num_new_alarms )
219+
211220 yield Result (
212- state = _expect_number ( site . num_new_alarms ) ,
221+ state = _alarmstate ,
213222 notice = f"{ site .num_new_alarms } new Alarm"
214223 )
215224
@@ -223,6 +232,8 @@ def check_unifi_sites(item,section):
223232 name = 'unifi_sites' ,
224233 service_name = 'Site %s' ,
225234 discovery_function = discovery_unifi_sites ,
235+ check_default_parameters = {},
236+ check_ruleset_name = "unifi_sites" ,
226237 check_function = check_unifi_sites ,
227238)
228239
@@ -258,6 +269,7 @@ def inventory_unifi_device_shortlist(section):
258269
259270############ DEVICE ###########
260271def discovery_unifi_device (section ):
272+ yield Service (item = "Device Status" )
261273 yield Service (item = "Unifi Device" )
262274 yield Service (item = "Uptime" )
263275 yield Service (item = "Active-User" )
@@ -271,8 +283,16 @@ def discovery_unifi_device(section):
271283 yield Service (item = "Speedtest" )
272284
273285def check_unifi_device (item ,section ):
274- if section .state != "1" :
275- yield IgnoreResults (f"device not active State: { section .state } " )
286+ _device_state = UNIFI_DEVICE_STATES .get (section .state ,"unknown" )
287+ ## connected OK / pending Warn / Rest Crit
288+ _hoststatus = State .OK if section .state == "1" else State .WARN if section .state == "2" else State .CRIT
289+ if item == "Device Status" :
290+ yield Result (
291+ state = _hoststatus ,
292+ summary = f"Status: { _device_state } "
293+ )
294+ #if section.state != "1":
295+ # yield IgnoreResults(f"device not active State: {section.state}")
276296
277297 if item == "Unifi Device" :
278298 yield Result (
0 commit comments