Class: ZabbixApi::Hosts
- Inherits:
-
Basic
- Object
- Basic
- ZabbixApi::Hosts
show all
- Defined in:
- lib/zabbixapi/classes/hosts.rb
Instance Method Summary
collapse
Methods inherited from Basic
#add, #all, #create, #delete, #destroy, #get, #get_full_data, #get_id, #get_or_create, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update
Instance Method Details
#create_or_update(data) ⇒ Object
49
50
51
52
|
# File 'lib/zabbixapi/classes/hosts.rb', line 49
def create_or_update(data)
hostid = get_id(:host => data[:host])
hostid ? update(data.merge(:hostid => hostid)) : create(data)
end
|
#default_options ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/zabbixapi/classes/hosts.rb', line 27
def default_options
{
:host => nil,
:interfaces => [],
:status => 0,
:available => 1,
:groups => [],
:proxy_hostid => nil
}
end
|
#dump_by_id(data) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/zabbixapi/classes/hosts.rb', line 12
def dump_by_id(data)
log "[DEBUG] Call dump_by_id with parametrs: #{data.inspect}"
@client.api_request(
:method => "host.get",
:params => {
:filter => {
key.to_sym => data[key.to_sym]
},
:output => "extend",
:selectGroups => "shorten"
}
)
end
|
#indentify ⇒ Object
8
9
10
|
# File 'lib/zabbixapi/classes/hosts.rb', line 8
def indentify
"host"
end
|
#method_name ⇒ Object
4
5
6
|
# File 'lib/zabbixapi/classes/hosts.rb', line 4
def method_name
"host"
end
|
#unlink_templates(data) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/zabbixapi/classes/hosts.rb', line 38
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
|