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

Returns:

  • (Array<Hash>)

    Array of matching objects

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

Parameters:

  • data (Hash)

    Should include desired object’s key and value

Returns:

  • (Hash)

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

Parameters:

  • data (Hash)

    Should include object’s id field name (identify) and id value

Returns:

  • (Hash)

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

Returns:

  • (String)


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

Returns:

  • (String)


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

Returns:

  • (String)


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

Returns:

  • (String)


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

def method_name
  'problem'
end