Sha256: 08ac8e66248f163664d3d1c923e487505b8ecc3f597db68bd8cfed0d72e0faa6
Contents?: true
Size: 713 Bytes
Versions: 5
Compression:
Stored size: 713 Bytes
Contents
require "snmpjr/pdu" require "snmpjr/session" class Snmpjr class Getter def initialize args = {} @target = args.fetch(:target) @max_oids_per_request = args[:max_oids_per_request] || 30 @session = Snmpjr::Session.new end def get_multiple oids @session.start result = oids.each_slice(@max_oids_per_request).map{|partial_oids| get_request partial_oids }.flatten @session.close result end def get oid @session.start result = get_request [oid] @session.close result.first end private def get_request oids pdu = Snmpjr::Pdu.new.create oids @session.send(pdu, @target) end end end
Version data entries
5 entries across 5 versions & 1 rubygems