Module: SNMP4EM::SNMPv2cRequests

Defined in:
lib/snmp4em/snmp_v2c_requests.rb

Instance Method Summary collapse

Instance Method Details

#bulkwalk(oids, args = {}) ⇒ Object

Uses SNMPv2 GET-BULK operations to fetch all values of one or more OID prefixes. This produces the same result as SNMP4EM::SNMPCommonRequests#walk, but with much higher efficiency, as GET-BULK operations can fetch multiple OIDs at the same time. Multiple OID prefixes can be passed into the oids array, and will be fetched in parallel. The function returns a SNMP4EM::SnmpBulkWalkRequest object, which implements EM::Deferrable. From there, implement a callback/errback to fetch the result. On success, the result will be a hash, mapping requested OID prefixes to the returned value. Successful walks will be mapped to a hash, where each pair is represented as (oid => value). Unsuccessful walks will be mapped to an instance of SNMP::ResponseError.

Optional arguments can be passed into args, including:

  • return_raw - Return objects and errors as their raw SNMP types, such as SNMP::Integer instead of native Ruby integers, SNMP::OctetString instead of native Ruby strings, etc. (default: false)

  • max_results - Maximum number of results to be returned for any single OID prefix (default: nil = unlimited)

  • version - Override the version provided in the Manager constructor



37
38
39
40
# File 'lib/snmp4em/snmp_v2c_requests.rb', line 37

def bulkwalk(oids, args = {})
  request = SnmpBulkWalkRequest.new(self, oids, args)
  if (@fiber || args[:fiber]) then wrap_in_fiber(request) else request end
end

#getbulk(oids, args = {}) ⇒ Object

Sends an SNMPv2 GET-BULK request to fetch multiple OID-value pairings simultaneously. This produces similar results to an SNMP-WALK using a single request/response transaction (SNMP-WALK is actually an inefficient series of GET-NEXTs). Multiple OIDs can be passed into the oids array. Two additional parameters control how this list is processed. Setting the parameter nonrepeaters to value N indicates that the first N OIDs will fetch a single value. This is identical to running a single GET-NEXT for the OID. Any remaining OIDs will fetch multiple values. The number of values fetched is controlled by the parameter maxrepetitions. The function returns a SNMP4EM::SnmpGetBulkRequest object, which implements EM::Deferrable. From there, implement a callback/errback to fetch the result. On success, the result will be a hash, mapping requested OID prefixes to the returned value. Successful walks will be mapped to a hash, where each pair is represented as => value. Unsuccessful fetches will be mapped to an instance of SNMP::ResponseError

For more information, see tools.ietf.org/html/rfc1905#section-4.2.3

Optional arguments can be passed into args, including:

  • return_raw - Return objects and errors as their raw SNMP types, such as SNMP::Integer instead of native Ruby integers, SNMP::OctetString instead of native Ruby strings, etc. (default: false)

  • nonrepeaters - Number of OIDs passed to which exactly one result will be returned (default is 0)

  • maxrepetitions - Number of OID-value pairs to be returned for each OID (default is 10)



21
22
23
24
# File 'lib/snmp4em/snmp_v2c_requests.rb', line 21

def getbulk(oids, args = {})
  request = SnmpGetBulkRequest.new(self, oids, args)
  if (@fiber || args[:fiber]) then wrap_in_fiber(request) else request end
end