Class: ZabbixApi::Applications

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

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #default_options, #delete, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #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 ZabbixApi::Basic

Instance Method Details

#create_or_update(data) ⇒ Integer

Create or update Application object using Zabbix API

Parameters:

  • data (Hash)

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

Returns:

  • (Integer)

    Zabbix object id

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.


38
39
40
41
# File 'lib/zabbixapi/classes/applications.rb', line 38

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

#get_or_create(data) ⇒ Integer

Get or Create Application object using Zabbix API

Parameters:

  • data (Hash)

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

Returns:

  • (Integer)

    Zabbix object id

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.


23
24
25
26
27
28
29
30
# File 'lib/zabbixapi/classes/applications.rb', line 23

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

#indentifyString

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

Returns:

  • (String)

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

def indentify
  'name'
end

#method_nameString

The method name used for interacting with Applications via Zabbix API

Returns:

  • (String)

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

def method_name
  'application'
end