Class: ZabbixApi::Hosts

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbixapi/1.8/classes/hosts.rb,
lib/zabbixapi/2.0/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

#array_flagObject



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

def array_flag
  true
end

#create_or_update(data) ⇒ Object



52
53
54
55
# File 'lib/zabbixapi/1.8/classes/hosts.rb', line 52

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

#default_optionsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/zabbixapi/1.8/classes/hosts.rb', line 16

def default_options
  {
    :host => nil,
    :port => 10050,
    :status => 1,
    :useip => 1,
    :dns => '',
    :ip => '0.0.0.0',
    :proxy_hostid => 0,
    :groups => [],
    :useipmi => 0,
    :ipmi_ip => '',
    :ipmi_port => 623,
    :ipmi_authtype => 0,
    :ipmi_privilege => 0,
    :ipmi_username => '',
    :ipmi_password => ''
  }
end

#indentifyObject



12
13
14
# File 'lib/zabbixapi/1.8/classes/hosts.rb', line 12

def indentify
  "host"
end

#method_nameObject



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

def method_name
  "host"
end


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/zabbixapi/1.8/classes/hosts.rb', line 36

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