Class: ZabbixApi::Graphs

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbixapi/classes/graphs.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #default_options, #delete, #destroy, #dump_by_id, #get, #get_id, #get_or_create, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_hash, #parse_keys, #symbolize_keys, #update

Constructor Details

This class inherits a constructor from ZabbixApi::Basic

Instance Method Details

#_update(data) ⇒ Object



56
57
58
59
# File 'lib/zabbixapi/classes/graphs.rb', line 56

def _update(data)
  data.delete(:name)
  update(data)
end

#create_or_update(data) ⇒ Object



51
52
53
54
# File 'lib/zabbixapi/classes/graphs.rb', line 51

def create_or_update(data)
  graphid = get_id(:name => data[:name], :templateid => data[:templateid])
  graphid ? _update(data.merge(:graphid => graphid)) : create(data)
end

#get_full_data(data) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/zabbixapi/classes/graphs.rb', line 12

def get_full_data(data)
  log "[DEBUG] Call get_full_data with parametrs: #{data.inspect}"

  @client.api_request(
    :method => "#{method_name}.get",
    :params => {
      :search => {
        indentify.to_sym => data[indentify.to_sym]
      },
      :output => "extend"
    }
  )
end

#get_ids_by_host(data) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/zabbixapi/classes/graphs.rb', line 26

def get_ids_by_host(data)
  ids = []
  graphs = Hash.new
  result = @client.api_request(:method => "graph.get", :params => {:filter => {:host => data[:host]}, :output => "extend"})
  result.each do |graph|
    num  = graph['graphid']
    name = graph['name']
    graphs[name] = num
    filter = data[:filter]

    unless filter.nil?
      if /#{filter}/ =~ name
        ids.push(graphs[name])
      end
    else
        ids.push(graphs[name])
    end
  end
  ids
end

#get_items(data) ⇒ Object



47
48
49
# File 'lib/zabbixapi/classes/graphs.rb', line 47

def get_items(data)
  @client.api_request(:method => "graphitem.get", :params => { :graphids => [data], :output => "extend" } )
end

#indentifyObject



8
9
10
# File 'lib/zabbixapi/classes/graphs.rb', line 8

def indentify
  "name"
end

#method_nameObject



4
5
6
# File 'lib/zabbixapi/classes/graphs.rb', line 4

def method_name
  "graph"
end