Sha256: a9cae62b8cb023b625995f22ff317a33bd9d2bfe76538f9c696cc38e231c5c0f

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 KB

Contents

module Zabbix

  class ZabbixApi
    def add_macro(host_id, macro_name, macro_value)

      message = {
        'method' => 'Usermacro.create',
        'params' => {
          'hostid' => host_id,
          'macro' => macro_name,
          'value'=> macro_value
        }
      }

      response = send_request(message)

      if hostmacroids = response['hostmacroids'] then
        result = hostmacroids
      else
        result = nil
      end

      return result
    end

    def get_macro(host_id, macro_name)
    
      message = {
        'method' => 'Usermacro.get',
        'params' => {
          'hostids' => host_id,
          'macros' => macro_name,
          'extendoutput' => '1'
        }
      }

      response = send_request(message)

      unless response.empty? then
        if hostmacroid =  response[0]['hostmacroid'] then
          macro_id = hostmacroid
          macro_value = response[0]['value']

          result = {
            'id' => macro_id,
            'value'=> macro_value
          }
        else
          result = nil
        end
      else
        result = nil
      end

      return result
    end

    def set_macro_value(host_id, macro_name, macro_value)
      
      message = {
        'method' => 'usermacro.updateValue',
        'params' => {
          'hostid' => host_id,
          'macro' => macro_name,
          'value' => macro_value
        }
      }

      response = send_request(message)

      return true
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
zabbixapi-0.1.6 lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5b lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5a6 lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5a5 lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5a4 lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5a3 lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5a2 lib/zabbixapi/usermacro.rb
zabbixapi-0.1.5a1 lib/zabbixapi/usermacro.rb
iteh-zabbixapi-0.2.4 lib/zabbixapi/usermacro.rb
iteh-zabbixapi-0.2.3 lib/zabbixapi/usermacro.rb
iteh-zabbixapi-0.2.2 lib/zabbixapi/usermacro.rb