Class: ZabbixApi::Problems

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbixapi/classes/problems.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #create, #create_or_update, #default_options, #delete, #destroy, #get, #get_id, #get_or_create, #get_raw, #hash_equals?, #initialize, #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

#allArray<Hash>

Get full/extended Zabbix data for Problem objects from API

Raises:

  • (ApiError)

    Error returned when there is a problem with the Zabbix API call.

  • (HttpError)

    Error raised when HTTP status from Zabbix Server response is not a 200 OK.



96
97
98
# File 'lib/zabbixapi/classes/problems.rb', line 96

def all
  get_full_data({})
end

#dump_by_id(data) ⇒ Hash

Dump Problem object data by key from Zabbix API

Raises:

  • (ApiError)

    Error returned when there is a problem with the Zabbix API call.

  • (HttpError)

    Error raised when HTTP status from Zabbix Server response is not a 200 OK.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/zabbixapi/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

Get full/extended Problem data from Zabbix API

Raises:

  • (ApiError)

    Error returned when there is a problem with the Zabbix API call.

  • (HttpError)

    Error raised when HTTP status from Zabbix Server response is not a 200 OK.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/zabbixapi/classes/problems.rb', line 59

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

  data = symbolize_keys(data)

  @client.api_request(
    method: "#{method_name}.get",
    params: {
      filter: {
        identify.to_sym => data[identify.to_sym]
      },
      eventids: data[:eventids] || nil,
      groupids: data[:groupids] || nil,
      hostids: data[:hostids] || nil,
      objectids: data[:objectids] || nil,
      tags: data[:tags] || nil,
      time_from: data[:time_from] || nil,
      time_till: data[:time_till] || nil,
      eventid_from: data[:eventid_from] || nil,
      eventid_till: data[:eventid_till] || nil,
      recent: data[:recent] || false,
      sortfield: data[:sortfield] || ['eventid'],
      sortorder: data[:sortorder] || 'DESC',
      countOutput: data[:countOutput] || nil,
      output: 'extend',
      selectAcknowledges: 'extend',
      selectTags: 'extend',
      selectSuppressionData: 'extend'
    }
  )
end

#identifyString

The id field name used for identifying specific Problem objects via Zabbix API



13
14
15
# File 'lib/zabbixapi/classes/problems.rb', line 13

def identify
  'name'
end

#keyString

The key field name used for Problem objects via Zabbix API However, Problem object does not have a unique identifier



21
22
23
# File 'lib/zabbixapi/classes/problems.rb', line 21

def key
  'problemid'
end

#keysString

Returns the object’s plural id field name (identify) based on key However, Problem object does not have a unique identifier



29
30
31
# File 'lib/zabbixapi/classes/problems.rb', line 29

def keys
  'problemids'
end

#method_nameString

The method name used for interacting with Hosts via Zabbix API



6
7
8
# File 'lib/zabbixapi/classes/problems.rb', line 6

def method_name
  'problem'
end