Sha256: f9527135f4f0c6138b6489ee780b2830193637a6ca90bd27d8ba48cea9102e4a

Contents?: true

Size: 991 Bytes

Versions: 4

Compression:

Stored size: 991 Bytes

Contents

require 'snmpjr/configuration_v2c'
require 'snmpjr/configuration_v3'
require 'snmpjr/wrappers/smi'
require "snmpjr/getter"
require 'snmpjr/walker'
require 'snmpjr/version'

class Snmpjr

  CONFIGURATION_VERSION = {
    Snmpjr::Version::V2C => Snmpjr::ConfigurationV2C,
    Snmpjr::Version::V3 => Snmpjr::ConfigurationV3
  }

  def initialize version
    @version = version
  end

  def configuration
    @configuration ||= CONFIGURATION_VERSION.fetch(@version).new
  end

  def configure
    yield(configuration) if block_given?
    self
  end

  def get oids
    Snmpjr::Getter.new(
      session: configuration.create_session,
      target: configuration.create_target,
      pdu: configuration.create_pdu,
      config: configuration
    ).get Array(oids)
  end

  def walk oid
    Snmpjr::Walker.new(
      session: configuration.create_session,
      target: configuration.create_target,
      pdu: configuration.create_pdu
    ).walk Snmpjr::Wrappers::SMI::OID.new(oid.to_s)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
snmpjr-0.3.3-java lib/snmpjr.rb
snmpjr-0.3.2-java lib/snmpjr.rb
snmpjr-0.3.1-java lib/snmpjr.rb
snmpjr-0.3.0-java lib/snmpjr.rb