Class: ZabbixManager::HttpTests

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

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #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_keys, #get_raw, #hash_equals?, #initialize, #key, #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

#create_or_update(data) ⇒ Object

通过 Zabbix API 创建或更新 HttpTest 对象



35
36
37
38
# File 'lib/zabbix_manager/classes/httptests.rb', line 35

def create_or_update(data)
  httptestid = get_id(name: data[:name], hostid: data[:hostid])
  httptestid ? update(data.merge(httptestid: httptestid)) : create(data)
end

#default_optionsObject

通过 Zabbix API 创建 HttpTest 对象时使用的默认选项



16
17
18
19
20
21
22
# File 'lib/zabbix_manager/classes/httptests.rb', line 16

def default_options
  {
    hostid: nil,
    name:   nil,
    steps:  []
  }
end

#get_or_create(data) ⇒ Object

通过 Zabbix API 获取或创建 HttpTest 对象



25
26
27
28
29
30
31
32
# File 'lib/zabbix_manager/classes/httptests.rb', line 25

def get_or_create(data)
  log "[DEBUG] 使用参数调用 get_or_create: #{data.inspect}"

  unless (id = get_id(name: data[:name], hostid: data[:hostid]))
    id = create(data)
  end
  id
end

#identifyObject

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



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

def identify
  "name"
end

#method_nameObject

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



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

def method_name
  "httptest"
end