zabbixapi 3.1.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +5 -0
  4. data/{LICENSE → LICENSE.md} +1 -1
  5. data/README.md +53 -569
  6. data/lib/zabbixapi.rb +102 -65
  7. data/lib/zabbixapi/basic/basic_alias.rb +21 -4
  8. data/lib/zabbixapi/basic/basic_func.rb +56 -23
  9. data/lib/zabbixapi/basic/basic_init.rb +21 -4
  10. data/lib/zabbixapi/basic/basic_logic.rb +75 -18
  11. data/lib/zabbixapi/classes/actions.rb +8 -4
  12. data/lib/zabbixapi/classes/applications.rb +20 -6
  13. data/lib/zabbixapi/classes/configurations.rb +23 -17
  14. data/lib/zabbixapi/classes/errors.rb +2 -4
  15. data/lib/zabbixapi/classes/graphs.rb +65 -15
  16. data/lib/zabbixapi/classes/hostgroups.rb +12 -4
  17. data/lib/zabbixapi/classes/hosts.rb +36 -10
  18. data/lib/zabbixapi/classes/httptests.rb +24 -4
  19. data/lib/zabbixapi/classes/items.rb +24 -5
  20. data/lib/zabbixapi/classes/maintenance.rb +8 -4
  21. data/lib/zabbixapi/classes/mediatypes.rb +20 -13
  22. data/lib/zabbixapi/classes/proxies.rb +29 -8
  23. data/lib/zabbixapi/classes/screens.rb +41 -25
  24. data/lib/zabbixapi/classes/server.rb +8 -4
  25. data/lib/zabbixapi/classes/templates.rb +46 -43
  26. data/lib/zabbixapi/classes/triggers.rb +43 -16
  27. data/lib/zabbixapi/classes/unusable.rb +0 -2
  28. data/lib/zabbixapi/classes/usergroups.rb +33 -26
  29. data/lib/zabbixapi/classes/usermacros.rb +137 -31
  30. data/lib/zabbixapi/classes/users.rb +32 -10
  31. data/lib/zabbixapi/classes/valuemaps.rb +50 -0
  32. data/lib/zabbixapi/client.rb +61 -22
  33. data/lib/zabbixapi/version.rb +1 -1
  34. data/zabbixapi.gemspec +26 -23
  35. metadata +25 -73
  36. data/.gitignore +0 -7
  37. data/.rspec +0 -1
  38. data/.travis.yml +0 -41
  39. data/Gemfile +0 -3
  40. data/Gemfile.lock +0 -36
  41. data/Rakefile +0 -1
  42. data/json-1.x.Gemfile +0 -4
  43. data/json-1.x.Gemfile.lock +0 -28
  44. data/spec/action.rb +0 -89
  45. data/spec/application.rb +0 -83
  46. data/spec/basic_func.rb +0 -4
  47. data/spec/configuration.rb +0 -122
  48. data/spec/graph.rb +0 -135
  49. data/spec/host.rb +0 -176
  50. data/spec/hostgroup.rb +0 -55
  51. data/spec/httptest.rb +0 -136
  52. data/spec/item.rb +0 -134
  53. data/spec/maintenance.rb +0 -81
  54. data/spec/mediatype.rb +0 -50
  55. data/spec/query.rb +0 -18
  56. data/spec/screen.rb +0 -88
  57. data/spec/script.rb +0 -123
  58. data/spec/server.rb +0 -15
  59. data/spec/spec_helper.rb +0 -21
  60. data/spec/template.rb +0 -148
  61. data/spec/trigger.rb +0 -103
  62. data/spec/user.rb +0 -116
  63. data/spec/usergroup.rb +0 -85
  64. data/spec/usermacro.rb +0 -190
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62d0c2a77a20181c6c206a4ef0f326816c9cd393
4
- data.tar.gz: 5f56649ab7a8db90bd5ce3cf9bcd6960f9ee1c08
3
+ metadata.gz: b599a8aaa780e38de4d2e21751373fd6395844cb
4
+ data.tar.gz: 54ac862491660755bec3da1543b1900e55ab5728
5
5
  SHA512:
6
- metadata.gz: 8f2be925d94ce9d47224cf6724cfbaa4a686bb846ee773919e5561632913340e80846af20e6f43a2d68e85b42ed53505dd4c6a79087c76d015e6973f107627e1
7
- data.tar.gz: aba85f76d861928efa429139f9aff3ecef58f6a0d6599de0c48905675eab6753f73df764b61f15d1a5b3d0c626f397b556b32a096d0b67d06f3d99be3aebeb88
6
+ metadata.gz: d702d07347f1c43801cb3382a86736481665df41cc8d32d07688077fc01e3ab778ae7956bbcbe9d01f5934638221d501d17e7ae5fe375f8715e9023be8785c9b
7
+ data.tar.gz: 435776e8bf0f5a62af5908a377036f144f6816872dbc457daf5e7bafb133cf712d8227d46bfd3c7f256be5c8fea79f7f2f8b5f17d428a7663539fa05d1aeca89
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --protected
3
+ --tag authentication:"Authentication"
4
+ --markup markdown
5
+ -
6
+ CHANGELOG.md
7
+ LICENSE.md
8
+ README.md
9
+ examples/*.md
@@ -1,3 +1,8 @@
1
+ ## 3.2.0
2
+ [PR #77](https://github.com/express42/zabbixapi/pull/77) Add support for Valuemap (Thanks @julienlevasseur)
3
+
4
+ [PR #80](https://github.com/express42/zabbixapi/pull/80) Hide password then raising error (Thanks @bbaugher)
5
+
1
6
  ## 3.1.0
2
7
  [PR #68](https://github.com/express42/zabbixapi/pull/68) Add support for scripts (Thanx @jrbeilke)
3
8
 
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Express 42
3
+ Copyright (c) 2015-2017 Express 42
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,586 +1,60 @@
1
1
  # Ruby Zabbix Api Module
2
2
 
3
- Simple and lightweight ruby module for work with zabbix api
3
+ [![Gem Version](http://img.shields.io/gem/v/zabbixapi.svg)][gem]
4
+ [![Build Status](http://img.shields.io/travis/express42/zabbixapi.svg)][travis]
4
5
 
5
- [![Build Status](https://travis-ci.org/express42/zabbixapi.png)](https://travis-ci.org/express42/zabbixapi)
6
+ [gem]: https://rubygems.org/gems/zabbixapi
7
+ [travis]: https://travis-ci.org/express42/zabbixapi
6
8
 
7
- ##### Now works with all version of zabbix
8
- * 1.8.2 (api version 1.2) /zabbixapi 0.6.x [branch zabbix1.8](https://github.com/express42/zabbixapi/tree/zabbix1.8)
9
- * 1.8.9 (api version 1.3) /zabbixapi 0.6.x [branch zabbix1.8](https://github.com/express42/zabbixapi/tree/zabbix1.8)
10
- * 2.0.x (api version 1.4 -> 2.0.10) /zabbixapi 2.0.x [branch zabbix2.0](https://github.com/express42/zabbixapi/tree/zabbix2.0)
11
- * 2.2.x (api version 2.2.x) /zabbixapi 2.2.x [branch zabbix2.2](https://github.com/express42/zabbixapi/tree/zabbix2.2)
12
- * 2.4.x (api version 2.2.x) /zabbixapi 2.4.x [master](https://github.com/express42/zabbixapi/)
13
- * 3.0.x (api version 3.0.x) /zabbixapi 2.4.x [master](https://github.com/express42/zabbixapi/)
14
- * 3.2.x (api version 3.2.x) /zabbixapi 2.4.x [master](https://github.com/express42/zabbixapi/)
15
-
16
- Because Zabbix 3.0 is a main branch of Zabbix, so master of zabbixapi supports this version of zabbix.
17
-
18
- ## Version policy
19
-
20
- Zabbixapi has next version policy:
21
- * for zabbix 1.8.9 and below you should use zabbixapi 0.6.x
22
- * for zabbix 2.0.x you should use zabbixapi 2.0.y
23
- * for zabbix 2.2.x you should use zabbixapi 2.2.y
24
- * for zabbix 2.4.x you should use zabbixapi 2.4.y
25
- * for zabbix 3.0.x you should use zabbixapi 3.0.y and ruby >= 2
26
-
27
- The PATCH (third digit) version of zabbixapi should not correspond to PATCH version of zabbix, for example
28
- zabbixapi-2.0.x should works with all version of zabbix 2.0.y
29
-
30
- We support only two last versions of zabbix (2.4 and 3.0), so you should consider zabbixapi 0.6.x, 2.0.x and 2.2.x depricated.
9
+ Simple and lightweight ruby module for working with [Zabbix][Zabbix] via the [Zabbix API][Zabbix API]
31
10
 
32
11
  ## Installation
33
- ```
34
- gem install zabbixapi
35
- ```
36
-
37
- ## Getting Started
38
-
39
- ### Connect
40
- ```ruby
41
- require "zabbixapi"
42
-
43
- zbx = ZabbixApi.connect(
44
- :url => 'http://localhost/zabbix/api_jsonrpc.php',
45
- :user => 'Admin',
46
- :password => 'zabbix'
47
- )
48
- # use basic_auth
49
- zbx = ZabbixApi.connect(
50
- :url => 'http://localhost/zabbix/api_jsonrpc.php',
51
- :user => 'Admin',
52
- :password => 'zabbix',
53
- :http_password => 'foo',
54
- :http_user => 'bar'
55
- )
56
- ```
57
- ### Create Hostgroup
58
- ```ruby
59
- zbx.hostgroups.create(:name => "hostgroup")
60
- ```
61
-
62
- ### Create Template
63
- ```ruby
64
- zbx.templates.create(
65
- :host => "template",
66
- :groups => [:groupid => zbx.hostgroups.get_id(:name => "hostgroup")]
67
- )
68
- ```
69
-
70
- ### Create Application
71
- ```ruby
72
- zbx.applications.create(
73
- :name => application,
74
- :hostid => zbx.templates.get_id(:host => "template")
75
- )
76
- ```
77
-
78
- ### Create Item
79
- ```ruby
80
- zbx.items.create(
81
- :name => "item",
82
- :description => "item",
83
- :key_ => "proc.num[aaa]",
84
- :type => 6,
85
- :value_type => 6,
86
- :hostid => zbx.templates.get_id(:host => "template"),
87
- :applications => [zbx.applications.get_id(:name => "application")]
88
- )
89
- # or use (lib merge json):
90
- zbx.items.create_or_update(
91
- :name => "item",
92
- :description => "item",
93
- :key_ => "proc.num[aaa]",
94
- :type => 6,
95
- :value_type => 4,
96
- :hostid => zbx.templates.get_id(:host => "template"),
97
- :applications => [zbx.applications.get_id(:name => "application")]
98
- )
99
- ```
100
-
101
- ### Update Item
102
- ```ruby
103
- zbx.items.update(
104
- :itemid => zbx.items.get_id(:name => "item"),
105
- :status => 0
106
- )
107
- #You can check item:
108
- puts zbx.items.get_full_data(:name => "item")
109
- ```
110
-
111
- ### Create host
112
- ```ruby
113
- zbx.hosts.create(
114
- :host => host.fqdn,
115
- :interfaces => [
116
- {
117
- :type => 1,
118
- :main => 1,
119
- :ip => '10.0.0.1',
120
- :dns => 'server.example.org',
121
- :port => 10050,
122
- :useip => 0
123
- }
124
- ],
125
- :groups => [ :groupid => zbx.hostgroups.get_id(:name => "hostgroup") ]
126
- )
127
-
128
- #or use:
129
- zbx.hosts.create_or_update(
130
- :host => host.fqdn,
131
- :interfaces => [
132
- {
133
- :type => 1,
134
- :main => 1,
135
- :ip => '10.0.0.1',
136
- :dns => 'server.example.org',
137
- :port => 10050,
138
- :useip => 0
139
- }
140
- ],
141
- :groups => [ :groupid => zbx.hostgroups.get_id(:name => "hostgroup") ]
142
- )
143
- ```
144
-
145
- ### Update host
146
- ```ruby
147
- zbx.hosts.update(
148
- :hostid => zbx.hosts.get_id(:host => "hostname"),
149
- :status => 0
150
- )
151
- #You can check host:
152
- puts zbx.hosts.get_full_data(:host => "hostname")
153
-
154
- # Zabbixapi checks that new object differ from one in zabbix. But if you
155
- # want to update nested arguments (like interfaces), you should use second argument.
156
- # For example:
157
-
158
- zbx.hosts.update({
159
- :hostid => zbx.hosts.get_id(:host => "hostname"),
160
- :interfaces => [
161
- {
162
- :type => 1,
163
- :main => 1,
164
- :ip => '10.0.0.1',
165
- :dns => 'server.example.org',
166
- :port => 10050,
167
- :useip => 0
168
- }
169
- ]}, true)
170
-
171
-
172
- ```
173
-
174
-
175
- ```ruby
176
- zbx.hosts.delete zbx.hosts.get_id(:host => "hostname")
177
- ```
178
-
179
- ### Create graph
180
- ```ruby
181
- gitems = {
182
- :itemid => zbx.items.get_id(:name => "item"),
183
- :calc_fnc => "2",
184
- :type => "0",
185
- :periods_cnt => "5"
186
- }
187
-
188
- zbx.graphs.create(
189
- :gitems => [gitems],
190
- :show_triggers => "0",
191
- :name => "graph",
192
- :width => "900",
193
- :height => "200",
194
- :hostid => zbx.templates.get_id(:host => "template")
195
- )
196
- ```
12
+ gem install zabbixapi
197
13
 
198
- ### Update graph
199
- ```ruby
200
- zbx.graphs.update(
201
- :graphid => zbx.graphs.get_id(:name => "graph"),
202
- :ymax_type => 1
203
- )
204
- #Also you can use:
205
- gitems = {
206
- :itemid => zbx.items.get_id(:name => "item"),
207
- :calc_fnc => "3",
208
- :type => "0",
209
- :periods_cnt => "5"
210
- }
211
- zbx.graphs.create_or_update(
212
- :gitems => [gitems],
213
- :show_triggers => "1",
214
- :name => graph,
215
- :width => "900",
216
- :height => "200",
217
- :hostid => zbx.templates.get_id(:host => "template")
218
- )
219
- ```
220
- ### Get ids by host ###
221
- ```ruby
222
- zbx.graphs.get_ids_by_host(:host => "hostname")
223
- #You can filter graph name:
224
- zbx.graphs.get_ids_by_host(:host => "hostname", filter => "CPU")
225
- ```
14
+ ## Documentation
15
+ [http://rdoc.info/gems/zabbixapi][documentation]
226
16
 
227
- ### Delete graph
228
- ```ruby
229
- zbx.graphs.delete(zbx.graphs.get_id(:name => "graph"))
230
- ```
17
+ [documentation]: http://rdoc.info/gems/zabbixapi
231
18
 
232
- ### Get all templates linked with host
233
- ```ruby
234
- zbx.templates.get_ids_by_host( :hostids => [zbx.hosts.get_id(:host => "hostname")] )
235
- #returned array:
236
- #[
237
- # "10",
238
- # "1021"
239
- #]
240
- ```
19
+ ## Examples
20
+ [https://github.com/express42/zabbixapi/tree/master/examples][examples]
241
21
 
242
- ### Mass (Un)Link host with templates
243
- ```ruby
244
- zbx.templates.mass_add(
245
- :hosts_id => [zbx.hosts.get_id(:host => "hostname")],
246
- :templates_id => [111, 214]
247
- )
248
- zbx.templates.mass_remove(
249
- :hosts_id => [zbx.hosts.get_id(:host => "hostname")],
250
- :templates_id => [111, 214]
251
- )
252
- ```
22
+ [examples]: https://github.com/express42/zabbixapi/tree/master/examples
253
23
 
254
- ### Create trigger
255
- ```ruby
256
- zbx.triggers.create(
257
- :description => "trigger",
258
- :expression => "{template:proc.num[aaa].last(0)}<1",
259
- :comments => "Bla-bla is faulty (disaster)",
260
- :priority => 5,
261
- :status => 0,
262
- :hostid => zbx.templates.get_id(:host => "template"),
263
- :type => 0,
264
- :tags => [
265
- {
266
- :tag => "process",
267
- :value => "aaa"
268
- },
269
- {
270
- :tag => "error",
271
- :value => ""
272
- }
273
- ]
274
- )
275
- ```
24
+ ## Version Policy
25
+ We support only two last versions of zabbix (3.0 and 3.2), so you should consider zabbixapi 0.6.x, 2.0.x, 2.2.x, and 2.4.x deprecated.
276
26
 
277
- ### Get trigger with certain filter
278
- ```ruby
279
- triggers = zbx.query(
280
- :method => "trigger.get",
281
- :params => {
282
- :filter => {
283
- :url => ""
284
- },
285
- :templated => true,
286
- :output => "extend"
287
- }
288
- )
289
- ```
27
+ * Zabbix 1.8.2 (api version 1.2) | zabbixapi 0.6.x | [branch zabbix1.8](https://github.com/express42/zabbixapi/tree/zabbix1.8)
28
+ * Zabbix 1.8.9 (api version 1.3) | zabbixapi 0.6.x | [branch zabbix1.8](https://github.com/express42/zabbixapi/tree/zabbix1.8)
29
+ * Zabbix 2.0.x (api version 1.4 -> 2.0.10) | zabbixapi 2.0.x | [branch zabbix2.0](https://github.com/express42/zabbixapi/tree/zabbix2.0)
30
+ * Zabbix 2.2.x (api version 2.2.x) | zabbixapi 2.2.x | [branch zabbix2.2](https://github.com/express42/zabbixapi/tree/zabbix2.2)
31
+ * Zabbix 2.4.x (api version 2.2.x) | zabbixapi 2.4.x | [branch zabbix2.4](https://github.com/express42/zabbixapi/tree/zabbix2.4)
32
+ * Zabbix 3.0.x (api version 3.0.x) | zabbixapi 3.0.x | [master](https://github.com/express42/zabbixapi/)
33
+ * Zabbix 3.2.x (api version 3.2.x) | zabbixapi 3.0.x | [master](https://github.com/express42/zabbixapi/)
290
34
 
291
- ### Create Web Scenario (httptest)
292
- ```ruby
293
- zbx.httptests.create(
294
- :name => "web scenario",
295
- :hostid => zbx.templates.get_id(:host => "template"),
296
- :applicationid => zbx.applications.get_id(:name => "application"),
297
- :steps => [
298
- {
299
- :name => "step",
300
- :url => "http://localhost/zabbix/",
301
- :status_codes => 200,
302
- :no => 1
303
- }
304
- ]
305
- )
306
- # or use (lib merge json):
307
- zbx.httptests.create_or_update(
308
- :name => "web scenario",
309
- :hostid => zbx.templates.get_id(:host => "template"),
310
- :applicationid => zbx.applications.get_id(:name => "application"),
311
- :steps => [
312
- {
313
- :name => "step",
314
- :url => "http://localhost/zabbix/",
315
- :status_codes => 200,
316
- :no => 1
317
- },
318
- {
319
- :name => "step 2",
320
- :url => "http://localhost/zabbix/index.php",
321
- :status_codes => 200,
322
- :no => 2
323
- }
324
- ]
325
- )
326
- ```
35
+ ## Supported Ruby Versions
36
+ This library aims to support and is [tested against][travis] the following Ruby
37
+ versions:
327
38
 
328
- ### Update Web Scenario (httptest)
329
- ```ruby
330
- zbx.httptests.update(
331
- :httptestid => zbx.httptests.get_id(:name => "web scenario"),
332
- :status => 0
333
- )
334
- #You can check web scenario:
335
- puts zbx.httptests.get_full_data(:name => "web scenario")
39
+ * Ruby 2.0
40
+ * Ruby 2.1
41
+ * Ruby 2.2
42
+ * Ruby 2.3
43
+ * Ruby 2.4
44
+ * JRuby 9.1.6.0
336
45
 
337
- ### Create action based on trigger
338
- ```ruby
339
- zbx.actions.create(
340
- :name => "trigger action",
341
- :eventsource => '0', # event source is a triggerid
342
- :status => '0', # action is enabled
343
- :esc_period => '120', # how long each step should take
344
- :def_shortdata => "Email header",
345
- :def_longdata => "Email content",
346
- :maintenance_mode => '1',
347
- :filter => {
348
- :evaltype => '1', # perform 'and' between the conditions
349
- :conditions => [
350
- {
351
- :conditiontype => '3', # trigger name
352
- :operator => '2', # like
353
- :value => 'pattern' # the pattern
354
- },
355
- {
356
- :conditiontype => '4', # trigger severity
357
- :operator => '5', # >=
358
- :value => '3' # average
359
- }
360
- ]
361
- },
362
- :operations => [
363
- {
364
- :operationtype => '0', # send message
365
- :opmessage_grp => [ # who the message will be sent to
366
- {
367
- :usrgrpid => '2'
368
- }
369
- ],
370
- :opmessage => {
371
- :default_msg => '0', # use default message
372
- :mediatypeid => '1' # email id
373
- }
374
- }
375
- ],
376
- :recovery_operations => [
377
- {
378
- :operationtype => '11', # send recovery message
379
- :opmessage_grp => [ # who the message will be sent to
380
- {
381
- :usrgrpid => '2'
382
- }
383
- ],
384
- :opmessage => {
385
- :default_msg => '0', # use default message
386
- :mediatypeid => '1' # email id
387
- }
388
- }
389
- ]
390
- )
391
- # In Zabbix 3.2 and higher actions now have a maintenance_mode property which pauses notifications during host maintenance
392
- # A separate action condition for Maintenance status = not in “maintenance” is no longer needed
393
- ```
46
+ If something doesn't work on one of these versions, it's a bug.
394
47
 
395
- ### Create user
396
- ```ruby
397
- zbx.users.create(
398
- :alias => "Test user",
399
- :name => "username",
400
- :surname => "usersername",
401
- :passwd => "password"
402
- )
403
- ```
48
+ This library may inadvertently work (or seem to work) on other Ruby versions,
49
+ however support will only be provided for the versions listed above.
404
50
 
405
- ### Update user
406
- ```ruby
407
- zbx.users.update(:userid => zbx.users.get_id(:alias => "user"), :name => "user2")
408
- ```
409
-
410
- ### Delete graph
411
- ```ruby
412
- zbx.graphs.delete(zbx.graphs.get_id(:name => "graph"))
413
- ```
414
-
415
- ### Create screen for host ###
416
- ```ruby
417
- zbx.screens.get_or_create_for_host(
418
- :screen_name => "screen_name",
419
- :graphids => zbx.graphs.get_ids_by_host(:host => "hostname")
420
- )
421
- ```
422
-
423
- ### Delete screen ###
424
- ```ruby
425
- zbx.screens.delete(
426
- :screen_id => 1, # or screen_id => [1, 2]
427
- )
428
- ```
429
-
430
- or
431
-
432
- ```ruby
433
- zbx.screens.delete(
434
- :screen_name => "foo screen", # or screen_name => ["foo screen", "bar screen"]
435
- )
436
- ````
437
-
438
- ### Create UserGroup, add user and set permission ###
439
- ```ruby
440
- zbx.usergroups.get_or_create(:name => "Some user group")
441
- zbx.usergroups.add_user(
442
- :usrgrpids => [zbx.usergroups.get_id(:name => "Some user group")],
443
- :userids => [zbx.users.get_id(:alias => "user")]
444
- )
445
- # set write and read permissions for UserGroup on all hostgroups
446
- zbx.usergroups.set_perms(
447
- :usrgrpid => zbx.usergroups.get_or_create(:name => "Some user group"),
448
- :hostgroupids => zbx.hostgroups.all.values, # kind_of Array
449
- :permission => 3 # 2- read (by default) and 3 - write and read
450
- )
451
- ```
452
-
453
- ### Create MediaType and add it to user ###
454
- ```ruby
455
- zbx.mediatypes.create_or_update(
456
- :description => "mediatype",
457
- :type => 0, # 0 - Email, 1 - External script, 2 - SMS, 3 - Jabber, 100 - EzTexting,
458
- :smtp_server => "127.0.0.1",
459
- :smtp_email => "zabbix@test.com"
460
- )
461
- zbx.users.add_medias(
462
- :userids => [zbx.users.get_id(:alias => "user")],
463
- :media => [
464
- {
465
- :mediatypeid => zbx.mediatypes.get_id(:description => "mediatype"),
466
- :sendto => "test@test",
467
- :active => 0,
468
- :period => "1-7,00:00-24:00", # 1-7 days and 00:00-24:00 hours
469
- :severity => "56"
470
- }
471
- ]
472
- )
473
- ```
474
-
475
- ### Update media ###
476
- ```ruby
477
- zbx.users.update_medias(
478
- :userids => [zbx.users.get_id(:alias => "user")],
479
- :media => [
480
- {
481
- :mediatypeid => zbx.mediatypes.get_id(:description => "mediatype"),
482
- :sendto => "test@test",
483
- :active => 0,
484
- :period => "1-7,00:00-24:00", # 1-7 days and 00:00-24:00 hours
485
- :severity => "56"
486
- }
487
- ]
488
- )
489
- ```
490
-
491
- ### Create Script
492
- ```ruby
493
- zbx.scripts.create(
494
- :name => 'Hostname',
495
- :command => 'hostname'
496
- )
497
- # or use (lib merge json):
498
- zbx.scripts.create_or_update(
499
- :name => 'Hostname',
500
- :command => 'hostname',
501
- :description => 'Show the system hostname'
502
- )
503
- ```
504
-
505
- ### Update Script
506
- ```ruby
507
- zbx.scripts.update(
508
- :httptestid => zbx.scripts.get_id(:name => 'Hostname'),
509
- :execute_on => 0
510
- )
511
- #You can check script:
512
- puts zbx.scripts.get_full_data(:name => 'Hostname')
513
-
514
-
515
- ### Create proxy
516
- #### Active proxy
517
- ```ruby
518
- zbx.proxies.create(
519
- :host => "Proxy 1",
520
- :status => 5
521
- )
522
- ```
523
-
524
- #### Passive Proxy
525
- ```ruby
526
- zbx.proxies.create(
527
- :host => "Passive proxy",
528
- :status => 6,
529
- :interfaces => [
530
- :ip => "127.0.0.1",
531
- :dns => "",
532
- :useip => 1,
533
- :port => 10051
534
- ]
535
- )
536
- ```
537
-
538
- ### Export object
539
-
540
- ```ruby
541
- zbx.configurations.export(
542
- :format => "xml",
543
- :options => {
544
- :templates => [zbx.templates.get_id(:host => "template")]
545
- }
546
- )
547
- ```
548
-
549
- ### Import object
550
-
551
- ```ruby
552
- zbx.configurations.import(
553
- :format => "xml",
554
- :rules => {
555
- :templates => {
556
- :createMissing => true,
557
- :updateExisting => true
558
- },
559
- :items => {
560
- :createMissing => true,
561
- :updateExisting => true
562
- }
563
- },
564
- :source => "<!--?xml version=\"1.0\" encoding=\"UTF-8\"?--><zabbix_export><version>2.0</version><date>2012-04-18T11:20:14Z</date><groups><group><name>Zabbix servers</name></group></groups><hosts><host><host>Export host</host><name>Export host</name><proxyid>0</proxyid><status>0</status><ipmi_authtype>-1</ipmi_authtype><ipmi_privilege>2</ipmi_privilege><ipmi_username></ipmi_username><ipmi_password></ipmi_password><templates></templates><groups><group><name>Zabbix servers</name></group></groups><interfaces><interface><default>1</default><type>1</type><useip>1</useip><ip>127.0.0.1</ip><dns></dns><port>10050</port><interface_ref>if1</interface_ref></interface></interfaces><applications><application><name>Application</name></application></applications><items><item><name>Item</name><type>0</type><snmp_community></snmp_community><multiplier>0</multiplier><snmp_oid></snmp_oid><key>item.key</key><delay>30</delay><history>90</history><trends>365</trends><status>0</status><value_type>3</value_type><allowed_hosts></allowed_hosts><units></units><delta>0</delta><snmpv3_securityname></snmpv3_securityname><snmpv3_securitylevel>0</snmpv3_securitylevel><snmpv3_authpassphrase></snmpv3_authpassphrase><snmpv3_privpassphrase></snmpv3_privpassphrase><formula>1</formula><delay_flex></delay_flex><params></params><ipmi_sensor></ipmi_sensor><data_type>0</data_type><authtype>0</authtype><username></username><password></password><publickey></publickey><privatekey></privatekey><port></port><description></description><inventory_link>0</inventory_link><applications><application><name>Application</name></application></applications><valuemap></valuemap><interface_ref>if1</interface_ref></item></items><discovery_rules></discovery_rules><macros></macros><inventory></inventory></host></hosts><triggers><trigger><expression>{Export host:item.key.last(0)}=0</expression><name>Trigger</name><url></url><status>0</status><priority>2</priority><description>Host trigger</description><type>0</type><dependencies></dependencies></trigger></triggers><graphs><graph><name>Graph</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>0</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>C80000</color><yaxisside>0</yaxisside><calc_fnc>7</calc_fnc><type>0</type><item><host>Export host</host><key>item.key</key></item></graph_item></graph_items></graph></graphs></zabbix_export>"
565
- )
566
- ```
567
-
568
- ### User and global macros
569
- ```ruby
570
- zbx.usermacros.create(
571
- :hostid => zbx.hosts.get_id( :host => "Zabbix server" ),
572
- :macro => "{$ZZZZ}",
573
- :value => 1.1.1.1
574
- )
575
- ```
576
-
577
- ### Custom queries
578
- ```ruby
579
- zbx.query(
580
- :method => "apiinfo.version",
581
- :params => {}
582
- )
583
- ```
51
+ If you would like this library to support another Ruby version or
52
+ implementation, you may volunteer to be a maintainer. Being a maintainer
53
+ entails making sure all tests run and pass on that implementation. When
54
+ something breaks on your implementation, you will be responsible for providing
55
+ patches in a timely fashion. If critical issues for a particular implementation
56
+ exist at the time of a major release, support for that Ruby version may be
57
+ dropped.
584
58
 
585
59
  ## Dependencies
586
60
 
@@ -591,11 +65,21 @@ zbx.query(
591
65
  ## Contributing
592
66
 
593
67
  * Fork the project.
594
- * Make your feature addition or bug fix, write tests.
68
+ * Make your feature addition or bug fix, write tests, write documentation/examples.
595
69
  * Commit, do not mess with rakefile, version.
596
70
  * Make a pull request.
597
71
 
598
72
  ## Zabbix documentation
599
73
 
600
- * [Zabbix Project Homepage](http://zabbix.com/)
601
- * [Zabbix Api docs](https://www.zabbix.com/documentation/3.0/manual/api/reference)
74
+ * [Zabbix Project Homepage][Zabbix]
75
+ * [Zabbix API docs][Zabbix API]
76
+
77
+ [Zabbix]: https://www.zabbix.com
78
+ [Zabbix API]: https://www.zabbix.com/documentation/3.2/manual/api
79
+
80
+ ## Copyright
81
+ Copyright (c) 2015-2017 Express 42
82
+
83
+ See [LICENSE][] for details.
84
+
85
+ [license]: LICENSE.md