zabbixapi 0.5.1b8 → 0.5.1b9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zabbixapi/basic/basic_logic.rb +17 -3
- data/lib/zabbixapi/client.rb +2 -0
- data/lib/zabbixapi/version.rb +1 -1
- metadata +3 -3
@@ -2,6 +2,8 @@ class ZabbixApi
|
|
2
2
|
class Basic
|
3
3
|
|
4
4
|
def create(data)
|
5
|
+
puts "[DEBUG] Call create with parametrs: #{data.inspect}" if @client.options[:debug]
|
6
|
+
|
5
7
|
data_with_default = default_options.empty? ? data : merge_params(data)
|
6
8
|
data_create = array_flag ? [data_with_default] : data_with_default
|
7
9
|
result = @client.api_request(:method => "#{method_name}.create", :params => data_create)
|
@@ -9,17 +11,21 @@ class ZabbixApi
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def delete(data)
|
14
|
+
puts "[DEBUG] Call delete with parametrs: #{data.inspect}" if @client.options[:debug]
|
15
|
+
|
12
16
|
data_delete = array_flag ? [data] : [key.to_sym => data]
|
13
17
|
result = @client.api_request(:method => "#{method_name}.delete", :params => data_delete)
|
14
18
|
parse_keys result
|
15
19
|
end
|
16
20
|
|
17
21
|
def create_or_update(data)
|
22
|
+
puts "[DEBUG] Call create_or_update with parametrs: #{data.inspect}" if @client.options[:debug]
|
18
23
|
id = get_id(indentify.to_sym => data[indentify.to_sym])
|
19
24
|
id ? update(data.merge(key.to_sym => id.to_s)) : create(data)
|
20
25
|
end
|
21
26
|
|
22
27
|
def update(data)
|
28
|
+
puts "[DEBUG] Call update with parametrs: #{data.inspect}" if @client.options[:debug]
|
23
29
|
|
24
30
|
dump = {}
|
25
31
|
item_id = data[key.to_sym].to_i
|
@@ -37,11 +43,13 @@ class ZabbixApi
|
|
37
43
|
end
|
38
44
|
|
39
45
|
def get_full_data(data)
|
46
|
+
puts "[DEBUG] Call get_full_data with parametrs: #{data.inspect}" if @client.options[:debug]
|
47
|
+
|
40
48
|
@client.api_request(
|
41
49
|
:method => "#{method_name}.get",
|
42
50
|
:params => {
|
43
51
|
:filter => {
|
44
|
-
indentify.to_sym =>
|
52
|
+
indentify.to_sym => data[indentify.to_sym]
|
45
53
|
},
|
46
54
|
:output => "extend"
|
47
55
|
}
|
@@ -49,11 +57,13 @@ class ZabbixApi
|
|
49
57
|
end
|
50
58
|
|
51
59
|
def dump_by_id(data)
|
60
|
+
puts "[DEBUG] Call dump_by_id with parametrs: #{data.inspect}" if @client.options[:debug]
|
61
|
+
|
52
62
|
@client.api_request(
|
53
63
|
:method => "#{method_name}.get",
|
54
64
|
:params => {
|
55
65
|
:filter => {
|
56
|
-
key.to_sym =>
|
66
|
+
key.to_sym => data[key.to_sym]
|
57
67
|
},
|
58
68
|
:output => "extend"
|
59
69
|
}
|
@@ -69,13 +79,17 @@ class ZabbixApi
|
|
69
79
|
end
|
70
80
|
|
71
81
|
def get_id(data)
|
82
|
+
puts "[DEBUG] Call get_id with parametrs: #{data.inspect}" if @client.options[:debug]
|
83
|
+
|
72
84
|
result = symbolize_keys( get_full_data(data) )
|
73
85
|
id = nil
|
74
|
-
result.each { |item| id =
|
86
|
+
result.each { |item| id = item[key.to_sym].to_i if item[indentify.to_sym] == data[indentify.to_sym] }
|
75
87
|
id
|
76
88
|
end
|
77
89
|
|
78
90
|
def get_or_create(data)
|
91
|
+
puts "[DEBUG] Call get_or_create with parametrs: #{data.inspect}" if @client.options[:debug]
|
92
|
+
|
79
93
|
unless id = get_id(data)
|
80
94
|
id = create(data)
|
81
95
|
end
|
data/lib/zabbixapi/client.rb
CHANGED
data/lib/zabbixapi/version.rb
CHANGED
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: 0.5.
|
4
|
+
version: 0.5.1b9
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allows you to work with zabbix api from ruby.
|
15
15
|
email:
|
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
segments:
|
65
65
|
- 0
|
66
|
-
hash:
|
66
|
+
hash: 2937401785949579712
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
69
69
|
requirements:
|