Class: ZabbixManager::Problems
- Defined in:
- lib/zabbix_manager/classes/problems.rb
Instance Method Summary collapse
-
#acknowledge_events(eventids, action: 2, message: nil) ⇒ Hash
(also: #ack_event)
批量确认事件,可指定确认动作和附加消息。.
-
#all ⇒ Array<Hash>
获取全部问题对象的完整数据。.
-
#dump_by_id(data) ⇒ Hash
按识别字段查询问题对象的完整数据。.
-
#get_full_data(data) ⇒ Hash
获取问题及其确认、标签和抑制信息,并支持附加查询参数。.
-
#identify ⇒ String
返回问题对象用于业务识别的字段名。.
-
#key ⇒ String
返回问题对象的兼容 ID 字段名;问题对象本身没有独立的唯一标识。.
-
#keys ⇒ String
返回问题对象的复数兼容 ID 字段名。.
-
#method_name ⇒ String
返回问题对象对应的 Zabbix API 方法前缀。.
Methods inherited from Basic
#add, #create, #create_or_update, #create_raw, #default_options, #delete, #delete_raw, #destroy, #get, #get_id, #get_or_create, #get_raw, #hash_equals?, #identity_filter, #initialize, #log, #normalize_hash, #parse_keys, #update, #update_raw
Constructor Details
This class inherits a constructor from ZabbixManager::Basic
Instance Method Details
#acknowledge_events(eventids, action: 2, message: nil) ⇒ Hash Also known as: ack_event
批量确认事件,可指定确认动作和附加消息。
94 95 96 97 98 99 100 101 102 |
# File 'lib/zabbix_manager/classes/problems.rb', line 94 def acknowledge_events(eventids, action: 2, message: nil) ids = Array(eventids).map(&:to_s).reject(&:blank?).uniq raise Invalid, "eventids are required" if ids.empty? @client.api_request( method: "event.acknowledge", params: { eventids: ids, action: action, message: }.compact ) end |
#all ⇒ Array<Hash>
获取全部问题对象的完整数据。
85 86 87 |
# File 'lib/zabbix_manager/classes/problems.rb', line 85 def all get_full_data({}) end |
#dump_by_id(data) ⇒ Hash
按识别字段查询问题对象的完整数据。
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/zabbix_manager/classes/problems.rb', line 39 def dump_by_id(data) log "[DEBUG] Call dump_by_id with parameters: #{data.inspect}" @client.api_request( method: "problem.get", params: { filter: { identify.to_sym => data[identify.to_sym] }, output: "extend" } ) end |
#get_full_data(data) ⇒ Hash
获取问题及其确认、标签和抑制信息,并支持附加查询参数。
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/zabbix_manager/classes/problems.rb', line 59 def get_full_data(data) log "[DEBUG] Call get_full_data with parameters: #{data.inspect}" data = data.deep_symbolize_keys params = { recent: false, sortfield: ["eventid"], sortorder: "DESC", output: "extend", selectAcknowledges: "extend", selectTags: "extend", selectSuppressionData: "extend" }.merge(data.except(:name).compact) params[:filter] = { identify.to_sym => data[identify.to_sym] } if data[identify.to_sym].present? @client.api_request( method: "#{method_name}.get", params: params ) end |
#identify ⇒ String
返回问题对象用于业务识别的字段名。
15 16 17 |
# File 'lib/zabbix_manager/classes/problems.rb', line 15 def identify "name" end |
#key ⇒ String
返回问题对象的兼容 ID 字段名;问题对象本身没有独立的唯一标识。
22 23 24 |
# File 'lib/zabbix_manager/classes/problems.rb', line 22 def key "problemid" end |
#keys ⇒ String
返回问题对象的复数兼容 ID 字段名。
29 30 31 |
# File 'lib/zabbix_manager/classes/problems.rb', line 29 def keys "problemids" end |
#method_name ⇒ String
返回问题对象对应的 Zabbix API 方法前缀。
8 9 10 |
# File 'lib/zabbix_manager/classes/problems.rb', line 8 def method_name "problem" end |