Sha256: f9d642d0de0b9813118c63a4446ffe1152316f1069f4526045732da9f5be0c3a

Contents?: true

Size: 772 Bytes

Versions: 1

Compression:

Stored size: 772 Bytes

Contents

class Snmpjr
  class Getter

    def initialize args = {}
      @target = args.fetch(:target)
      @max_oids_per_request = args.fetch(:config).max_oids_per_request
      @session = args.fetch(:session)
      @pdu = args.fetch(:pdu)
    end

    def get oids
      @session.start
      begin
        results = oids.each_slice(@max_oids_per_request).map{|partial_oids|
          get_request partial_oids
        }.flatten
      ensure
        @session.close
      end
      extract_possible_single_result_from results
    end

    private

    def get_request oids
      pdu = @pdu.create oids
      @session.send(pdu, @target)
    end

    def extract_possible_single_result_from results
      return results.first if results.size.eql?(1)
      results
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snmpjr-0.3.0-java lib/snmpjr/getter.rb