I need to send a SNMPv2c trap to a port other than the default 162 however this fails with a trap (see below). From the code it looks like the port is hardcoded (in TrapSession)
def initialize(options = {})
options[:peername] = "#{options[:peername]}:162"
super(options)
end
when passing the port the peername becomes localhost:162:2006. If I remove the 162 everything works fine.
a = Net::SNMP::TrapSession.new(:peername => "localhost", :port => 2006, :community => "whatever", :version => "2c")
a.trap_v2(:oid => "1.3.6.1.6.3.1.1.4.1.0")
FFI::NullPointerError: invalid memory read at address=0x00000000000000
from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/ffi-1.4.0/lib/ffi/pointer.rb:42:in get_string' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/ffi-1.4.0/lib/ffi/pointer.rb:42:inread_string'
from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:515:in get_error' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:460:inerrno'
from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/error.rb:9:in initialize' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:245:innew'
from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:245:in error' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:442:insend_pdu'
from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/trap_session.rb:36:in trap_v2' from (irb):3 from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:instart'
from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in start' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in'
I need to send a SNMPv2c trap to a port other than the default 162 however this fails with a trap (see below). From the code it looks like the port is hardcoded (in TrapSession) def initialize(options = {}) options[:peername] = "#{options[:peername]}:162" super(options) end when passing the port the peername becomes localhost:162:2006. If I remove the 162 everything works fine.
a = Net::SNMP::TrapSession.new(:peername => "localhost", :port => 2006, :community => "whatever", :version => "2c") a.trap_v2(:oid => "1.3.6.1.6.3.1.1.4.1.0") FFI::NullPointerError: invalid memory read at address=0x00000000000000 from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/ffi-1.4.0/lib/ffi/pointer.rb:42:in'
get_string' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/ffi-1.4.0/lib/ffi/pointer.rb:42:in
read_string' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:515:inget_error' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:460:in
errno' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/error.rb:9:ininitialize' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:245:in
new' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:245:inerror' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/session.rb:442:in
send_pdu' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.5/lib/net/snmp/trap_session.rb:36:intrap_v2' from (irb):3 from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in
start' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:instart' from /Users/bwessels/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in
<top (required)>' from script/rails:6:inrequire' from script/rails:6:in