Class: ZabbixManager::Actions

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

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #create_or_update, #create_raw, #default_options, #delete, #delete_raw, #destroy, #dump_by_id, #get, #get_id, #get_or_create, #get_raw, #hash_equals?, #identity_filter, #initialize, #key, #keys, #log, #normalize_hash, #parse_keys, #update, #update_raw

Constructor Details

This class inherits a constructor from ZabbixManager::Basic

Instance Method Details

#get_full_data(data) ⇒ Hash

获取操作及其执行、恢复、确认操作和过滤条件的完整数据。

Parameters:

  • data (Hash)

    包含识别字段及其值的查询条件

Returns:

  • (Hash)

    匹配的操作完整数据

Raises:

  • (ApiError)

    Zabbix API 返回业务错误时抛出

  • (TransportError)

    Zabbix 服务端返回非成功 HTTP 状态时抛出



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/zabbix_manager/classes/actions.rb', line 25

def get_full_data(data)
  log "[DEBUG] Call get_full_data with parameters: #{data.inspect}"

  @client.api_request(
    method: "#{method_name}.get",
    params: {
      filter: {
        identify.to_sym => data[identify.to_sym]
      },
      output: "extend",
      selectOperations: "extend",
      selectRecoveryOperations: "extend",
      selectAcknowledgeOperations: "extend",
      selectFilter: "extend"
    }
  )
end

#identifyString

返回操作对象用于业务识别的字段名。

Returns:

  • (String)


15
16
17
# File 'lib/zabbix_manager/classes/actions.rb', line 15

def identify
  "name"
end

#method_nameString

返回操作对象对应的 Zabbix API 方法前缀。

Returns:

  • (String)


8
9
10
# File 'lib/zabbix_manager/classes/actions.rb', line 8

def method_name
  "action"
end