@@ -158,7 +158,7 @@ def discovery_unifi_sites(section):
158
158
for _item in section .values ():
159
159
yield Service (item = f"{ _item .desc } " )
160
160
161
- def check_unifi_sites (item ,section ):
161
+ def check_unifi_sites (item ,params , section ):
162
162
site = next (filter (lambda x : x .desc == item ,section .values ()))
163
163
yield Metric ("satisfaction" ,max (0 ,_safe_int (site .satisfaction )))
164
164
@@ -169,7 +169,8 @@ def check_unifi_sites(item,section):
169
169
#yield Metric("if_in_bps",_safe_int(site.lan_rx_bytes_r)*8)
170
170
yield Metric ("if_out_octets" ,_safe_int (site .lan_tx_bytes_r ))
171
171
#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 ))
173
174
yield Result (
174
175
state = _unifi_status2state (site .lan_status ),
175
176
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):
185
186
yield Metric ("wlan_iot_sta" ,_safe_int (site .wlan_num_iot ))
186
187
yield Metric ("wlan_if_in_octets" ,_safe_int (site .wlan_rx_bytes_r ))
187
188
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 ))
188
191
yield Result (
189
192
state = _unifi_status2state (site .wlan_status ),
190
193
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):
208
211
state = _unifi_status2state (site .vpn_status ),
209
212
notice = f"WWW Status: { site .vpn_status } "
210
213
)
214
+
215
+ if params .get ("ignore_alarms" ):
216
+ _alarmstate = State .OK
217
+ else :
218
+ _alarmstate = _expect_number (site .num_new_alarms )
219
+
211
220
yield Result (
212
- state = _expect_number ( site . num_new_alarms ) ,
221
+ state = _alarmstate ,
213
222
notice = f"{ site .num_new_alarms } new Alarm"
214
223
)
215
224
@@ -223,6 +232,8 @@ def check_unifi_sites(item,section):
223
232
name = 'unifi_sites' ,
224
233
service_name = 'Site %s' ,
225
234
discovery_function = discovery_unifi_sites ,
235
+ check_default_parameters = {},
236
+ check_ruleset_name = "unifi_sites" ,
226
237
check_function = check_unifi_sites ,
227
238
)
228
239
@@ -258,6 +269,7 @@ def inventory_unifi_device_shortlist(section):
258
269
259
270
############ DEVICE ###########
260
271
def discovery_unifi_device (section ):
272
+ yield Service (item = "Device Status" )
261
273
yield Service (item = "Unifi Device" )
262
274
yield Service (item = "Uptime" )
263
275
yield Service (item = "Active-User" )
@@ -271,8 +283,16 @@ def discovery_unifi_device(section):
271
283
yield Service (item = "Speedtest" )
272
284
273
285
def 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}")
276
296
277
297
if item == "Unifi Device" :
278
298
yield Result (
0 commit comments