Class: Snmpjr::Getter

Inherits:
Object
  • Object
show all
Defined in:
lib/snmpjr/getter.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Getter

Returns a new instance of Getter.



4
5
6
7
8
9
# File 'lib/snmpjr/getter.rb', line 4

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

Instance Method Details

#get(oids) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/snmpjr/getter.rb', line 11

def get oids
  #TODO: Change it to be a session do end block
  @session.start
  begin
    results = oids.each_slice(@max_oids_per_request).flat_map{|partial_oids|
      get_request partial_oids
    }
  ensure
    @session.close
  end
  extract_possible_single_result_from results
end