-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzbx_export_templates.yaml
751 lines (743 loc) · 24 KB
/
zbx_export_templates.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
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
zabbix_export:
version: '7.0'
template_groups:
- uuid: 57b7ae836ca64446ba2c296389c009b7
name: Templates/Modules
templates:
- uuid: 04aceac553204efca60d4412e79b453c
template: ex2
name: 'example 2 - get stats from 3 pages'
groups:
- name: Templates/Modules
items:
- uuid: 031f692c58b7434895bf0e6d83551c53
name: all
type: BROWSER
key: all
delay: 1d
trends: '0'
value_type: TEXT
params: |
var params = JSON.parse(value);
var browser = new Browser(Browser.chromeOptions());
var page = params.pages.split("|");
var full = [];
const screenshot = '';
browser.setScreenSize(Number(1280), Number(720));
for (i = 0; i < page.length; i++) {
row = {};
browser.navigate(params.schema + '://' + params.domain + '/' + page[i]);
browser.collectPerfEntries(page[i]);
screenshot = browser.getScreenshot();
const result = browser.getResult();
result.screenshot = screenshot;
row = result;
full.push(row);
}
return JSON.stringify(full);
parameters:
- name: domain
value: '{$DOMAIN}'
- name: pages
value: '{$PAGES}'
- name: schema
value: '{$SCHEMA}'
- uuid: 77319d8bec9c4a11a5f5609c7c2822e2
name: page1
type: DEPENDENT
key: page1
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- '$[0]'
error_handler: DISCARD_VALUE
master_item:
key: all
- uuid: 9d19fbaa4aab4fe6bec2df6030f7e7c8
name: page2
type: DEPENDENT
key: page2
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- '$[1]'
error_handler: DISCARD_VALUE
master_item:
key: all
- uuid: 7db74a01bbc84a3ea167bd423dae1b47
name: page3
type: DEPENDENT
key: page3
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- '$[2]'
error_handler: DISCARD_VALUE
master_item:
key: all
- uuid: 7963ac6bbc064a438ab431d1f9582ca7
name: pd1
type: DEPENDENT
key: pd1
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- $.performance_data
master_item:
key: page1
- uuid: a90c8847e6e54cb6960dec2711490947
name: pd2
type: DEPENDENT
key: pd2
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- $.performance_data
master_item:
key: page2
- uuid: a2f67289079a4b81986a1d87ad39b4dd
name: pd3
type: DEPENDENT
key: pd3
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- $.performance_data
master_item:
key: page3
- uuid: 1402a13827094064942c738fdbf0ba26
name: screen1
type: DEPENDENT
key: screen1
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- $.screenshot
master_item:
key: page1
- uuid: f2d911b991104b44908c355add23088f
name: screen2
type: DEPENDENT
key: screen2
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- $.screenshot
master_item:
key: page2
- uuid: 26cf49b22d674d0c94c85d00fb29aa26
name: screen3
type: DEPENDENT
key: screen3
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- $.screenshot
master_item:
key: page3
macros:
- macro: '{$DOMAIN}'
value: www.zabbix.com
- macro: '{$PAGES}'
value: whats_new_5_0|whats_new_6_0|whats_new_7_0
- macro: '{$SCHEMA}'
value: https
dashboards:
- uuid: dea0f2e4ff3b4efc82eb5363c62efb11
name: steps
pages:
- widgets:
- type: itemhistory
name: step1
width: '23'
height: '7'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex2
key: screen1
- type: STRING
name: columns.0.name
value: page1
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: JSVCH
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- type: itemhistory
name: step2
x: '23'
width: '25'
height: '7'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex2
key: screen2
- type: STRING
name: columns.0.name
value: page2
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: ZGQKY
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- type: itemhistory
name: step3
x: '48'
width: '24'
height: '7'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex2
key: screen3
- type: STRING
name: columns.0.name
value: page3
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: MEOYT
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- uuid: 5db4859193fc49cca9ea2f2f71c8bb3e
template: ex3
name: 'example 3 - monitor all unique links in landing page'
groups:
- name: Templates/Modules
items:
- uuid: 66a7988e18eb4638879243cbfd0aaf78
name: landing
type: BROWSER
key: landing
delay: 1d
trends: '0'
value_type: TEXT
params: |
var params = JSON.parse(value);
function uniq(a) {
return a.sort().filter(function (item, pos, ary) {
return !pos || item != ary[pos - 1];
});
}
var browser = new Browser(Browser.chromeOptions());
browser.navigate(params.schema + '://' + params.domain);
var el = browser.findElements("link text", "");
var links = [];
for (var n = 0; n < el.length; n++) { links.push(el[n].getAttribute('href')); }
links = uniq(links);
var lld = [];
for (i = 0; i < links.length; i++) {
if (links[i].match(/^http.*/)) {
var row = {};
row["{#URL}"] = links[i];
lld.push(row);
}
}
return JSON.stringify(lld);
parameters:
- name: domain
value: '{$DOMAIN}'
- name: schema
value: '{$SCHEMA}'
discovery_rules:
- uuid: 1fdb16e81f1d43f1a4bd813385c3d763
name: page
type: DEPENDENT
key: page
delay: '0'
item_prototypes:
- uuid: 706c151d749e4f0b9fd70d53065d0865
name: '{#URL}'
type: BROWSER
key: 'collectPerfEntries[{#URL}]'
delay: 1d
trends: '0'
value_type: TEXT
params: |
var params = JSON.parse(value);
var browser = new Browser(Browser.chromeOptions());
const screenshot = '';
browser.setScreenSize(Number(1280), Number(1024))
browser.navigate(params.url);
browser.collectPerfEntries();
screenshot = browser.getScreenshot();
const result = browser.getResult();
result.screenshot = screenshot;
return JSON.stringify(result);
parameters:
- name: url
value: '{#URL}'
- uuid: 3c7a3cbd8ddb4b9aae22699001e69728
name: '{#URL} performance data'
type: DEPENDENT
key: 'pd[{#URL}]'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- $.performance_data
master_item:
key: 'collectPerfEntries[{#URL}]'
- uuid: 02c46354f76d4cc384fc40afd441d21b
name: '{#URL} screenshot'
type: DEPENDENT
key: 'screenshot[{#URL}]'
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- $.screenshot
master_item:
key: 'collectPerfEntries[{#URL}]'
master_item:
key: landing
macros:
- macro: '{$DOMAIN}'
value: blog.zabbix.com
- macro: '{$SCHEMA}'
value: https
- uuid: 7b60277c56c540a8bc60465a7bc0d55f
template: ex4
name: 'example 4 - fill fields and push a button'
groups:
- name: Templates/Modules
items:
- uuid: e40cbe28b17641db86e023145f750a9b
name: authenticate
type: BROWSER
key: authenticate
delay: 1d
trends: '0'
value_type: TEXT
params: |
var browser, result;
browser = new Browser(Browser.chromeOptions());
browser.setScreenSize(Number(1280), Number(720));
screens = [];
const screenshot = '';
try {
browser.navigate("https://github.com/login");
screens.push(browser.getScreenshot());
// enter username
var el = browser.findElement("xpath", "//{$USER:1}[@{$USER:2}='{$USER:3}']");
if (el === null) {throw Error("cannot find name input field");}
el.sendKeys("{$USER:4}");
screens.push(browser.getScreenshot());
// enter password
el = browser.findElement("xpath", "//{$PASS:1}[@{$PASS:2}='{$PASS:3}']");
if (el === null) { throw Error("cannot find password input field"); }
el.sendKeys("{$PASS:4}");
screens.push(browser.getScreenshot());
// login
el = browser.findElement("xpath", "//input[@name='commit']");
if (el === null) { throw Error("cannot find login button"); }
el.click();
screens.push(browser.getScreenshot());
}
catch (err) {
if (!(err instanceof BrowserError)) {
browser.setError(err.message);
}
result = browser.getResult();
result.error.screenshot = browser.getScreenshot();
}
finally {
return JSON.stringify(screens);
}
- uuid: 3b8d904e56bd4ac5836870da57515ee6
name: step1
type: DEPENDENT
key: step1
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- '$[0]'
error_handler: DISCARD_VALUE
master_item:
key: authenticate
- uuid: bdc3322d3a8a40fcaf72874e8e98aade
name: step2
type: DEPENDENT
key: step2
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- '$[1]'
error_handler: DISCARD_VALUE
master_item:
key: authenticate
- uuid: 373431d76f3e4924aadda9c4b524f115
name: step3
type: DEPENDENT
key: step3
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- '$[2]'
error_handler: DISCARD_VALUE
master_item:
key: authenticate
- uuid: 61098878a9d94f7f8ded89edca5296cb
name: step4
type: DEPENDENT
key: step4
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- '$[3]'
error_handler: DISCARD_VALUE
master_item:
key: authenticate
- uuid: a208a0828ab044cb91babdcf05ca05c1
name: step5
type: DEPENDENT
key: step5
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- '$[4]'
error_handler: DISCARD_VALUE
master_item:
key: authenticate
- uuid: 8e1ae1b5cbf243e8a595bb029c8239ad
name: step6
type: DEPENDENT
key: step6
delay: '0'
trends: '0'
value_type: BINARY
preprocessing:
- type: JSONPATH
parameters:
- '$[5]'
error_handler: DISCARD_VALUE
master_item:
key: authenticate
macros:
- macro: '{$AUTH}'
value: 'https://github.com/login'
- macro: '{$PASS:1}'
value: input
description: 'HTML tag name which holds password'
- macro: '{$PASS:2}'
value: id
description: 'which attribute to seek'
- macro: '{$PASS:3}'
value: password
description: 'attribute value'
- macro: '{$PASS:4}'
value: 'hello world'
description: 'enter password'
- macro: '{$SCHEMA}'
value: https
- macro: '{$USER:1}'
value: input
description: 'HTML tag name which holds username'
- macro: '{$USER:2}'
value: id
description: 'which attribute to seek'
- macro: '{$USER:3}'
value: login_field
description: 'attribute value'
- macro: '{$USER:4}'
value: 'my username'
description: 'fill the field'
dashboards:
- uuid: 52ff50e5539d4ba683573e8e2c213155
name: screen
pages:
- widgets:
- type: itemhistory
name: '1'
width: '17'
height: '8'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex4
key: step1
- type: STRING
name: columns.0.name
value: screen1
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: ZPYUH
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- type: itemhistory
name: '2'
x: '17'
width: '18'
height: '8'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex4
key: step2
- type: STRING
name: columns.0.name
value: screen1
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: VBVQY
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- type: itemhistory
name: '3'
x: '35'
width: '19'
height: '8'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex4
key: step3
- type: STRING
name: columns.0.name
value: screen1
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: JWTDD
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- type: itemhistory
name: '4'
x: '54'
width: '18'
height: '8'
fields:
- type: ITEM
name: columns.0.itemid
value:
host: ex4
key: step4
- type: STRING
name: columns.0.name
value: screen4
- type: INTEGER
name: columns.0.show_thumbnail
value: '1'
- type: STRING
name: reference
value: KSAIB
- type: INTEGER
name: show_lines
value: '5'
- type: INTEGER
name: show_timestamp
value: '1'
- uuid: 846a0613d8eb4561b41038e76dadc375
template: ex5
name: 'example 5 - search for string'
groups:
- name: Templates/Modules
items:
- uuid: e9cb2f5572ab4ba0be5bf30e40c992f7
name: landing
type: BROWSER
key: landing
delay: 1d
trends: '0'
value_type: TEXT
params: |
var params = JSON.parse(value);
function uniq(a) {
return a.sort().filter(function (item, pos, ary) {
return !pos || item != ary[pos - 1];
});
}
var browser = new Browser(Browser.chromeOptions());
browser.navigate(params.schema + '://' + params.domain);
var el = browser.findElements("link text", "");
var links = [];
for (var n = 0; n < el.length; n++) { links.push(el[n].getAttribute('href')); }
links = uniq(links);
var lld = [];
for (i = 0; i < links.length; i++) {
if (links[i].match(/^http.*/)) {
var row = {};
row["{#URL}"] = links[i];
lld.push(row);
}
}
return JSON.stringify(lld);
parameters:
- name: domain
value: '{$DOMAIN}'
- name: schema
value: '{$SCHEMA}'
discovery_rules:
- uuid: 6eedb8fff43a42bb8198a45bc53d5f66
name: page
type: DEPENDENT
key: page
delay: '0'
item_prototypes:
- uuid: 994ba1f641134452a5525461c1fb1332
name: 'count of keyword "the " in {#URL}'
type: DEPENDENT
key: 'count.of[the,{#URL}]'
delay: '0'
preprocessing:
- type: JAVASCRIPT
parameters:
- 'return value.match(/the /g).length;'
master_item:
key: 'src[{#URL}]'
- uuid: 7b5af67514a246efb13c7bdcbcf594e5
name: 'seek for "Zabbix API" in {#URL}'
type: DEPENDENT
key: 'seek[Zabbix API,{#URL}]'
delay: '0'
valuemap:
name: keyword
preprocessing:
- type: JAVASCRIPT
parameters:
- 'return value.match(/Zabbix API/g) ? 1 : 0;'
master_item:
key: 'src[{#URL}]'
- uuid: be9c44ff66644418b98beea950d74ef2
name: '{#URL} source'
type: DEPENDENT
key: 'src[{#URL}]'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
- type: JSONPATH
parameters:
- $.source
master_item:
key: 'url[{#URL}]'
- uuid: c7f2cbd585ca4bd8a9a931820b464f92
name: '{#URL}'
type: BROWSER
key: 'url[{#URL}]'
delay: 1d
trends: '0'
value_type: TEXT
params: |
var params = JSON.parse(value);
var browser = new Browser(Browser.chromeOptions());
browser.navigate(params.url);
browser.collectPerfEntries();
const result = browser.getResult();
var source = browser.getPageSource();
return JSON.stringify({
'result':result,
'source':source
});
parameters:
- name: url
value: '{#URL}'
master_item:
key: landing
macros:
- macro: '{$DOMAIN}'
value: blog.zabbix.com
- macro: '{$SCHEMA}'
value: https
valuemaps:
- uuid: d790c69d47c94a319aedca345e6dc1c9
name: keyword
mappings:
- value: '1'
newvalue: found
- value: '0'
newvalue: 'not found'