Revisions
-
newacct revised this gist
Feb 3, 2011 . 1 changed file with 17 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,18 @@ require "rubygems" require "snmp" mac = ARGV.shift.dup unless mac.gsub! /^(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?$/, '\1 \2 \3 \4 \5 \6' puts "illegal mac" exit end mac = mac.split(" ").collect { |x| x.hex }.join "." %w[240 113 175 184 185 179 241 193 194 176 177 178 202].each do |ip| SNMP::Manager.open(:Host => "192.168.1.#{ip}") do |snmp| value = snmp.get_value("SNMPv2-SMI::mib-2.17.4.3.1.2.#{mac}") puts "192.168.1.#{ip}, port #{value}" unless value.to_s =~ /noSuchInstance/ end end -
rkh created this gist
Mar 5, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ require "rubygems" require "snmp" mac = ARGV.shift.dup unless mac.gsub! /^(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?$/, '\1 \2 \3 \4 \5 \6' puts "illegal mac" exit end mac = mac.split(" ").collect { |hex| eval("0x#{hex}").to_s }.join "." %w[240 113 175 184 185 179 241 193 194 176 177 178 202].each do |ip| SNMP::Manager.open(:Host => "192.168.1.#{ip}") do |snmp| value = snmp.get_value("SNMPv2-SMI::mib-2.17.4.3.1.2.#{mac}") puts "192.168.1.#{ip}, port #{value}" unless value.to_s =~ /noSuchInstance/ end end