Class: ZabbixApi::Hosts

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

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #delete, #destroy, #dump_by_id, #get, #get_full_data, #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

#create_or_update(data) ⇒ Object



34
35
36
37
# File 'lib/zabbixapi/classes/hosts.rb', line 34

def create_or_update(data)
  hostid = get_id(:host => data[:host])
  hostid ? update(data.merge(:hostid => hostid)) : create(data)
end

#default_optionsObject



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

def default_options
  {
    :host => nil,
    :interfaces => [],
    :status => 0,
    :available => 1,
    :groups => [],
    :proxy_hostid => nil
  }
end

#indentifyObject



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

def indentify
  "host"
end

#method_nameObject



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

def method_name
  "host"
end


23
24
25
26
27
28
29
30
31
32
# File 'lib/zabbixapi/classes/hosts.rb', line 23

def unlink_templates(data)
  result = @client.api_request(
    :method => "host.massRemove",
    :params => {
      :hostids => data[:hosts_id],
      :templates => data[:templates_id]
    }
  )
  result.empty? ? false : true
end