-
-
Save newacct/809146 to your computer and use it in GitHub Desktop.
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 characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment