zabbixapi 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/zabbixapi.rb CHANGED
@@ -23,7 +23,7 @@ class ZabbixApi
23
23
  case @client.api_version
24
24
  when "1.3", "1.2"
25
25
  apidir = "1.8"
26
- when "1.4", "2.0.4"
26
+ when "1.4", "2.0.4", "2.0.5"
27
27
  apidir = "2.0"
28
28
  else
29
29
  raise "unknown Api version!"
@@ -35,7 +35,7 @@ class ZabbixApi
35
35
 
36
36
  def unlink_templates(data)
37
37
  result = @client.api_request(
38
- :method => "host.massRemove",
38
+ :method => "host.massRemove",
39
39
  :params => {
40
40
  :hostids => data[:hosts_id],
41
41
  :templates => data[:templates_id]
@@ -48,6 +48,9 @@ class ZabbixApi
48
48
  # https://www.zabbix.com/documentation/2.2/manual/api/reference/host/create
49
49
  # interfaces :(
50
50
  data_new = data.clone
51
+
52
+ data_new[:interfaces] = {}
53
+
51
54
  %w( type main useip ip dns port ).each do |key|
52
55
  data_new[:interfaces][key.to_sym] = data_new[key.to_sym]
53
56
  end
@@ -1,6 +1,6 @@
1
1
  class ZabbixApi
2
2
  class Triggers < Basic
3
-
3
+
4
4
  def array_flag
5
5
  true
6
6
  end
@@ -29,9 +29,9 @@ class ZabbixApi
29
29
  )
30
30
  end
31
31
 
32
- def safe_update(data)
32
+ def safe_update(data)
33
33
  log "[DEBUG] Call update with parametrs: #{data.inspect}"
34
-
34
+
35
35
  dump = {}
36
36
  item_id = data[key.to_sym].to_i
37
37
  dump_by_id(key.to_sym => data[key.to_sym]).each do |item|
@@ -39,17 +39,17 @@ class ZabbixApi
39
39
  end
40
40
 
41
41
  expression = dump[:items][0][:key_]+"."+dump[:functions][0][:function]+"("+dump[:functions][0][:parameter]+")"
42
- dump[:expression] = dump[:expression].gsub(/{(\d*)}/,"{#{expression}}") #TODO ugly regexp
42
+ dump[:expression] = dump[:expression].gsub(/\{(\d*)\}/,"{#{expression}}") #TODO ugly regexp
43
43
  dump.delete(:functions)
44
44
  dump.delete(:items)
45
45
 
46
46
  old_expression = data[:expression]
47
- data[:expression] = data[:expression].gsub(/{.*\:/,"{") #TODO ugly regexp
47
+ data[:expression] = data[:expression].gsub(/\{.*\:/,"{") #TODO ugly regexp
48
48
  data.delete(:templateid)
49
-
49
+
50
50
  log "[DEBUG] expression: #{dump[:expression]}\n data: #{data[:expression]}"
51
51
 
52
- if hash_equals?(dump, data)
52
+ if hash_equals?(dump, data)
53
53
  log "[DEBUG] Equal keys #{dump} and #{data}, skip update"
54
54
  item_id
55
55
  else
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  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: 0.5.7
4
+ version: 0.5.8
5
5
  prerelease:
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: 2013-03-15 00:00:00.000000000 Z
12
+ date: 2013-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json