zabbixapi 2.4.8 → 2.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9993377c6f344fef920fc248798eec2d010ba7ec
4
- data.tar.gz: 96bb61c40517a55efd1f0ca1c2dde18c7d24677b
3
+ metadata.gz: 3b0c4d39286a5204648a76628cc643fb5155ed4a
4
+ data.tar.gz: a8076c8cd8f418d0dd40828ac430cd7409285f54
5
5
  SHA512:
6
- metadata.gz: 482de14774541ede7972c80dd4b082539412f5b7bfa08ccf9b2fedcc066b415319e6226665c691f4688417b2b1647256af08751c7d70ec8c59c50932ae558f46
7
- data.tar.gz: 246494db24bc2cc0527459d6874f2054e58259910f9f21db23375b82ea064c3aeef882993a9e68ae4e901fa725fa3d5e2aab7c2ad4b0aa380fbd7a254958850f
6
+ metadata.gz: 9ceb26cc5e2ddff7674a0f5beefe99bcdf91639eb280d39862daf110d652b05aa40433ec77c8c709d37ffb19153f27529140f54bcad60ce885369bbbd9b761e0
7
+ data.tar.gz: 1628507b889ce7cb58b72218fb3205f41e219276a0195669f73146408b000c5037d1729ff1687e085dc20efdafa9b7140dc5e1f15586df2ee2e4b72079c50b61
@@ -1,7 +1,17 @@
1
1
  language:
2
2
  - ruby
3
3
  addons:
4
- postgresql: "9.5"
4
+ postgresql: '9.5'
5
+ apt:
6
+ sources:
7
+ - sourceline: 'deb http://repo.zabbix.com/zabbix/3.0/ubuntu/ trusty main'
8
+ key_url: 'http://repo.zabbix.com/zabbix-official-repo.key'
9
+ packages:
10
+ - php5-pgsql
11
+ - zabbix-frontend-php
12
+ - zabbix-server-pgsql
13
+ services:
14
+ - postgresql
5
15
  rvm:
6
16
  - 1.9.3
7
17
  - 2.0
@@ -11,26 +21,10 @@ dist: trusty
11
21
  sudo: required
12
22
 
13
23
  before_script:
14
- - sudo apt-get purge postgresql-9.1 postgresql-9.2 postgresql-9.3 postgresql-9.4 -y
15
- # - wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
16
- # - echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | sudo tee /etc/apt/sources.list.d/postgresql.list
17
- - wget -qO - http://repo.zabbix.com/zabbix-official-repo.key | sudo apt-key add -
18
- - echo "deb http://repo.zabbix.com/zabbix/3.0/ubuntu/ trusty main" | sudo tee /etc/apt/sources.list.d/zabbix.list
19
- - sudo apt-get update
20
- - sudo dpkg-reconfigure locales
21
- - sudo apt-get install curl -y
22
- - sudo apt-get install apache2 -y
23
- - sudo apt-get install libiodbc2 -y
24
- - sudo apt-get install zabbix-frontend-php -y
25
- - sudo useradd -r zabbix
26
- - sudo apt-get install zabbix-server-pgsql -y
27
- - sudo apt-get install php5-pgsql -y
28
24
  - sudo sed -i "s,;date.timezone =,date.timezone = 'US/Eastern'," /etc/php5/apache2/php.ini
29
- - 'echo -e "local all postgres trust\nlocal all all trust\nhost all all 127.0.0.1/32 trust\nhost all all ::1/128 trust" | sudo tee /etc/postgresql/9.5/main/pg_hba.conf'
30
- - sudo /etc/init.d/postgresql restart
31
- - sudo pg_ctlcluster 9.5 main reload
32
- - sudo -u postgres createdb zabbix
33
- - sudo -u postgres createuser -a -d -E zabbix
25
+ - psql -c 'create database zabbix;' -U postgres
26
+ - psql -c 'create user zabbix;' -U postgres
27
+ - psql -c 'grant all privileges on database zabbix to zabbix;' -U postgres
34
28
  - zcat /usr/share/doc/zabbix-server-pgsql/create.sql.gz | LC_ALL=C psql -U zabbix
35
29
  - echo "$(curl -fsSL https://gist.githubusercontent.com/evtuhovich/9544441/raw/d661863063b76cc8e2599bc44d8595b1f86ece38/zabbix)" | sudo tee /etc/zabbix/web/zabbix.conf.php
36
30
  - sudo service apache2 restart
@@ -1,3 +1,10 @@
1
+ ## 2.4.9
2
+
3
+ [PR #55](https://github.com/express42/zabbixapi/pull/55) Add 3.2.x support (Thanx @jrbeilke)
4
+
5
+ [PR #54](https://github.com/express42/zabbixapi/pull/54) Add web scenarios support (Thanx @jrbeilke)
6
+
7
+
1
8
  ## 2.4.7
2
9
 
3
10
  [PR #45](https://github.com/express42/zabbixapi/pull/45) Add support for zabbix 3.0.x (Thanx @wandenberg)
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem "rspec"
4
4
  gem "rake"
5
- gem "json"
5
+ gem "json"
@@ -1,8 +1,8 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
- json (1.6.1)
5
+ json (1.8.3)
6
6
  rake (0.9.2.2)
7
7
  rspec (2.12.0)
8
8
  rspec-core (~> 2.12.0)
data/README.md CHANGED
@@ -11,6 +11,7 @@ Simple and lightweight ruby module for work with zabbix api
11
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
12
  * 2.4.x (api version 2.2.x) /zabbixapi 2.4.x [master](https://github.com/express42/zabbixapi/)
13
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/)
14
15
 
15
16
  Because Zabbix 3.0 is a main branch of Zabbix, so master of zabbixapi supports this version of zabbix.
16
17
 
@@ -257,7 +258,17 @@ zbx.triggers.create(
257
258
  :priority => 5,
258
259
  :status => 0,
259
260
  :templateid => 0,
260
- :type => 0
261
+ :type => 0,
262
+ :tags => [
263
+ {
264
+ :tag => "process",
265
+ :value => "aaa"
266
+ },
267
+ {
268
+ :tag => "error",
269
+ :value => ""
270
+ }
271
+ ]
261
272
  )
262
273
  ```
263
274
 
@@ -275,6 +286,110 @@ triggers = zbx.query(
275
286
  )
276
287
  ```
277
288
 
289
+ ### Create Web Scenario (httptest)
290
+ ```ruby
291
+ zbx.httptests.create(
292
+ :name => "web scenario",
293
+ :hostid => zbx.templates.get_id(:host => "template"),
294
+ :applicationid => zbx.applications.get_id(:name => "application"),
295
+ :steps => [
296
+ {
297
+ :name => "step",
298
+ :url => "http://localhost/zabbix/",
299
+ :status_codes => 200,
300
+ :no => 1
301
+ }
302
+ ]
303
+ )
304
+ # or use (lib merge json):
305
+ zbx.httptests.create_or_update(
306
+ :name => "web scenario",
307
+ :hostid => zbx.templates.get_id(:host => "template"),
308
+ :applicationid => zbx.applications.get_id(:name => "application"),
309
+ :steps => [
310
+ {
311
+ :name => "step",
312
+ :url => "http://localhost/zabbix/",
313
+ :status_codes => 200,
314
+ :no => 1
315
+ },
316
+ {
317
+ :name => "step 2",
318
+ :url => "http://localhost/zabbix/index.php",
319
+ :status_codes => 200,
320
+ :no => 2
321
+ }
322
+ ]
323
+ )
324
+ ```
325
+
326
+ ### Update Web Scenario (httptest)
327
+ ```ruby
328
+ zbx.httptests.update(
329
+ :httptestid => zbx.httptests.get_id(:name => "web scenario"),
330
+ :status => 0
331
+ )
332
+ #You can check web scenario:
333
+ puts zbx.httptests.get_full_data(:name => "web scenario")
334
+
335
+ ### Create action based on trigger
336
+ ```ruby
337
+ zbx.actions.create(
338
+ :name => "trigger action",
339
+ :eventsource => '0', # event source is a triggerid
340
+ :status => '0', # action is enabled
341
+ :esc_period => '120', # how long each step should take
342
+ :def_shortdata => "Email header",
343
+ :def_longdata => "Email content",
344
+ :maintenance_mode => '1',
345
+ :filter => {
346
+ :evaltype => '1', # perform 'and' between the conditions
347
+ :conditions => [
348
+ {
349
+ :conditiontype => '3', # trigger name
350
+ :operator => '2', # like
351
+ :value => 'pattern' # the pattern
352
+ },
353
+ {
354
+ :conditiontype => '4', # trigger severity
355
+ :operator => '5', # >=
356
+ :value => '3' # average
357
+ }
358
+ ]
359
+ },
360
+ :operations => [
361
+ {
362
+ :operationtype => '0', # send message
363
+ :opmessage_grp => [ # who the message will be sent to
364
+ {
365
+ :usrgrpid => '2'
366
+ }
367
+ ],
368
+ :opmessage => {
369
+ :default_msg => '0', # use default message
370
+ :mediatypeid => '1' # email id
371
+ }
372
+ }
373
+ ],
374
+ :recovery_operations => [
375
+ {
376
+ :operationtype => '11', # send recovery message
377
+ :opmessage_grp => [ # who the message will be sent to
378
+ {
379
+ :usrgrpid => '2'
380
+ }
381
+ ],
382
+ :opmessage => {
383
+ :default_msg => '0', # use default message
384
+ :mediatypeid => '1' # email id
385
+ }
386
+ }
387
+ ]
388
+ )
389
+ # In Zabbix 3.2 and higher actions now have a maintenance_mode property which pauses notifications during host maintenance
390
+ # A separate action condition for Maintenance status = not in “maintenance” is no longer needed
391
+ ```
392
+
278
393
  ### Create user
279
394
  ```ruby
280
395
  zbx.users.create(
@@ -12,6 +12,7 @@ require "zabbixapi/classes/graphs"
12
12
  require "zabbixapi/classes/hostgroups"
13
13
  require "zabbixapi/classes/maintenance"
14
14
  require "zabbixapi/classes/hosts"
15
+ require "zabbixapi/classes/httptests"
15
16
  require "zabbixapi/classes/items"
16
17
  require "zabbixapi/classes/mediatypes"
17
18
  require "zabbixapi/classes/proxies"
@@ -62,6 +63,10 @@ class ZabbixApi
62
63
  @hosts ||= Hosts.new(@client)
63
64
  end
64
65
 
66
+ def httptests
67
+ @httptests ||= HttpTests.new(@client)
68
+ end
69
+
65
70
  def applications
66
71
  @applications ||= Applications.new(@client)
67
72
  end
@@ -0,0 +1,25 @@
1
+ class ZabbixApi
2
+ class HttpTests < Basic
3
+
4
+ def method_name
5
+ "httptest"
6
+ end
7
+
8
+ def indentify
9
+ "name"
10
+ end
11
+
12
+ def default_options
13
+ {
14
+ :hostid => nil,
15
+ :name => nil,
16
+ :steps => []
17
+ }
18
+ end
19
+
20
+ def create_or_update(data)
21
+ httptestid = get_id(:name => data[:name])
22
+ httptestid ? update(data.merge(:httptestid => httptestid)) : create(data)
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = "2.4.8"
2
+ VERSION = "2.4.9"
3
3
  end
@@ -13,6 +13,7 @@ describe 'action' do
13
13
  :esc_period => '120', # how long each step should take
14
14
  :def_shortdata => "Email header",
15
15
  :def_longdata => "Email content",
16
+ :maintenance_mode => '1',
16
17
  :filter => {
17
18
  :evaltype => '1', # perform 'and' between the conditions
18
19
  :conditions => [
@@ -21,11 +22,6 @@ describe 'action' do
21
22
  :operator => '2', # like
22
23
  :value => 'pattern' # the pattern
23
24
  },
24
- {
25
- :conditiontype => '5', # trigger value
26
- :operator => '0', # equal
27
- :value => '1' # 'on'
28
- },
29
25
  {
30
26
  :conditiontype => '4', # trigger severity
31
27
  :operator => '5', # >=
@@ -46,6 +42,20 @@ describe 'action' do
46
42
  :mediatypeid => '1' # email id
47
43
  }
48
44
  }
45
+ ],
46
+ :recovery_operations => [
47
+ {
48
+ :operationtype => '11', # send recovery message
49
+ :opmessage_grp => [ # who the message will be sent to
50
+ {
51
+ :usrgrpid => @usergroupid
52
+ }
53
+ ],
54
+ :opmessage => {
55
+ :default_msg => '0', # use default message
56
+ :mediatypeid => '1' # email id
57
+ }
58
+ }
49
59
  ]
50
60
  }
51
61
  end
@@ -0,0 +1,136 @@
1
+ #encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'httptest' do
6
+ before :all do
7
+ @hostgroup = gen_name 'hostgroup'
8
+ @hostgroupid = zbx.hostgroups.create(:name => @hostgroup)
9
+ @template = gen_name 'template'
10
+ @templateid = zbx.templates.create(
11
+ :host => @template,
12
+ :groups => [:groupid => @hostgroupid]
13
+ )
14
+ end
15
+
16
+ context 'when name not exists' do
17
+ before do
18
+ @httptest_name = gen_name 'httptest_name'
19
+ @step_name = gen_name 'step_name'
20
+ end
21
+
22
+ describe 'create' do
23
+ it "should return integer id" do
24
+ httptestid = zbx.httptests.create(
25
+ :name => @httptest_name,
26
+ :hostid => @templateid,
27
+ :steps => [
28
+ {
29
+ :name => @step_name,
30
+ :url => "http://localhost/zabbix/",
31
+ :status_codes => 200,
32
+ :no => 1
33
+ }
34
+ ]
35
+ )
36
+ expect(httptestid).to be_kind_of(Integer)
37
+ end
38
+ end
39
+
40
+ describe 'get_id' do
41
+ it "should return nil" do
42
+ expect(zbx.httptests.get_id(:name => @httptest_name)).to be_kind_of(NilClass)
43
+ expect(zbx.httptests.get_id('name' => @httptest_name)).to be_kind_of(NilClass)
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'when name exists' do
49
+ before :all do
50
+ @httptest_name = gen_name 'httptest_name'
51
+ @step_name = gen_name 'step_name'
52
+ @httptestid = zbx.httptests.create(
53
+ :name => @httptest_name,
54
+ :hostid => @templateid,
55
+ :steps => [
56
+ {
57
+ :name => @step_name,
58
+ :url => "http://localhost/zabbix/",
59
+ :status_codes => 200,
60
+ :no => 1
61
+ }
62
+ ]
63
+ )
64
+ end
65
+
66
+ describe 'get_or_create' do
67
+ it "should return id of httptest" do
68
+ expect(zbx.httptests.get_or_create(
69
+ :name => @httptest_name,
70
+ :hostid => @templateid,
71
+ :steps => [
72
+ {
73
+ :name => @step_name,
74
+ :url => "http://localhost/zabbix/",
75
+ :status_codes => 200,
76
+ :no => 1
77
+ }
78
+ ]
79
+ )).to eq @httptestid
80
+ end
81
+ end
82
+
83
+ describe 'get_full_data' do
84
+ it "should contain created httptest" do
85
+ expect(zbx.httptests.get_full_data(:name => @httptest_name)[0]).to include("name" => @httptest_name)
86
+ end
87
+ end
88
+
89
+ describe 'get_id' do
90
+ it "should return id of httptest" do
91
+ expect(zbx.httptests.get_id(:name => @httptest_name)).to eq @httptestid
92
+ expect(zbx.httptests.get_id('name' => @httptest_name)).to eq @httptestid
93
+ end
94
+ end
95
+
96
+ describe 'create_or_update' do
97
+ it "should return id of updated httptest" do
98
+ expect(zbx.httptests.create_or_update(
99
+ :name => @httptest_name,
100
+ :hostid => @templateid,
101
+ :steps => [
102
+ {
103
+ :name => @step_name,
104
+ :url => "http://localhost/zabbix/",
105
+ :status_codes => 200,
106
+ :no => 1
107
+ }
108
+ ]
109
+ )).to eq @httptestid
110
+ end
111
+ end
112
+
113
+ describe 'update' do
114
+ it "should return id" do
115
+ expect(zbx.httptests.update(
116
+ :httptestid => @httptestid,
117
+ :status => 0,
118
+ :steps => [
119
+ {
120
+ :name => @step_name,
121
+ :url => "http://localhost/zabbix/",
122
+ :status_codes => 200,
123
+ :no => 1
124
+ }
125
+ ]
126
+ )).to eq @httptestid
127
+ end
128
+ end
129
+
130
+ describe 'delete' do
131
+ it "HTTPTEST: Delete" do
132
+ expect(zbx.httptests.delete( @httptestid )).to eq @httptestid
133
+ end
134
+ end
135
+ end
136
+ end
@@ -38,8 +38,18 @@ describe "trigger" do
38
38
  :expression => "{#{@template}:#{@proc}.last(0)}<1",
39
39
  :comments => "Bla-bla is faulty (disaster)",
40
40
  :priority => 5,
41
- :status => 0,
42
- :type => 0
41
+ :status => 0,
42
+ :type => 0,
43
+ :tags => [
44
+ {
45
+ :tag => "proc",
46
+ :value => "#{@proc}"
47
+ },
48
+ {
49
+ :tag => "error",
50
+ :value => ""
51
+ }
52
+ ]
43
53
  )
44
54
  expect(triggerid).to be_kind_of(Integer)
45
55
  end
@@ -54,8 +64,18 @@ describe "trigger" do
54
64
  :expression => "{#{@template}:#{@proc}.last(0)}<1",
55
65
  :comments => "Bla-bla is faulty (disaster)",
56
66
  :priority => 5,
57
- :status => 0,
58
- :type => 0
67
+ :status => 0,
68
+ :type => 0,
69
+ :tags => [
70
+ {
71
+ :tag => "proc",
72
+ :value => "#{@proc}"
73
+ },
74
+ {
75
+ :tag => "error",
76
+ :value => ""
77
+ }
78
+ ]
59
79
  )
60
80
  end
61
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbixapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.8
4
+ version: 2.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliev D.V.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-16 00:00:00.000000000 Z
12
+ date: 2016-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -60,6 +60,7 @@ files:
60
60
  - lib/zabbixapi/classes/graphs.rb
61
61
  - lib/zabbixapi/classes/hostgroups.rb
62
62
  - lib/zabbixapi/classes/hosts.rb
63
+ - lib/zabbixapi/classes/httptests.rb
63
64
  - lib/zabbixapi/classes/items.rb
64
65
  - lib/zabbixapi/classes/maintenance.rb
65
66
  - lib/zabbixapi/classes/mediatypes.rb
@@ -81,6 +82,7 @@ files:
81
82
  - spec/graph.rb
82
83
  - spec/host.rb
83
84
  - spec/hostgroup.rb
85
+ - spec/httptest.rb
84
86
  - spec/item.rb
85
87
  - spec/maintenance.rb
86
88
  - spec/mediatype.rb
@@ -125,6 +127,7 @@ test_files:
125
127
  - spec/graph.rb
126
128
  - spec/host.rb
127
129
  - spec/hostgroup.rb
130
+ - spec/httptest.rb
128
131
  - spec/item.rb
129
132
  - spec/maintenance.rb
130
133
  - spec/mediatype.rb