zabbixapi 0.6.6 → 2.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +11 -6
- data/README.md +21 -25
- data/lib/zabbixapi.rb +23 -10
- data/lib/zabbixapi/{1.8/basic → basic}/basic_alias.rb +0 -0
- data/lib/zabbixapi/{1.8/basic → basic}/basic_func.rb +3 -3
- data/lib/zabbixapi/{1.8/basic → basic}/basic_init.rb +0 -0
- data/lib/zabbixapi/{2.0/basic → basic}/basic_logic.rb +3 -3
- data/lib/zabbixapi/{1.8/classes → classes}/applications.rb +0 -0
- data/lib/zabbixapi/{1.8/classes → classes}/errors.rb +0 -0
- data/lib/zabbixapi/{1.8/classes → classes}/graphs.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/hostgroups.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/hosts.rb +4 -0
- data/lib/zabbixapi/{2.0/classes → classes}/items.rb +8 -0
- data/lib/zabbixapi/{1.8/classes → classes}/mediatypes.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/proxies.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/screens.rb +1 -19
- data/lib/zabbixapi/{1.8/classes → classes}/server.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/templates.rb +4 -4
- data/lib/zabbixapi/{1.8/classes → classes}/triggers.rb +0 -0
- data/lib/zabbixapi/{1.8/classes → classes}/unusable.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/usergroups.rb +0 -12
- data/lib/zabbixapi/{2.0/classes → classes}/usermacros.rb +0 -0
- data/lib/zabbixapi/{2.0/classes → classes}/users.rb +2 -2
- data/lib/zabbixapi/version.rb +1 -1
- data/spec/application.rb +74 -0
- data/spec/basic_func.rb +4 -0
- data/spec/graph.rb +135 -0
- data/spec/host.rb +136 -0
- data/spec/hostgroup.rb +55 -0
- data/spec/item.rb +132 -0
- data/spec/mediatype.rb +47 -0
- data/spec/query.rb +13 -0
- data/spec/screen.rb +88 -0
- data/spec/server.rb +17 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/template.rb +148 -0
- data/spec/trigger.rb +74 -0
- data/spec/user.rb +99 -0
- data/spec/usergroup.rb +69 -0
- data/zabbixapi.gemspec +3 -3
- metadata +52 -44
- data/lib/zabbixapi/1.8/basic/basic_logic.rb +0 -103
- data/lib/zabbixapi/1.8/classes/hostgroups.rb +0 -26
- data/lib/zabbixapi/1.8/classes/hosts.rb +0 -58
- data/lib/zabbixapi/1.8/classes/items.rb +0 -54
- data/lib/zabbixapi/1.8/classes/screens.rb +0 -101
- data/lib/zabbixapi/1.8/classes/templates.rb +0 -109
- data/lib/zabbixapi/1.8/classes/usergroups.rb +0 -82
- data/lib/zabbixapi/1.8/classes/users.rb +0 -32
- data/lib/zabbixapi/2.0/basic/basic_alias.rb +0 -21
- data/lib/zabbixapi/2.0/basic/basic_func.rb +0 -55
- data/lib/zabbixapi/2.0/basic/basic_init.rb +0 -33
- data/lib/zabbixapi/2.0/classes/applications.rb +0 -45
- data/lib/zabbixapi/2.0/classes/errors.rb +0 -15
- data/lib/zabbixapi/2.0/classes/graphs.rb +0 -66
- data/lib/zabbixapi/2.0/classes/mediatypes.rb +0 -31
- data/lib/zabbixapi/2.0/classes/server.rb +0 -12
- data/lib/zabbixapi/2.0/classes/triggers.rb +0 -67
- data/lib/zabbixapi/2.0/classes/unusable.rb +0 -10
- data/spec/localhost.rb +0 -514
- data/spec/run.rb +0 -486
data/spec/run.rb
DELETED
@@ -1,486 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
|
3
|
-
require 'zabbixapi'
|
4
|
-
|
5
|
-
# settings
|
6
|
-
@api_url = 'http://localhost/zabbix/api_jsonrpc.php'
|
7
|
-
@api_login = 'Admin'
|
8
|
-
@api_password = 'zabbix'
|
9
|
-
|
10
|
-
zbx = ZabbixApi.connect(
|
11
|
-
:url => @api_url,
|
12
|
-
:user => @api_login,
|
13
|
-
:password => @api_password,
|
14
|
-
:debug => false
|
15
|
-
)
|
16
|
-
|
17
|
-
hostgroup = "hostgroup"
|
18
|
-
template = "template"
|
19
|
-
application = "application"
|
20
|
-
item = "item"
|
21
|
-
host = "hostname"
|
22
|
-
screen_name = "screen_name"
|
23
|
-
trigger = "trigger"
|
24
|
-
user = "user"
|
25
|
-
user2 = "user2"
|
26
|
-
usergroup = "SomeUserGroup"
|
27
|
-
graph = "graph"
|
28
|
-
mediatype = "somemediatype"
|
29
|
-
|
30
|
-
hostgroupid = 0
|
31
|
-
templateid = 0
|
32
|
-
applicationid = 0
|
33
|
-
itemid = 0
|
34
|
-
hostid = 0
|
35
|
-
triggerid = 0
|
36
|
-
userid = 0
|
37
|
-
usergroupid = 0
|
38
|
-
graphid = 0
|
39
|
-
screenid = 0
|
40
|
-
mediatypeid = 0
|
41
|
-
|
42
|
-
|
43
|
-
puts "### Zabbix API server version #{zbx.server.version} ###"
|
44
|
-
|
45
|
-
describe ZabbixApi do
|
46
|
-
|
47
|
-
it "SERVER: Get version api" do
|
48
|
-
zbx.server.version.should be_kind_of(String)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "HOSTGROUP: Create" do
|
52
|
-
hostgroupid = zbx.hostgroups.create(:name => hostgroup)
|
53
|
-
hostgroupid.should be_kind_of(Integer)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "HOSTGROUP: Find" do
|
57
|
-
zbx.hostgroups.get_id(:name => hostgroup).should eq hostgroupid
|
58
|
-
end
|
59
|
-
|
60
|
-
it "HOSTGROUP: Find unknown" do
|
61
|
-
zbx.hostgroups.get_id(:name => "#{hostgroup}______").should be_kind_of(NilClass)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "HOSTGROUP: Create or get" do
|
65
|
-
zbx.hostgroups.get_or_create(:name => hostgroup).should eq hostgroupid
|
66
|
-
end
|
67
|
-
|
68
|
-
it "HOSTGROUP: Create or update" do
|
69
|
-
zbx.hostgroups.create_or_update(:name => hostgroup).should eq hostgroupid
|
70
|
-
end
|
71
|
-
|
72
|
-
it "HOSTGROUP: Get all" do
|
73
|
-
zbx.hostgroups.all.should include(hostgroup=>hostgroupid.to_s)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "TEMPLATE: Create" do
|
77
|
-
templateid = zbx.templates.create(
|
78
|
-
:host => template,
|
79
|
-
:groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
|
80
|
-
)
|
81
|
-
templateid.should be_kind_of(Integer)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "TEMPLATE: Get get or create" do
|
85
|
-
zbx.templates.get_or_create(
|
86
|
-
:host => template,
|
87
|
-
:groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
|
88
|
-
).should eq templateid
|
89
|
-
end
|
90
|
-
|
91
|
-
it "TEMPLATE: Check full data" do
|
92
|
-
zbx.templates.get_full_data(:host => template)[0].should include("host"=>template)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "TEMPLATE: Find" do
|
96
|
-
zbx.templates.get_id(:host => template).should eq templateid
|
97
|
-
end
|
98
|
-
|
99
|
-
it "TEMPLATE: Find unknown" do
|
100
|
-
zbx.templates.get_id(:host => "#{template}_____").should be_kind_of(NilClass)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "APPLICATION: Create" do
|
104
|
-
applicationid = zbx.applications.create(
|
105
|
-
:name => application,
|
106
|
-
:hostid => zbx.templates.get_id(:host => template)
|
107
|
-
)
|
108
|
-
applicationid.should be_kind_of(Integer)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "APPLICATION: Get or create" do
|
112
|
-
zbx.applications.get_or_create(
|
113
|
-
:name => application,
|
114
|
-
:hostid => zbx.templates.get_id(:host => template)
|
115
|
-
).should eq applicationid
|
116
|
-
end
|
117
|
-
|
118
|
-
it "APPLICATION: Full info check" do
|
119
|
-
zbx.applications.get_full_data(:name => application)[0].should include("name"=>application)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "APPLICATION: Find" do
|
123
|
-
zbx.applications.get_id(:name => application).should eq applicationid
|
124
|
-
end
|
125
|
-
|
126
|
-
it "APPLICATION: Find unknown" do
|
127
|
-
zbx.applications.get_id(:name => "#{application}___").should be_kind_of(NilClass)
|
128
|
-
end
|
129
|
-
|
130
|
-
it "ITEM: Create" do
|
131
|
-
itemid = zbx.items.create(
|
132
|
-
:description => item,
|
133
|
-
:key_ => "proc.num[aaa]",
|
134
|
-
:hostid => zbx.templates.get_id(:host => template),
|
135
|
-
:applications => [zbx.applications.get_id(:name => application)]
|
136
|
-
)
|
137
|
-
itemid.should be_kind_of(Integer)
|
138
|
-
end
|
139
|
-
|
140
|
-
it "ITEM: Full info check" do
|
141
|
-
zbx.items.get_full_data(:description => item)[0].should include("description"=>item)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "ITEM: Find" do
|
145
|
-
zbx.items.get_id(:description => item).should eq itemid
|
146
|
-
end
|
147
|
-
|
148
|
-
it "ITEM: Update" do
|
149
|
-
zbx.items.update(
|
150
|
-
:itemid => zbx.items.get_id(:description => item),
|
151
|
-
:status => 1
|
152
|
-
).should eq itemid
|
153
|
-
end
|
154
|
-
|
155
|
-
it "ITEM: Create or update (update)" do
|
156
|
-
zbx.items.create_or_update(
|
157
|
-
:description => item,
|
158
|
-
:key_ => "proc.num[aaa]",
|
159
|
-
:status => 0,
|
160
|
-
:hostid => zbx.templates.get_id(:host => template),
|
161
|
-
:applications => [zbx.applications.get_id(:name => application)]
|
162
|
-
).should eq itemid
|
163
|
-
end
|
164
|
-
|
165
|
-
it "ITEM: Create or update (create)" do
|
166
|
-
zbx.items.create_or_update(
|
167
|
-
:description => item + "____1",
|
168
|
-
:key_ => "proc.num[aaabb]",
|
169
|
-
:status => 0,
|
170
|
-
:hostid => zbx.templates.get_id(:host => template),
|
171
|
-
:applications => [zbx.applications.get_id(:name => application)]
|
172
|
-
).should eq itemid + 1
|
173
|
-
end
|
174
|
-
|
175
|
-
it "ITEM: Get unknown" do
|
176
|
-
zbx.items.get_id(:description => "#{item}_____").should be_kind_of(NilClass)
|
177
|
-
end
|
178
|
-
|
179
|
-
it "HOST: Create" do
|
180
|
-
hostid = zbx.hosts.create(
|
181
|
-
:host => host,
|
182
|
-
:ip => "10.20.48.88",
|
183
|
-
:groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
|
184
|
-
)
|
185
|
-
hostid.should be_kind_of(Integer)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "HOST: Update or create (update)" do
|
189
|
-
zbx.hosts.create_or_update(
|
190
|
-
:host => host,
|
191
|
-
:ip => "10.20.48.89",
|
192
|
-
:groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
|
193
|
-
).should eq hostid
|
194
|
-
end
|
195
|
-
|
196
|
-
it "HOST: Find unknown" do
|
197
|
-
zbx.hosts.get_id(:host => "#{host}___").should be_kind_of(NilClass)
|
198
|
-
end
|
199
|
-
|
200
|
-
it "HOST: Find" do
|
201
|
-
zbx.hosts.get_id(:host => host).should eq hostid
|
202
|
-
end
|
203
|
-
|
204
|
-
it "HOST: Update" do
|
205
|
-
zbx.hosts.update(
|
206
|
-
:hostid => zbx.hosts.get_id(:host => host),
|
207
|
-
:status => 0
|
208
|
-
).should eq hostid
|
209
|
-
end
|
210
|
-
|
211
|
-
it "TEMPLATE: Update hosts with templates" do
|
212
|
-
zbx.templates.mass_update(
|
213
|
-
:hosts_id => [zbx.hosts.get_id(:host => host)],
|
214
|
-
:templates_id => [zbx.templates.get_id(:host => template)]
|
215
|
-
).should be_kind_of(TrueClass)
|
216
|
-
end
|
217
|
-
|
218
|
-
it "TEMPLATE: Get all templates linked with host" do
|
219
|
-
tmpl_array = zbx.templates.get_ids_by_host(
|
220
|
-
:hostids => [zbx.hosts.get_id(:host => host)]
|
221
|
-
)
|
222
|
-
tmpl_array.should be_kind_of(Array)
|
223
|
-
tmpl_array.should include templateid.to_s
|
224
|
-
end
|
225
|
-
|
226
|
-
it "TEMPLATE: Linked hosts with templates" do
|
227
|
-
zbx.templates.mass_add(
|
228
|
-
:hosts_id => [zbx.hosts.get_id(:host => host)],
|
229
|
-
:templates_id => [zbx.templates.get_id(:host => template)]
|
230
|
-
).should be_kind_of(TrueClass)
|
231
|
-
end
|
232
|
-
|
233
|
-
it "TEMPLATE: Get all" do
|
234
|
-
zbx.templates.all.should include(template=>templateid.to_s)
|
235
|
-
end
|
236
|
-
|
237
|
-
it "TRIGGER: Create" do
|
238
|
-
triggerid = zbx.triggers.create(
|
239
|
-
:description => trigger,
|
240
|
-
:expression => "{#{template}:proc.num[aaa].last(0)}<1",
|
241
|
-
:comments => "Bla-bla is faulty (disaster)",
|
242
|
-
:priority => 5,
|
243
|
-
:status => 0,
|
244
|
-
:templateid => 0,
|
245
|
-
:type => 0
|
246
|
-
)
|
247
|
-
triggerid.should be_kind_of(Integer)
|
248
|
-
end
|
249
|
-
|
250
|
-
it "TRIGGER: Find" do
|
251
|
-
zbx.triggers.get_id(:description => trigger).should eq triggerid + 1 # вау блять
|
252
|
-
end
|
253
|
-
|
254
|
-
it "GRAPH: Create" do
|
255
|
-
gitems = {
|
256
|
-
:itemid => zbx.items.get_id(:description => item),
|
257
|
-
:calc_fnc => "2",
|
258
|
-
:type => "0",
|
259
|
-
:periods_cnt => "5"
|
260
|
-
}
|
261
|
-
graphid = zbx.graphs.create(
|
262
|
-
:gitems => [gitems],
|
263
|
-
:show_triggers => "0",
|
264
|
-
:name => graph,
|
265
|
-
:width => "900",
|
266
|
-
:height => "200"
|
267
|
-
)
|
268
|
-
graphid.should be_kind_of(Integer)
|
269
|
-
end
|
270
|
-
|
271
|
-
it "GRAPH: Create or get" do
|
272
|
-
gitems = {
|
273
|
-
:itemid => zbx.items.get_id(:description => item),
|
274
|
-
:calc_fnc => "2",
|
275
|
-
:type => "0",
|
276
|
-
:periods_cnt => "5"
|
277
|
-
}
|
278
|
-
zbx.graphs.get_or_create(
|
279
|
-
:gitems => [gitems],
|
280
|
-
:show_triggers => "0",
|
281
|
-
:name => graph,
|
282
|
-
:width => "900",
|
283
|
-
:height => "200"
|
284
|
-
).should eq graphid
|
285
|
-
end
|
286
|
-
|
287
|
-
it "GRAPH: Find gititems" do
|
288
|
-
zbx.graphs.get_items( zbx.graphs.get_id(:name => graph) )
|
289
|
-
end
|
290
|
-
|
291
|
-
it "GRAPH: Find" do
|
292
|
-
zbx.graphs.get_id( :name => graph ).should eq graphid
|
293
|
-
end
|
294
|
-
|
295
|
-
it "GRAPH: get_ids_by_host" do
|
296
|
-
graph_array = zbx.graphs.get_ids_by_host( :host => host )
|
297
|
-
graph_array.should be_kind_of(Array)
|
298
|
-
graph_array.should include(graphid.to_s)
|
299
|
-
end
|
300
|
-
|
301
|
-
it "GRAPH: Update" do
|
302
|
-
zbx.graphs.update(
|
303
|
-
:graphid => zbx.graphs.get_id(
|
304
|
-
:name => graph,
|
305
|
-
:hostid => zbx.hosts.get_id(:host => host)
|
306
|
-
),
|
307
|
-
:ymax_type => 1
|
308
|
-
).should eq graphid
|
309
|
-
end
|
310
|
-
|
311
|
-
it "GRAPH: Create or Update" do
|
312
|
-
gitems = {
|
313
|
-
:itemid => zbx.items.get_id(:description => item),
|
314
|
-
:calc_fnc => "3",
|
315
|
-
:type => "0",
|
316
|
-
:periods_cnt => "5"
|
317
|
-
}
|
318
|
-
zbx.graphs.create_or_update(
|
319
|
-
:gitems => [gitems],
|
320
|
-
:show_triggers => "1",
|
321
|
-
:name => graph,
|
322
|
-
:width => "900",
|
323
|
-
:height => "200"
|
324
|
-
).should eq graphid
|
325
|
-
end
|
326
|
-
|
327
|
-
it "SCREEN: Get or create for host" do
|
328
|
-
screenid = zbx.screens.get_or_create_for_host(
|
329
|
-
:screen_name => screen_name,
|
330
|
-
:graphids => zbx.graphs.get_ids_by_host(:host => host)
|
331
|
-
)
|
332
|
-
screenid.should be_kind_of(Integer)
|
333
|
-
end
|
334
|
-
|
335
|
-
it "TEMPLATE: Unlink hosts from templates" do
|
336
|
-
zbx.templates.mass_remove(
|
337
|
-
:hosts_id => [zbx.hosts.get_id(:host => host)],
|
338
|
-
:templates_id => [zbx.templates.get_id(:host => template)]
|
339
|
-
).should be_kind_of(TrueClass)
|
340
|
-
end
|
341
|
-
|
342
|
-
it "SCREEN: Delete" do
|
343
|
-
zbx.screens.delete(:screen_id => screenid).should eq screenid
|
344
|
-
end
|
345
|
-
|
346
|
-
it "GRAPH: Delete" do
|
347
|
-
zbx.graphs.delete(zbx.graphs.get_id(:name => graph)).should be_kind_of(TrueClass)
|
348
|
-
end
|
349
|
-
|
350
|
-
it "TRIGGER: Delete" do
|
351
|
-
zbx.triggers.delete( zbx.triggers.get_id(:description => trigger) ).should eq triggerid + 1
|
352
|
-
end
|
353
|
-
|
354
|
-
it "HOST: Delete" do
|
355
|
-
zbx.hosts.delete( zbx.hosts.get_id(:host => host) ).should eq hostid
|
356
|
-
end
|
357
|
-
|
358
|
-
it "ITEM: Delete" do
|
359
|
-
zbx.items.delete(
|
360
|
-
zbx.items.get_id(:description => item)
|
361
|
-
).should eq itemid
|
362
|
-
end
|
363
|
-
|
364
|
-
it "APPLICATION: Delete" do
|
365
|
-
zbx.applications.delete( zbx.applications.get_id(:name => application) ).should eq applicationid
|
366
|
-
end
|
367
|
-
|
368
|
-
it "TEMPLATE: Delete" do
|
369
|
-
zbx.templates.delete(zbx.templates.get_id(:host => template)).should eq templateid
|
370
|
-
end
|
371
|
-
|
372
|
-
it "HOSTGROUP: Delete" do
|
373
|
-
zbx.hostgroups.delete(
|
374
|
-
zbx.hostgroups.get_id(:name => hostgroup)
|
375
|
-
).should eq hostgroupid
|
376
|
-
end
|
377
|
-
|
378
|
-
it "USER: Create" do
|
379
|
-
userid = zbx.users.create(
|
380
|
-
:alias => "Test #{user}",
|
381
|
-
:name => user,
|
382
|
-
:surname => user,
|
383
|
-
:passwd => user
|
384
|
-
)
|
385
|
-
userid.should be_kind_of(Integer)
|
386
|
-
end
|
387
|
-
|
388
|
-
it "USER: Create or update" do
|
389
|
-
zbx.users.create_or_update(
|
390
|
-
:alias => "Test #{user}",
|
391
|
-
:name => user,
|
392
|
-
:surname => user,
|
393
|
-
:passwd => user
|
394
|
-
).should eq userid
|
395
|
-
end
|
396
|
-
|
397
|
-
it "USER: Find" do
|
398
|
-
zbx.users.get_full_data(:name => user)[0]['name'].should be_kind_of(String)
|
399
|
-
end
|
400
|
-
|
401
|
-
it "USER: Update" do
|
402
|
-
zbx.users.update(:userid => zbx.users.get_id(:name => user), :name => user2).should be_kind_of(Integer)
|
403
|
-
end
|
404
|
-
|
405
|
-
it "USER: Find unknown" do
|
406
|
-
zbx.users.get_id(:name => "#{user}_____").should be_kind_of(NilClass)
|
407
|
-
end
|
408
|
-
|
409
|
-
it "USERGROUPS: Create" do
|
410
|
-
usergroupid = zbx.usergroups.create(:name => usergroup)
|
411
|
-
usergroupid.should be_kind_of(Integer)
|
412
|
-
end
|
413
|
-
|
414
|
-
it "USERGROUPS: Create or update" do
|
415
|
-
zbx.usergroups.get_or_create(:name => usergroup).should eq usergroupid
|
416
|
-
end
|
417
|
-
|
418
|
-
it "USERGROUPS: Add user" do
|
419
|
-
zbx.usergroups.add_user(
|
420
|
-
:usrgrpids => [zbx.usergroups.get_id(:name => usergroup)],
|
421
|
-
:userids => [zbx.users.get_id(:name => user2)]
|
422
|
-
).should eq usergroupid
|
423
|
-
end
|
424
|
-
|
425
|
-
it "USERGROUPS: Set UserGroup read & write perm" do
|
426
|
-
zbx.usergroups.set_perms(
|
427
|
-
:usrgrpid => zbx.usergroups.get_or_create(:name => usergroup).to_s,
|
428
|
-
:hostgroupids => zbx.hostgroups.all.values,
|
429
|
-
:permission => 3
|
430
|
-
).should eq usergroupid
|
431
|
-
end
|
432
|
-
|
433
|
-
it "MEDIATYPE: Create" do
|
434
|
-
mediatypeid = zbx.mediatypes.create(
|
435
|
-
:description => mediatype,
|
436
|
-
:type => 0,
|
437
|
-
:smtp_server => "127.0.0.1",
|
438
|
-
:smtp_email => "zabbix@test.com"
|
439
|
-
)
|
440
|
-
mediatypeid.should be_kind_of(Integer)
|
441
|
-
end
|
442
|
-
|
443
|
-
it "MEDIATYPE: Update or create" do
|
444
|
-
zbx.mediatypes.create_or_update(
|
445
|
-
:description => mediatype,
|
446
|
-
:smtp_email => "zabbix2@test.com"
|
447
|
-
).should eq mediatypeid
|
448
|
-
end
|
449
|
-
|
450
|
-
it "USER: Add mediatype" do
|
451
|
-
zbx.users.add_medias(
|
452
|
-
:userids => [zbx.users.get_id(:name => user2)],
|
453
|
-
:media => [
|
454
|
-
{
|
455
|
-
:mediatypeid => zbx.mediatypes.get_id(:description => mediatype),
|
456
|
-
:sendto => "test@test",
|
457
|
-
:active => 0,
|
458
|
-
:period => "1-7,00:00-24:00",
|
459
|
-
:severity => "56"
|
460
|
-
}
|
461
|
-
]
|
462
|
-
).should eq userid
|
463
|
-
end
|
464
|
-
|
465
|
-
it "MEDIATYPE: Delete" do
|
466
|
-
zbx.mediatypes.delete(
|
467
|
-
zbx.mediatypes.get_id(:description => mediatype)
|
468
|
-
).should eq mediatypeid
|
469
|
-
end
|
470
|
-
|
471
|
-
it "USER: Delete" do
|
472
|
-
zbx.users.delete(zbx.users.get_id(:name => user2)).should eq userid
|
473
|
-
end
|
474
|
-
|
475
|
-
it "USERGROUPS: Delete" do
|
476
|
-
zbx.usergroups.delete([zbx.usergroups.get_id(:name => usergroup)]).should eq usergroupid
|
477
|
-
end
|
478
|
-
|
479
|
-
it "QUERY" do
|
480
|
-
zbx.query(
|
481
|
-
:method => "apiinfo.version",
|
482
|
-
:params => {}
|
483
|
-
).should be_kind_of(String)
|
484
|
-
end
|
485
|
-
|
486
|
-
end
|