Class: ZabbixApi::Hosts
Instance Method Summary collapse
-
#create_or_update(data) ⇒ Integer
Create or update Host object using Zabbix API.
-
#default_options ⇒ Hash
The default options used when creating Host objects via Zabbix API.
-
#dump_by_id(data) ⇒ Hash
Dump Host object data by key from Zabbix API.
-
#indentify ⇒ String
The id field name used for identifying specific Host objects via Zabbix API.
-
#method_name ⇒ String
The method name used for interacting with Hosts via Zabbix API.
-
#unlink_templates(data) ⇒ Boolean
Unlink/Remove Templates from Hosts using Zabbix API.
Methods inherited from Basic
#add, #all, #create, #delete, #destroy, #get, #get_full_data, #get_id, #get_or_create, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update
Constructor Details
This class inherits a constructor from ZabbixApi::Basic
Instance Method Details
#create_or_update(data) ⇒ Integer
Create or update Host object using Zabbix API
75 76 77 78 |
# File 'lib/zabbixapi/classes/hosts.rb', line 75 def create_or_update(data) hostid = get_id(host: data[:host]) hostid ? update(data.merge(hostid: hostid)) : create(data) end |
#default_options ⇒ Hash
The default options used when creating Host objects via Zabbix API
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/zabbixapi/classes/hosts.rb', line 41 def { host: nil, interfaces: [], status: 0, available: 1, groups: [], proxy_hostid: nil } end |
#dump_by_id(data) ⇒ Hash
Dump Host object data by key from Zabbix API
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/zabbixapi/classes/hosts.rb', line 23 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 ⇒ String
The id field name used for identifying specific Host objects via Zabbix API
13 14 15 |
# File 'lib/zabbixapi/classes/hosts.rb', line 13 def indentify 'host' end |
#method_name ⇒ String
The method name used for interacting with Hosts via Zabbix API
6 7 8 |
# File 'lib/zabbixapi/classes/hosts.rb', line 6 def method_name 'host' end |
#unlink_templates(data) ⇒ Boolean
Unlink/Remove Templates from Hosts using Zabbix API
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/zabbixapi/classes/hosts.rb', line 58 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 |