Sha256: 28f5f82e5d6a13dbc2cf3286204b4a14133d7b89249ccee3bedac5ebac1c7c06

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

require 'snmpjr/wrappers/transport'

class Snmpjr
  class Session

    def initialize
      @snmp = Snmpjr::Wrappers::Snmp.new(Snmpjr::Wrappers::Transport::DefaultUdpTransportMapping.new)
    end

    def start
      @snmp.listen
    end

    def send pdu, target
      begin
        result = @snmp.send(pdu, target)
        if result.response.nil?
          "Request timed out"
        else
          result.response.variable_bindings.first.variable.to_s
        end
      rescue Exception => e
        "Error: #{e.to_s}"
      end
    end

    def close
      @snmp.close
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snmpjr-0.1.2-java lib/snmpjr/session.rb