lib/snmp/manager.rb
##
# Walks a list of ObjectId or VarBind objects using get_next until
# the response to the first OID in the list reaches the end of its
# MIB subtree.
#
# The varbinds from each get_next are yielded to the given block as
# they are retrieved.  The result is yielded as a VarBind when walking
# a single object or as a VarBindList when walking a list of objects.
#
# Normally this method is used for walking tables by providing an
# ObjectId for each column of the table.
#
# For example:
#
#   SNMP::Manager.open(:host => "localhost") do |manager|
#     manager.walk("ifTable") { |vb| puts vb }
#   end
#
#   SNMP::Manager.open(:host => "localhost") do |manager|
#     manager.walk(["ifIndex", "ifDescr"]) do |index, descr|
#       puts "#{index.value} #{descr.value}"
#     end
#   end
#
# The index_column identifies the column that will provide the index
# for each row.  This information is used to deal with "holes" in a
# table (when a row is missing a varbind for one column).  A missing
# varbind is replaced with a varbind with the value NoSuchInstance.
#
# Note: If you are getting back rows where all columns have a value of
# NoSuchInstance then your index column is probably missing one of the
# rows.  Choose an index column that includes all indexes for the table.
#
Walks a list of ObjectId or VarBind objects using get_next until
the response to the first OID in the list reaches the end of its
MIB subtree.

The varbinds from each get_next are yielded to the given block as
they are retrieved.  The result is yielded as a VarBind when walking
a single object or as a VarBindList when walking a list of objects.

Normally this method is used for walking tables by providing an
ObjectId for each column of the table.

For example.

:Manager.open(:host => "localhost") do |manager|
manager.walk("ifTable") { |vb| puts vb }
end



The index_column identifies the column that will provide the index
for each row.  This information is used to deal with "holes" in a
table (when a row is missing a varbind for one column).  A missing
varbind is replaced with a varbind with the value NoSuchInstance.

If you are getting back rows where all columns have a value of
NoSuchInstance then your index column is probably missing one of the
rows.  Choose an index column that includes all indexes for the table.
Walks a list of ObjectId or VarBind objects using get_next until the response to the first OID in the list reaches the end of its MIB subtree . The varbinds from each get_next are yielded to the given block as they are retrieved . The result is yielded as a VarBind when walking a single object or as a VarBindList when walking a list of objects . Normally this method is used for walking tables by providing an ObjectId for each column of the table . For example . : Manager . open ( : host = > " localhost " ) do |manager| manager . walk ( " ifTable " ) { |vb| puts vb } end The index_column identifies the column that will provide the index for each row . This information is used to deal with " holes " in a table ( when a row is missing a varbind for one column ) . A missing varbind is replaced with a varbind with the value NoSuchInstance . If you are getting back rows where all columns have a value of NoSuchInstance then your index column is probably missing one of the rows . Choose an index column that includes all indexes for the table .
def walk(object_list, index_column=0)
      raise ArgumentError, "expected a block to be given" unless block_given?
      vb_list = @mib.varbind_list(object_list, :NullValue)
      raise ArgumentError, "index_column is past end of varbind list" if index_column >= vb_list.length
      is_single_vb = object_list.respond_to?(:to_str) ||
          object_list.respond_to?(:to_varbind)
      start_list = vb_list
      start_oid = vb_list[index_column].name
      last_oid = start_oid
      loop do
        vb_list = get_next(vb_list).vb_list
        index_vb = vb_list[index_column]
        break if EndOfMibView == index_vb.value
        stop_oid = index_vb.name
        if !@ignore_oid_order && stop_oid <= last_oid
          warn "OIDs are not increasing, #{last_oid} followed by #{stop_oid}"
          break
        end
        break unless stop_oid.subtree_of?(start_oid)
        last_oid = stop_oid
        if is_single_vb
          yield index_vb
        else
          vb_list = validate_row(vb_list, start_list, index_column)
          yield vb_list
        end
      end
    end
def walk ( object_list , index_column = 0 ) raise ArgumentError , "expected a block to be given" unless block_given? vb_list = @mib . varbind_list ( object_list , :NullValue ) raise ArgumentError , "index_column is past end of varbind list" if index_column >= vb_list . length is_single_vb = object_list . respond_to? ( :to_str ) || object_list . respond_to? ( :to_varbind ) start_list = vb_list start_oid = vb_list [ index_column ] . name last_oid = start_oid loop do vb_list = get_next ( vb_list ) . vb_list index_vb = vb_list [ index_column ] break if EndOfMibView == index_vb . value stop_oid = index_vb . name if ! @ignore_oid_order && stop_oid <= last_oid warn "OIDs are not increasing, #{last_oid} followed by #{stop_oid}" break end break unless stop_oid . subtree_of? ( start_oid ) last_oid = stop_oid if is_single_vb yield index_vb else vb_list = validate_row ( vb_list , start_list , index_column ) yield vb_list end end end
Walks a list of ObjectId or VarBind objects using get_next until
the response to the first OID in the list reaches the end of its
MIB subtree.
Walks a list of ObjectId or VarBind objects using get_next until the response to the first OID in the list reaches the end of its MIB subtree .
object_list
<not_specific>
index_column
<not_specific>