Created
June 30, 2011 16:59
-
-
Save gnarl/1056667 to your computer and use it in GitHub Desktop.
When Integer is not a Duck
This file contains 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' | |
include SNMP | |
def snmp_get( oid ) | |
varbind = VarBind.new(oid) | |
response = @manager.get([varbind]) | |
response.each_varbind do |vb| | |
puts "#{vb.name.to_s} #{vb.value.to_s} #{vb.value.asn1_type}" | |
end | |
end | |
def snmp_set( oid, val ) | |
varbind = VarBind.new(oid, val) | |
puts "Setting #{varbind.name.to_s} #{varbind.value.to_s}" #{varbind.value.asn1_type}" | |
response = @manager.set(varbind) | |
# varbind.value.methods.each {|x| puts x} | |
end | |
@manager = Manager.new(:Host => 'x.x.x.x', :Community => "public") | |
snmp_set("1.3.6.1.4.1.641.1.5.6.1.0", SNMP::Integer.new(2)) #http enable | |
snmp_get("1.3.6.1.4.1.641.1.5.6.1.0") #http enable | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment