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_key_ids, #get_key_ids_by_identify, #get_or_create_keys, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update

Constructor Details

This class inherits a constructor from ZabbixManager::Basic

Instance Method Details

#create_or_update(data) ⇒ Integer, ...

Create or update HttpTest object using Zabbix API

Parameters:

  • data (Hash)

    Needs to include name and hostid to properly identify HttpTests via Zabbix API

Returns:

  • (Integer, TrueClass, FalseClass)

    Zabbix object id

Raises:

  • (ZbxError)

    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.



51
52
53
54
# File 'lib/zabbix_manager/classes/httptests.rb', line 51

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

#default_optionsHash

The default options used when creating HttpTest objects via Zabbix API

Returns:

  • (Hash)


22
23
24
25
26
27
28
# File 'lib/zabbix_manager/classes/httptests.rb', line 22

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

#get_or_create(data) ⇒ Integer

Get or Create HttpTest object using Zabbix API

Parameters:

  • data (Hash)

    Needs to include name and hostid to properly identify HttpTests via Zabbix API

Returns:

  • (Integer)

    Zabbix object id

Raises:

  • (ZbxError)

    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.



36
37
38
39
40
41
42
43
# File 'lib/zabbix_manager/classes/httptests.rb', line 36

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

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

#identifyString

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

Returns:

  • (String)


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

def identify
  "name"
end

#method_nameString

The method name used for interacting with HttpTests via Zabbix API

Returns:

  • (String)


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

def method_name
  "httptest"
end