-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzbx_export_unifi.yaml
671 lines (666 loc) · 27.4 KB
/
zbx_export_unifi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
zabbix_export:
version: '6.4'
template_groups:
- uuid: f1978336f4e84d2f8a23796b8a04bfe6
name: 'Templates ZBX'
templates:
- uuid: 0823a03ce73c40baa7ed9cc3054f755f
template: 'Template UniFi Controller'
name: 'Template UniFi Controller'
description: 'Template to monitor the UniFi Controller via API. Set the macros as needed. Readonly permission are enough.'
groups:
- name: 'Templates ZBX'
items:
- uuid: 9fd8dc2e9bca44799d40d47798d5d88f
name: 'Discover UniFi Sites'
type: SCRIPT
key: unifi.sites
delay: 5m
history: 7d
tags:
- tag: Application
value: UniFi
trends: '0'
value_type: TEXT
params: |
var obj = JSON.parse(value);
host = obj.host;
port = obj.port;
user = obj.user;
password = obj.password;
var response, login = new HttpRequest();
login.addHeader('Content-Type: application/x-www-form-urlencoded');
response = login.post(
'https://'+host+':'+port+'/api/login',
'{"username": "'+user+'", "password": "'+password+'"}'
);
if (login.getStatus() !== 200) {
throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
}
try {
response = login.get('https://'+host+':'+port+'/api/stat/sites');
response = JSON.parse(response);
}
catch (error) {
throw 'No JSON Response';
}
sites = response.data;
return JSON.stringify(sites);
parameters:
- name: host
value: '{HOST.CONN}'
- name: password
value: '{$UNIFI_PASSWORD}'
- name: port
value: '{$UNIFI_PORT}'
- name: user
value: '{$UNIFI_USER}'
- uuid: aace83a5186649b39000dcb27edac383
name: 'UniFi Up2Date Version'
type: SCRIPT
key: unifi.up2dateVersion
delay: 60m
history: 30d
tags:
- tag: Application
value: UniFi
trends: '0'
value_type: CHAR
params: |
var obj = JSON.parse(value);
url = obj.url;
var response, login = new HttpRequest();
login.addHeader('Content-Type: application/x-www-form-urlencoded');
try {
response = login.get(url);
response = JSON.parse(response);
}
catch (error) {
throw 'No JSON Response';
}
firmware = response._embedded.firmware[0];
result = firmware.version_major+"."+firmware.version_minor+"."+firmware.version_patch;
return result ;
description: 'The current unifi controller Version (Windows Version) provided by webrequest.'
parameters:
- name: url
value: '{$UNIFI_UPDATEURL}'
discovery_rules:
- uuid: f16b902954af4c949c1554534f67875f
name: 'UniFi Sites Discovery'
type: DEPENDENT
key: unifi.sites.discovery
delay: '0'
item_prototypes:
- uuid: 5d095b973cda4dee8fefb3495434cb7d
name: 'UniFi Site [{#DESC}] Alarms'
type: DEPENDENT
key: 'unifi.sites.alarms.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].[''num_new_alarms''].first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 188b899999de427d99550e0bc3fb588e
expression: 'last(/Template UniFi Controller/unifi.sites.alarms.[{#ID}])>0'
name: 'UniFi Alarms on {HOSTNAME} site [{#DESC}]'
priority: AVERAGE
- uuid: e41cfb4509d54395be1e51d142128f22
name: 'UniFi Site [{#DESC}] Description'
type: DEPENDENT
key: 'unifi.sites.desc.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].[''desc''].first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: c87db04ca4b04a24a3ce655cfa5df676
name: 'UniFi Site [{#DESC}] LAN adopted'
type: DEPENDENT
key: 'unifi.sites.name.lan.adopted.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_adopted.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 601b502606d5493bb46852e3f9181bd5
name: 'UniFi Site [{#DESC}] LAN disconnected'
type: DEPENDENT
key: 'unifi.sites.name.lan.disconnected.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_disconnected.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 8318519c28c64a1bab4ea42c29528ccf
expression: 'last(/Template UniFi Controller/unifi.sites.name.lan.disconnected.[{#ID}])>0'
name: 'UniFi LAN missing {ITEM.LASTVALUE} device(s) on {HOSTNAME} site [{#DESC}]'
priority: HIGH
- uuid: 2417dbe0669d4bbc837dd65293a83ef4
name: 'UniFi Site [{#DESC}] LAN Guests'
type: DEPENDENT
key: 'unifi.sites.name.lan.guest.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_guest.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 0b2ff88fc62b4af1b787c0fac09eb9dc
name: 'UniFi Site [{#DESC}] LAN IOT'
type: DEPENDENT
key: 'unifi.sites.name.lan.iot.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_iot.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 40f6a6a48d704dcc9f32a8d7d860ea70
name: 'UniFi Site [{#DESC}] LAN pending'
type: DEPENDENT
key: 'unifi.sites.name.lan.pending.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_pending.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 469a123cffe0439792ce97793f3077ac
name: 'UniFi Site [{#DESC}] LAN Status'
type: DEPENDENT
key: 'unifi.sites.name.lan.status.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].status.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 8446bf10c648462986dd0a82e5ef0abd
expression: 'last(/Template UniFi Controller/unifi.sites.name.lan.status.[{#ID}])<>"ok"'
name: 'UniFi LAN Subsystem not "ok" on {HOSTNAME} site [{#DESC}]'
priority: AVERAGE
- uuid: 925244528e3b433d8fa67c244b68a709
name: 'UniFi Site [{#DESC}] LAN Switches'
type: DEPENDENT
key: 'unifi.sites.name.lan.sw.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_sw.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: ea3895bce8b641dfaacf3b208d8be419
name: 'UniFi Site [{#DESC}] LAN User'
type: DEPENDENT
key: 'unifi.sites.name.lan.user.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''lan'')].num_user.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 039f3fc0f0044855894566f48bb5218a
name: 'UniFi Site [{#DESC}] VPN Status'
type: DEPENDENT
key: 'unifi.sites.name.vpn.status.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''vpn'')].status.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 2ac6115d2a2e46a1911b4e0f631b1b05
expression: 'last(/Template UniFi Controller/unifi.sites.name.vpn.status.[{#ID}])="unknown"'
name: 'UniFi VPN Subsystem is "unknown" on {HOSTNAME} site [{#DESC}]'
priority: INFO
- uuid: 89b862abc38642ceb7abc3570956d9cd
expression: 'last(/Template UniFi Controller/unifi.sites.name.vpn.status.[{#ID}])<>"ok" and last(/Template UniFi Controller/unifi.sites.name.vpn.status.[{#ID}])<>"unknown"'
name: 'UniFi VPN Subsystem not "ok" on {HOSTNAME} site [{#DESC}]'
priority: AVERAGE
- uuid: 5c23a7fa26c94bf2b06ed167e08d12e9
name: 'UniFi Site [{#DESC}] WAN Gateways'
type: DEPENDENT
key: 'unifi.sites.name.wan.gw.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wan'')].num_gw.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: d80b289473e844048b5624a19ceadc02
name: 'UniFi Site [{#DESC}] WAN Gateways adopted'
type: DEPENDENT
key: 'unifi.sites.name.wan.gws_adopted.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wan'')].num_adopted.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 5c562cdab82a4919a66718dfc24cf7ab
name: 'UniFi Site [{#DESC}] WAN Gateways disconnected'
type: DEPENDENT
key: 'unifi.sites.name.wan.gws_disconnected.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wan'')].num_disconnected.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 7ac350324bd747c4ab5c92d72aecf9a6
expression: 'last(/Template UniFi Controller/unifi.sites.name.wan.gws_disconnected.[{#ID}])>0'
name: 'UniFi Gateways missing {ITEM.LASTVALUE} device(s) on {HOSTNAME} site [{#DESC}]'
priority: HIGH
- uuid: f427ff8594cb4b7f9e98393c8a3d4c46
name: 'UniFi Site [{#DESC}] WAN Gateways pending'
type: DEPENDENT
key: 'unifi.sites.name.wan.gws_pending.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wan'')].num_pending.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 88de2ac574244d988e4eb64c54bb8951
name: 'UniFi Site [{#DESC}] WAN Status'
type: DEPENDENT
key: 'unifi.sites.name.wan.status.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wan'')].status.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 6f34f71aea6245129baa867f6a8ff0cd
expression: 'last(/Template UniFi Controller/unifi.sites.name.wan.status.[{#ID}])="unknown"'
name: 'UniFi WAN Subsystem is "unkown" on {HOSTNAME} site [{#DESC}]'
priority: INFO
- uuid: bde31e0b09fc40b0b7ae3f25376d7ebf
expression: |
last(/Template UniFi Controller/unifi.sites.name.wan.status.[{#ID}])<>"ok" and
last(/Template UniFi Controller/unifi.sites.name.wan.status.[{#ID}])<>"unknown"
name: 'UniFi WAN Subsystem not "ok" on {HOSTNAME} site [{#DESC}]'
priority: AVERAGE
- uuid: 96026d4a6c414020b471abbb45c10c3f
name: 'UniFi Site [{#DESC}] WLAN APs'
type: DEPENDENT
key: 'unifi.sites.name.wlan.ap.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_ap.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 9df364f28a714d75a1e0db4056603925
name: 'UniFi Site [{#DESC}] WLAN APs adopted'
type: DEPENDENT
key: 'unifi.sites.name.wlan.aps_adopted.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_adopted.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 1255887b82b34fcc9bb2cc9acfcf2834
name: 'UniFi Site [{#DESC}] WLAN APs disabled'
type: DEPENDENT
key: 'unifi.sites.name.wlan.aps_disabled.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_disabled.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 122c5fea8af14cc88aaac6bbb467e389
name: 'UniFi Site [{#DESC}] WLAN APs disconnected'
type: DEPENDENT
key: 'unifi.sites.name.wlan.aps_disconnected.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_disconnected.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 7c3ebe31ffbc461fb2270cf946f09fc8
expression: 'last(/Template UniFi Controller/unifi.sites.name.wlan.aps_disconnected.[{#ID}])>0'
name: 'UniFi Aps missing {ITEM.LASTVALUE} device(s) on {HOSTNAME} site [{#DESC}]'
priority: HIGH
- uuid: d66bcd1bd46740b488a286a0859f3ce4
name: 'UniFi Site [{#DESC}] WLAN APs pending'
type: DEPENDENT
key: 'unifi.sites.name.wlan.aps_pending.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_pending.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 2b82f4d94a544f33a9439a31210092b5
name: 'UniFi Site [{#DESC}] WLAN Guests'
type: DEPENDENT
key: 'unifi.sites.name.wlan.guest.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_guest.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: a082e8a36214422ab7c3a5d80db8e94d
name: 'UniFi Site [{#DESC}] WLAN Status'
type: DEPENDENT
key: 'unifi.sites.name.wlan.status.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].status.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 2676bd53cc4243d5bba71c65a3163e7d
expression: 'last(/Template UniFi Controller/unifi.sites.name.wlan.status.[{#ID}])="unknown"'
name: 'UniFi WLAN Subsystem is "unkown" on {HOSTNAME} site [{#DESC}]'
priority: INFO
- uuid: d9de8ea2bc594b2988c578f64e112f42
expression: 'last(/Template UniFi Controller/unifi.sites.name.wlan.status.[{#ID}])<>"ok" and last(/Template UniFi Controller/unifi.sites.name.wlan.status.[{#ID}])<>"unknown"'
name: 'UniFi WLAN Subsystem not "ok" on {HOSTNAME} site [{#DESC}]'
priority: AVERAGE
- uuid: 4e0643297eed40eea9e0a1ad5db2614f
name: 'UniFi Site [{#DESC}] WLAN User'
type: DEPENDENT
key: 'unifi.sites.name.wlan.user.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''wlan'')].num_user.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 9af38f10b1d74a3db4fcce63ba96acbe
name: 'UniFi Site [{#DESC}] WWW Status'
type: DEPENDENT
key: 'unifi.sites.name.www.status.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].health.[?(@.[''subsystem'']==''www'')].status.first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 7030bb2421b74327a62bbe10aa66f8f0
expression: 'last(/Template UniFi Controller/unifi.sites.name.www.status.[{#ID}])="unknown"'
name: 'UniFi WWW Subsystem is "unkown" on {HOSTNAME} site [{#DESC}]'
priority: INFO
- uuid: b90610f0e09e43ada0a25e5d44dd9d6f
expression: 'last(/Template UniFi Controller/unifi.sites.name.www.status.[{#ID}])<>"ok" and last(/Template UniFi Controller/unifi.sites.name.www.status.[{#ID}])<>"unknown"'
name: 'UniFi WWW Subsystem not "ok" on {HOSTNAME} site [{#DESC}]'
priority: AVERAGE
- uuid: 308297e1634d43c59352475ac6117908
name: 'UniFi Site [{#DESC}] Name'
type: DEPENDENT
key: 'unifi.sites.name.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[?(@.[''_id'']==''{#ID}'')].[''name''].first()'
master_item:
key: unifi.sites
tags:
- tag: Application
value: UniFi
- uuid: 46d570e396b845cca7915453ce8bf9f5
name: 'Discover UniFi Site Info [{#DESC}]'
type: SCRIPT
key: 'unifi.sites.sysinfo.[{#ID}]'
delay: 10m
history: 7d
trends: '0'
value_type: TEXT
params: |
var obj = JSON.parse(value);
var response, login = new HttpRequest();
login.addHeader('Content-Type: application/x-www-form-urlencoded');
response = login.post(
'https://'+host+':'+port+'/api/login',
'{"username": "'+user+'", "password": "'+password+'"}'
);
if (login.getStatus() !== 200) {
throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
}
site = '{#NAME}'
try {
url = 'https://'+host+':'+port+'/api/s/'+site+'/stat/sysinfo'
response = login.get(url);
response = JSON.parse(response);
}
catch (error) {
throw 'No JSON Response from: '+url;
}
sites = response.data;
return JSON.stringify(sites);
parameters:
- name: host
value: '{HOST.CONN}'
- name: password
value: '{$UNIFI_PASSWORD}'
- name: port
value: '{$UNIFI_PORT}'
- name: user
value: '{$UNIFI_USER}'
tags:
- tag: Application
value: UniFi
- uuid: d9e88289b4f3484eb99d16766c7a63ce
name: 'UniFi Site [{#DESC}] Unsupported Device Count'
type: DEPENDENT
key: 'unifi.sites.unsuppoted_device_count.[{#ID}]'
delay: '0'
history: 30d
preprocessing:
- type: JSONPATH
parameters:
- '$.[*].[''unsupported_device_count''].first()'
master_item:
key: 'unifi.sites.sysinfo.[{#ID}]'
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 8d7b08e8767e418b98aeda07305d35df
expression: 'last(/Template UniFi Controller/unifi.sites.unsuppoted_device_count.[{#ID}])>0'
name: 'UniFi Devices not supported on {HOSTNAME} site [{#DESC}]'
priority: HIGH
- uuid: 69866caf71d140f6a152324ceb6c7aca
name: 'UniFi Site [{#DESC}] Version'
type: DEPENDENT
key: 'unifi.sites.version.[{#ID}]'
delay: '0'
history: 30d
trends: '0'
value_type: CHAR
preprocessing:
- type: JSONPATH
parameters:
- '$.[*].version.first()'
master_item:
key: 'unifi.sites.sysinfo.[{#ID}]'
tags:
- tag: Application
value: UniFi
trigger_prototypes:
- uuid: 7bcf5b73ccc34b7e9cb6bb61149cbfc2
expression: 'last(/Template UniFi Controller/unifi.up2dateVersion)<>last(/Template UniFi Controller/unifi.sites.version.[{#ID}])'
name: 'UniFi Update pending on {HOSTNAME} site [{#DESC}]'
priority: WARNING
master_item:
key: unifi.sites
preprocessing:
- type: JAVASCRIPT
parameters:
- |
var result = [];
var sites = JSON.parse(value);
sites.forEach(function(site) {
result.push({"{#ID}": site._id, "{#DESC}": site.desc, "{#NAME}": site.name});
});
return JSON.stringify(result);
macros:
- macro: '{$UNIFI_PASSWORD}'
value: password
- macro: '{$UNIFI_PORT}'
value: '8443'
- macro: '{$UNIFI_UPDATEURL}'
value: 'https://fw-update.ubnt.com/api/firmware-latest?filter=eq~~product~~unifi-controller&filter=eq~~channel~~release&filter=eq~~platform~~windows'
- macro: '{$UNIFI_USER}'
value: admin