zabbixapi 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zabbixapi.rb +4 -0
- data/lib/zabbixapi/basic/basic_logic.rb +8 -5
- data/lib/zabbixapi/classes/hostinterfaces.rb +19 -0
- data/lib/zabbixapi/version.rb +1 -1
- data/spec/host.rb +11 -6
- data/spec/hostinterface.rb +79 -0
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd481b02c9223088ad234cbca2b81d51bcc5916b
|
4
|
+
data.tar.gz: 32641a4d6a3f436ae4fb521f78f6e55c10b159dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 827a84f1bf076a63c25ef9c17d082e4e7d56290015023a7cfbf6e5e8efaacea67d88a35670079e59f77618eef59f371dbe6917f7238a8cbdcf6c16168e76c130
|
7
|
+
data.tar.gz: fa4c337f755a659da65cabca1bc598c063edc3fc25e63a4c021af04ce1e33497d38429fe00094c7a3e802d8f2779cd5b5b03c345dadb058e5de4d674a68a5fe3
|
data/lib/zabbixapi.rb
CHANGED
@@ -23,6 +23,7 @@ require "zabbixapi/classes/usergroups"
|
|
23
23
|
require "zabbixapi/classes/usermacros"
|
24
24
|
require "zabbixapi/classes/users"
|
25
25
|
require "zabbixapi/classes/configurations"
|
26
|
+
require "zabbixapi/classes/hostinterfaces"
|
26
27
|
|
27
28
|
class ZabbixApi
|
28
29
|
|
@@ -107,5 +108,8 @@ class ZabbixApi
|
|
107
108
|
@configurations ||= Configurations.new(@client)
|
108
109
|
end
|
109
110
|
|
111
|
+
def hostinterfaces
|
112
|
+
@hostinterfaces ||= Hostinterfaces.new(@client)
|
113
|
+
end
|
110
114
|
end
|
111
115
|
|
@@ -46,22 +46,25 @@ class ZabbixApi
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def get_full_data(data)
|
49
|
-
log "[DEBUG] Call get_full_data with parametrs: #{data.inspect}"
|
49
|
+
log "[DEBUG] Call get_full_data with parametrs: #{data.inspect} and params #{data[:params]}"
|
50
50
|
|
51
|
-
|
51
|
+
data[:params] ||= {}
|
52
|
+
res = @client.api_request(
|
52
53
|
:method => "#{method_name}.get",
|
53
54
|
:params => {
|
54
55
|
:filter => {
|
55
56
|
indentify.to_sym => data[indentify.to_sym]
|
56
57
|
},
|
57
58
|
:output => "extend"
|
58
|
-
}
|
59
|
+
}.merge(data[:params])
|
59
60
|
)
|
61
|
+
res
|
60
62
|
end
|
61
63
|
|
62
64
|
def dump_by_id(data)
|
63
|
-
log "[DEBUG] Call dump_by_id with parametrs: #{data.inspect}"
|
65
|
+
log "[DEBUG] Call dump_by_id with parametrs: #{data.inspect} and params #{data[:params]}"
|
64
66
|
|
67
|
+
data[:params] ||= {}
|
65
68
|
@client.api_request(
|
66
69
|
:method => "#{method_name}.get",
|
67
70
|
:params => {
|
@@ -69,7 +72,7 @@ class ZabbixApi
|
|
69
72
|
key.to_sym => data[key.to_sym]
|
70
73
|
},
|
71
74
|
:output => "extend"
|
72
|
-
}
|
75
|
+
}.merge(data[:params])
|
73
76
|
)
|
74
77
|
end
|
75
78
|
|
data/lib/zabbixapi/version.rb
CHANGED
data/spec/host.rb
CHANGED
@@ -36,15 +36,15 @@ describe 'host' do
|
|
36
36
|
@hostgroupid2 = zbx.hostgroups.create(:name => gen_name('hostgroup'))
|
37
37
|
host = gen_name('host')
|
38
38
|
hostid = zbx.hosts.create(
|
39
|
-
host
|
40
|
-
interfaces
|
41
|
-
groups
|
42
|
-
{groupid
|
43
|
-
{groupid
|
39
|
+
:host => host,
|
40
|
+
:interfaces => [{ :type => 1, :main => 1, :ip => '192.168.0.1', :dns => 'server.example.org', :port => 10050, :useip => 0 }],
|
41
|
+
:groups => [
|
42
|
+
{:groupid => @hostgroupid},
|
43
|
+
{:groupid => @hostgroupid2}
|
44
44
|
])
|
45
45
|
|
46
46
|
expect(hostid).to be_kind_of Integer
|
47
|
-
host = zbx.query(method
|
47
|
+
host = zbx.query(:method => 'host.get', :params => { :hostids => [hostid], :selectGroups => 'extend' }).first
|
48
48
|
|
49
49
|
expect(host['hostid'].to_i).to eq hostid
|
50
50
|
expect(host['groups'].size).to eq 2
|
@@ -90,6 +90,11 @@ describe 'host' do
|
|
90
90
|
it "should contains created host" do
|
91
91
|
expect(zbx.hosts.get_full_data(:host => @host)[0]).to include("host" => @host)
|
92
92
|
end
|
93
|
+
|
94
|
+
it "shoulld dump interfaces" do
|
95
|
+
expect(zbx.hosts.get_full_data(:host => @host, :params => {:selectInterfaces => "extend"})[0]["interfaces"][0]).to include("type" => "1")
|
96
|
+
expect(zbx.hosts.get_full_data(:host => @host, :params => {:selectInterfaces => "extend"})[0]["interfaces"][0]).to include("ip" => "10.20.48.88")
|
97
|
+
end
|
93
98
|
end
|
94
99
|
|
95
100
|
describe 'get_id' do
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "hostinterface" do
|
6
|
+
before :all do
|
7
|
+
@hostgroup = gen_name 'hostgroup'
|
8
|
+
@hostgroupid = zbx.hostgroups.create(:name => @hostgroup)
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when interface not exists' do
|
12
|
+
before do
|
13
|
+
@host = gen_name 'host'
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'create' do
|
17
|
+
it 'should return integer id' do
|
18
|
+
@hostid = zbx.hosts.create(:host => @host,
|
19
|
+
:interfaces => [
|
20
|
+
{
|
21
|
+
:type => 1,
|
22
|
+
:main => 1,
|
23
|
+
:ip => "10.20.48.88",
|
24
|
+
:dns => "",
|
25
|
+
:port => 10050,
|
26
|
+
:useip => 1
|
27
|
+
}
|
28
|
+
],
|
29
|
+
:groups => [:groupid => @hostgroupid]
|
30
|
+
)
|
31
|
+
interfaceid = zbx.hostinterfaces.create(
|
32
|
+
:hostid => @hostid,
|
33
|
+
:dns => "",
|
34
|
+
:ip => "1.1.1.1",
|
35
|
+
:main => 0,
|
36
|
+
:port => '10050',
|
37
|
+
:type => 1,
|
38
|
+
:useip => 1
|
39
|
+
)
|
40
|
+
interfaceid.should be_kind_of(Integer)
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'get_id' do
|
44
|
+
it "should return nil" do
|
45
|
+
random_id = gen_name('')
|
46
|
+
expect(zbx.hosts.get_id(:hostids => [random_id])).to be_kind_of(NilClass)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when interface exists' do
|
53
|
+
before :all do
|
54
|
+
@host = gen_name 'host'
|
55
|
+
@hostid = zbx.hosts.create(
|
56
|
+
:host => @host,
|
57
|
+
:interfaces => [
|
58
|
+
{
|
59
|
+
:type => 1,
|
60
|
+
:main => 1,
|
61
|
+
:ip => "10.20.48.88",
|
62
|
+
:dns => "",
|
63
|
+
:port => 10050,
|
64
|
+
:useip => 1
|
65
|
+
}
|
66
|
+
],
|
67
|
+
:groups => [:groupid => @hostgroupid]
|
68
|
+
)
|
69
|
+
@interfaceid = zbx.hostinterfaces.create(:hostid => @hostid, :type => 1, :main => 0, :ip => "10.20.48.88", :dns => "", :port => 10050, :useip => 1)
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'get_full_data' do
|
73
|
+
it "should contains created host" do
|
74
|
+
expect(zbx.hostinterfaces.get_full_data(:hostid => "#{@hostid}")[0]).to include("hostid" => "#{@hostid}")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
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.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev D.V.
|
@@ -9,26 +9,26 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.6'
|
21
|
-
- -
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.6.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- - ~>
|
28
|
+
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '1.6'
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.6.0
|
34
34
|
description: Allows you to work with zabbix api from ruby.
|
@@ -39,9 +39,9 @@ executables: []
|
|
39
39
|
extensions: []
|
40
40
|
extra_rdoc_files: []
|
41
41
|
files:
|
42
|
-
- .gitignore
|
43
|
-
- .rspec
|
44
|
-
- .travis.yml
|
42
|
+
- ".gitignore"
|
43
|
+
- ".rspec"
|
44
|
+
- ".travis.yml"
|
45
45
|
- Gemfile
|
46
46
|
- Gemfile.lock
|
47
47
|
- README.md
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/zabbixapi/classes/errors.rb
|
57
57
|
- lib/zabbixapi/classes/graphs.rb
|
58
58
|
- lib/zabbixapi/classes/hostgroups.rb
|
59
|
+
- lib/zabbixapi/classes/hostinterfaces.rb
|
59
60
|
- lib/zabbixapi/classes/hosts.rb
|
60
61
|
- lib/zabbixapi/classes/items.rb
|
61
62
|
- lib/zabbixapi/classes/mediatypes.rb
|
@@ -76,6 +77,7 @@ files:
|
|
76
77
|
- spec/graph.rb
|
77
78
|
- spec/host.rb
|
78
79
|
- spec/hostgroup.rb
|
80
|
+
- spec/hostinterface.rb
|
79
81
|
- spec/item.rb
|
80
82
|
- spec/mediatype.rb
|
81
83
|
- spec/query.rb
|
@@ -97,17 +99,17 @@ require_paths:
|
|
97
99
|
- lib
|
98
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
101
|
requirements:
|
100
|
-
- -
|
102
|
+
- - ">="
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
version: '0'
|
103
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
106
|
requirements:
|
105
|
-
- -
|
107
|
+
- - ">="
|
106
108
|
- !ruby/object:Gem::Version
|
107
109
|
version: '0'
|
108
110
|
requirements: []
|
109
111
|
rubyforge_project: zabbixapi
|
110
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.3
|
111
113
|
signing_key:
|
112
114
|
specification_version: 4
|
113
115
|
summary: Realization for Zabbix API.
|
@@ -118,6 +120,7 @@ test_files:
|
|
118
120
|
- spec/graph.rb
|
119
121
|
- spec/host.rb
|
120
122
|
- spec/hostgroup.rb
|
123
|
+
- spec/hostinterface.rb
|
121
124
|
- spec/item.rb
|
122
125
|
- spec/mediatype.rb
|
123
126
|
- spec/query.rb
|