Sha256: 809c8e89670cbff2bb757ae64e0aea7b9dfcda014fd39701bb3c12419b3d9a77

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

class ZabbixApi
  class Applications

    def initialize(client)
      @client = client
    end

    def create(data)
      result = @client.api_request(:method => "application.create", :params => [data])
      result.empty? ? nil : result['applicationids'][0].to_i
    end

    def add(data)
      create(data)
    end

    def delete(data)
      result = @client.api_request(:method => "application.delete", :params => [data])
      result.empty? ? nil : result['applicationids'][0].to_i
    end

    def get_or_create(data)
      unless (appid = get_id(data))
        appid = create(data)
      end
      appid
    end

    def destroy(data)
      delete(data)
    end

    def get_full_data(data)
      @client.api_request(:method => "application.get", :params => {:filter => data, :output => "extend"})
    end

    def get_id(data)
      result = get_full_data(data)
      applicationid = nil
      result.each { |app| applicationid = app['applicationid'].to_i if app['name'] == data[:name] }
      applicationid
      if %w(127.0.0.1 localhost).include? host
        host_cmd = ""
      else
        host_cmd = "-h #{host}"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zabbixapi-0.5.2b3 lib/zabbixapi/classes/applications.rb