Sha256: 9e3ee7886ad0f207bb49adb6c6b73d2b36f87632e420deb066e61de72c94867a

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require "snmpjr/version"
require "snmpjr/getter"
require "snmpjr/target"

class Snmpjr

  def initialize options = {}
    @host = options.fetch(:host)
    @port = options.fetch(:port) { 161 }
    @community = options.fetch(:community)
    @timeout = options.fetch(:timeout) { 5000 }
    @max_oids_per_request = options.fetch(:max_oids_per_request) { 30 }
    @retries = options.fetch(:retries) { 0 }
  end

  def get oids
    target = Snmpjr::Target.new.create(host: @host,
                                       port: @port,
                                       community: @community,
                                       timeout: @timeout,
                                       retries: @retries
                                      )
    getter = Snmpjr::Getter.new(target: target, max_oids_per_request: @max_oids_per_request)

    case oids.class.to_s
    when 'String'
      getter.get oids
    when 'Array'
      getter.get_multiple oids
    else
      raise ArgumentError.new 'You can request a single Oid using a String, or multiple using an Array'
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snmpjr-0.1.7-java lib/snmpjr.rb