Class: ZabbixManager::HostInterfaces

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbix_manager/classes/hostinterfaces.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #create_or_update, #default_options, #delete, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_ids, #get_ids_by_identify, #get_key_ids, #get_key_ids_by_identify, #get_or_create, #get_or_create_keys, #get_raw, #hash_equals?, #initialize, #keys, #log, #merge_hashes, #normalize_array, #normalize_hash, #parse_keys, #request_raw, #symbolize_keys, #update

Constructor Details

This class inherits a constructor from ZabbixManager::Basic

Instance Method Details

#get_interfaceid(hostid) ⇒ Object

Note:

基于 hostid 查询关联的 Interfaceid

通过 Zabbix API 基于提供的 hostid 获取 Zabbix interface 的 id



22
23
24
25
26
27
# File 'lib/zabbix_manager/classes/hostinterfaces.rb', line 22

def get_interfaceid(hostid)
  result = get_raw({ output: key, identify.to_sym => hostid })

  # 如果查询结果不为空,且第一个元素不为空,则继续获取 {interfaceid} 并转换为整数
  result&.[](0)&.[](key)&.to_i
end

#identifyObject

用于通过 Zabbix API 标识特定 HostInterface 对象的 id 字段名称



11
12
13
# File 'lib/zabbix_manager/classes/hostinterfaces.rb', line 11

def identify
  "hostids"
end

#keyObject

HostInterface 对象通过 Zabbix API 使用的 key 字段名称



16
17
18
# File 'lib/zabbix_manager/classes/hostinterfaces.rb', line 16

def key
  "interfaceid"
end

#method_nameObject

用于通过 Zabbix API 与 HostInterfaces 交互的方法名称



6
7
8
# File 'lib/zabbix_manager/classes/hostinterfaces.rb', line 6

def method_name
  "hostinterface"
end