Example for SNMP-WALK-ifTable

[Back to main]
# SNMP walk example
# Usage: ruby iftable.rb 
#
# 
require 'socket'
require 's2nmp'

host=ARGV.shift
vars= ["1.3.6.1.2.1.2.2.1.1", #inIndex
       "1.3.6.1.2.1.2.2.1.2", #inDescr
       "1.3.6.1.2.1.2.2.1.5", #ifSpeed
       "1.3.6.1.2.1.2.2.1.10", #ifInOctets
       "1.3.6.1.2.1.2.2.1.16", #ifOutOctets
       ]

s=SNMP.new(host)
s.walk("public",vars){ |idx,dsc,speed,inocts,outocts|
  p [ idx[2],dsc[2],speed[2],inocts[2],outocts[2]]
}
C:\My Documents\examples>ruby iftable.rb 192.168.1.254
[1, "Ethernet0", 10000000, 2366665238, 3148211935]
[2, "Ethernet1", 10000000, 3122078818, 2548047762]
[3, "Serial0", 1544000, 908343279, 621731704]
[5, "Serial0.1", 128000, 891604887, 607308539]

C:\My Documents\examples>

[PR]看護師の好条件求人なら:転職活動不安ですか?なんでも相談OK!