net-snmp 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/sync_spec.rb CHANGED
@@ -74,12 +74,20 @@ describe "synchronous calls" do
74
74
  end
75
75
 
76
76
  it "get_table should work" do
77
+ pending "not yet implemented"
77
78
  session = Net::SNMP::Session.open(:peername => "localhost", :version => '1')
78
- table = session.get_table("ifEntry")
79
+ table = session.get_table("ifTable", :columns => ['ifIndex', 'ifDescr'])
79
80
  table[0]['ifIndex'].should eql(1)
80
81
  table[1]['ifIndex'].should eql(2)
81
82
  end
82
83
 
84
+ it "walk should work" do
85
+ pending "not yet implemented"
86
+ session = Net::SNMP::Session.open(:peername => 'test.net-snmp.org', :version => 1)
87
+ results = session.walk("system")
88
+ results['1.3.6.1.2.1.1.1.0'].should match(/test.net-snmp.org/)
89
+ end
90
+
83
91
  end
84
92
 
85
93
  context "version 2" do
data/spec/thread_spec.rb CHANGED
@@ -2,13 +2,14 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "in a thread" do
4
4
  it "should get an oid asynchronously in a thread" do
5
+ Net::SNMP.thread_safe = true
5
6
  did_callback = false
6
7
  puts "calling thread"
7
8
  dispatch_thread = Net::SNMP::Dispatcher.thread_loop
8
9
  puts "still here"
9
10
  Net::SNMP::Session.open(:peername => 'test.net-snmp.org', :community => 'demopublic') do |s|
10
11
  puts "sending get"
11
- s.get(["sysDescr.0", "sysContact.0"]) do |result|
12
+ s.get(["sysDescr.0", "sysContact.0"]) do |op, result|
12
13
  puts "got callback"
13
14
  did_callback = true
14
15
  result.varbinds[0].value.should eql("test.net-snmp.org")
@@ -20,5 +21,6 @@ describe "in a thread" do
20
21
  did_callback.should be(true)
21
22
 
22
23
  Thread.kill(dispatch_thread)
24
+ Net::SNMP.thread_safe = false
23
25
  end
24
26
  end
data/spec/trap_spec.rb CHANGED
@@ -1,31 +1,33 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
+ # These are currently occasionally segfaulting at random. Other than that, they work 90% of the time ;)
4
+
3
5
  describe "snmp traps" do
4
6
  it "should send a v1 trap" do
5
- pending "still working on it"
6
- Net::SNMP::Session.open(:peername => '127.0.0.1') do |sess|
7
+ #pending "still working on it"
8
+ Net::SNMP::TrapSession.open(:peername => '127.0.0.1') do |sess|
7
9
  res = sess.trap
8
10
  res.should be_true
9
11
  end
10
12
  end
11
13
 
12
14
  it "should send a v2 inform" do
13
- pending "still working on it"
15
+ #pending "still working on it"
14
16
  did_callback = false
15
-
16
- Net::SNMP::Session.open(:peername => '127.0.0.1', :version => '2c') do |sess|
17
- sess.inform do |res|
17
+ Net::SNMP::TrapSession.open(:peername => '127.0.0.1', :version => '2c') do |sess|
18
+ sess.inform(:oid => 'coldStart.0') do |op, res|
18
19
  did_callback = true
19
20
  end
20
21
  end
22
+ Net::SNMP::Dispatcher.poll(false)
21
23
  did_callback.should be_true
22
24
  end
23
25
 
24
26
  it "should send v2 trap" do
25
- pending "still working on it"
26
- Net::SNMP::Session.open(:peername => '127.0.0.1', :version => '2c') do |sess|
27
- res = sess.trap_v2
27
+ #pending "still working on it"
28
+ Net::SNMP::TrapSession.open(:peername => '127.0.0.1', :version => '2c') do |sess|
29
+ res = sess.trap_v2(:oid => 'warmStart.0')
28
30
  res.should be_true
29
31
  end
30
32
  end
31
- end
33
+ end
data/spec/wrapper_spec.rb CHANGED
@@ -58,7 +58,7 @@ describe "Net::SNMP::Wrapper" do
58
58
  sess = Net::SNMP::Wrapper.snmp_open(@session.pointer)
59
59
  Net::SNMP::Wrapper.snmp_send(sess.pointer, @pdu)
60
60
  sleep 1
61
- fdset = Net::SNMP::Wrapper.get_fd_set
61
+ fdset = FFI::MemoryPointer.new(:pointer, Net::SNMP::Inline.fd_setsize / 8)
62
62
  fds = FFI::MemoryPointer.new(:int)
63
63
  #fds.autorelease = false
64
64
  tval = Net::SNMP::Wrapper::TimeVal.new
@@ -66,7 +66,7 @@ describe "Net::SNMP::Wrapper" do
66
66
  #block.autorelease = false
67
67
  block.write_int(1)
68
68
  Net::SNMP::Wrapper.snmp_select_info(fds, fdset, tval.pointer, block )
69
- Net::SNMP::Wrapper.select(fds.read_int, fdset, nil, nil, nil)
69
+ FFI::LibC.select(fds.read_int, fdset, nil, nil, nil)
70
70
  Net::SNMP::Wrapper.snmp_read(fdset)
71
71
  did_callback.should be(1)
72
72
  result.should eql('test.net-snmp.org')
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 7
9
- version: 0.1.7
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ron McClain
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-28 00:00:00 -05:00
17
+ date: 2011-04-30 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -69,6 +69,7 @@ files:
69
69
  - lib/net-snmp.rb
70
70
  - lib/net/snmp.rb
71
71
  - lib/net/snmp/constants.rb
72
+ - lib/net/snmp/debug.rb
72
73
  - lib/net/snmp/dispatcher.rb
73
74
  - lib/net/snmp/error.rb
74
75
  - lib/net/snmp/inline.rb
@@ -77,6 +78,7 @@ files:
77
78
  - lib/net/snmp/oid.rb
78
79
  - lib/net/snmp/pdu.rb
79
80
  - lib/net/snmp/session.rb
81
+ - lib/net/snmp/trap_session.rb
80
82
  - lib/net/snmp/utility.rb
81
83
  - lib/net/snmp/varbind.rb
82
84
  - lib/net/snmp/version.rb
@@ -84,6 +86,7 @@ files:
84
86
  - net-snmp.gemspec
85
87
  - spec/async_spec.rb
86
88
  - spec/em_spec.rb
89
+ - spec/error_spec.rb
87
90
  - spec/fiber_spec.rb
88
91
  - spec/mib_spec.rb
89
92
  - spec/net-snmp_spec.rb
@@ -129,6 +132,7 @@ summary: Object oriented wrapper around C net-snmp libraries
129
132
  test_files:
130
133
  - spec/async_spec.rb
131
134
  - spec/em_spec.rb
135
+ - spec/error_spec.rb
132
136
  - spec/fiber_spec.rb
133
137
  - spec/mib_spec.rb
134
138
  - spec/net-snmp_spec.rb