zabbixapi 0.5.3b7u → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,5 +2,6 @@
2
2
  *.gem
3
3
  *.swp
4
4
  .idea
5
+ .gemtags
5
6
  pkg
6
7
  test
data/README.md CHANGED
@@ -156,6 +156,8 @@ zbx.graphs.create_or_update(
156
156
  ### Get ids by host ###
157
157
  ```ruby
158
158
  zbx.graphs.get_ids_by_host(:host => "hostname")
159
+ #You can filter graph name:
160
+ zbx.graphs.get_ids_by_host(:host => "hostname", filter => "CPU")
159
161
  ```
160
162
 
161
163
  ### Delete graph
@@ -221,7 +223,7 @@ zbx.graphs.delete(zbx.graphs.get_id(:name => "graph"))
221
223
  ### Create screen for host ###
222
224
  ```ruby
223
225
  zbx.screens.get_or_create_for_host(
224
- :host => "hostname",
226
+ :screen_name => "screen_name",
225
227
  :graphids => zbx.graphs.get_ids_by_host(:host => "hostname")
226
228
  )
227
229
  ```
@@ -29,9 +29,19 @@ class ZabbixApi
29
29
 
30
30
  def get_ids_by_host(data)
31
31
  ids = []
32
+ graphs = Hash.new
32
33
  result = @client.api_request(:method => "graph.get", :params => {:filter => {:host => data[:host]}, :output => "extend"})
33
34
  result.each do |graph|
34
- ids << graph['graphid']
35
+ num = graph['graphid']
36
+ name = graph['name']
37
+ graphs[name] = num
38
+ filter = data[:filter]
39
+
40
+ unless #{filter}
41
+ if /#{filter}/ =~ name
42
+ ids.push(graphs[name])
43
+ end
44
+ end
35
45
  end
36
46
  ids
37
47
  end
@@ -34,13 +34,17 @@ class ZabbixApi
34
34
  end
35
35
 
36
36
  def get_or_create_for_host(data)
37
- screen_name = data[:host].to_s + "_graphs"
37
+ screen_name = data[:screen_name]
38
38
  graphids = data[:graphids]
39
39
  screenitems = []
40
40
  hsize = data[:hsize] || 3
41
41
  valign = data[:valign] || 2
42
42
  halign = data[:halign] || 2
43
- vsize = data[:vsize] || ((graphids.size/hsize) + 1).to_i
43
+ rowspan = data[:rowspan] || 0
44
+ colspan = data[:colspan] || 0
45
+ height = data[:height] || 320 # default 320
46
+ width = data[:width] || 200 # default 200
47
+ vsize = data[:vsize] || (graphids.size/hsize).to_i
44
48
  screenid = get_id(:name => screen_name)
45
49
  unless screenid
46
50
  # Create screen
@@ -50,8 +54,12 @@ class ZabbixApi
50
54
  :resourceid => graphid,
51
55
  :x => (index % hsize).to_i,
52
56
  :y => (index % graphids.size/hsize).to_i,
53
- :valign =>valign,
54
- :halign =>halign
57
+ :valign => valign,
58
+ :halign => halign,
59
+ :rowspan => rowspan,
60
+ :colspan => colspan,
61
+ :height => height,
62
+ :width => width
55
63
  }
56
64
  end
57
65
  screenid = create(
@@ -48,7 +48,7 @@ class ZabbixApi
48
48
 
49
49
  def http_request(body)
50
50
  uri = URI.parse(@options[:url])
51
- unless @proxy_uri.nil?
51
+ if @proxy_uri.nil?
52
52
  http = Net::HTTP.Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_pass).new(uri.host, uri.port)
53
53
  else
54
54
  http = Net::HTTP.new(uri.host, uri.port)
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = "0.5.3b7u"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbixapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3b7u
5
- prerelease: 5
4
+ version: 0.5.4
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vasiliev D.V.
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-14 00:00:00.000000000 Z
12
+ date: 2013-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -96,15 +96,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
96
  - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
+ segments:
100
+ - 0
101
+ hash: -402697987343714468
99
102
  required_rubygems_version: !ruby/object:Gem::Requirement
100
103
  none: false
101
104
  requirements:
102
- - - ! '>'
105
+ - - ! '>='
103
106
  - !ruby/object:Gem::Version
104
- version: 1.3.1
107
+ version: '0'
105
108
  requirements: []
106
109
  rubyforge_project: zabbixapi
107
- rubygems_version: 1.8.25
110
+ rubygems_version: 1.8.24
108
111
  signing_key:
109
112
  specification_version: 3
110
113
  summary: Realization for Zabbix API.