snmp 1.3.2 → 1.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cc05dcb597e677b4e3415d4ebbf8d3270a6ee0497811835161bc8a720e37bb1
4
- data.tar.gz: 1cb457419b0226e161ae789803a2924d80d6b93b4099535eebacf938d141b134
3
+ metadata.gz: 4a21d910b05ecc503b318d54843dc706c80e8912bdab3da2635e6cfed4fa1b7b
4
+ data.tar.gz: 5223e07377fc2bda06ebff57fa09022f22856fa26f596ecced8557f1c1267422
5
5
  SHA512:
6
- metadata.gz: '09a2f0ed024c6271556fe8afaded20ae06eef4b7c2857ee82e1dddd4196f280532060631b98f39bd24f2539c3e1a384bfd0b64cc45d5b80fba8ad567c7875528'
7
- data.tar.gz: a030ed0e551eb4fe3d8c96a2b02c731ec225e20c47804ee95e50488986d943410ff00fefb26a12a70c808b4db0a5a4a263361f7ebf3406e97e8beefb801ad769
6
+ metadata.gz: 560062489338a74306f8d8504135bad6cc07198d1e01a940da3857b1fce54f5f50ab6fa017b674ff2ee552cd0f14ac0ebdf7b89dafa2968c3275edb5c8fa872b
7
+ data.tar.gz: 696b0ce5b8858e49355011f1a7c8298838ec4cc4fa4f65fed7cdabc12a00c2ddfa26e070f29990c867a51d31b8cb0eaee297a6d75612c2d3722c8363dc54949b
data/CHANGELOG.md ADDED
@@ -0,0 +1,63 @@
1
+ # Change Log
2
+
3
+ ## Changes for version 1.3.3:
4
+ * Move web content to GitHub Pages https://github.com/ruby-snmp/ruby-snmp/pull/66
5
+ * Modernize project structure: README, gemspec, Rakefile, and development dependencies https://github.com/ruby-snmp/ruby-snmp/pull/65
6
+ * This change includes: Ship license file in gem. https://github.com/ruby-snmp/ruby-snmp/pull/65
7
+ * Migrate from Travis CI to GitHub Actions https://github.com/ruby-snmp/ruby-snmp/pull/64
8
+ * Transfer repository from `hallidave/ruby-snmp` to `ruby-snmp/ruby-snmp` https://github.com/ruby-snmp/ruby-snmp/pull/63
9
+ * Allow MIB dir to be specified when loading additional modules (Fixes: https://github.com/ruby-snmp/ruby-snmp/issues/55 )
10
+ * Name lookup hash values were set to nil when overwriting (Fixes: https://github.com/ruby-snmp/ruby-snmp/issues/54 )
11
+
12
+ ## Changes for version 1.3.2:
13
+ * Accept non-standard error status codes
14
+
15
+ ## Changes for version 1.3.1:
16
+ * Cleaned up deprecation warnings
17
+ * Fixed SNMP::Integer#<=> method for Ruby 2.3.0 and later
18
+ * Removed artificial limit on number of non-repeaters for GetBulkRequest
19
+ * SNMP::BER module no longer pollutes global namespace
20
+
21
+ ## Changes for version 1.2.0:
22
+ * Removed support for Ruby 1.8
23
+ * Changed license to MIT License
24
+
25
+ ## Changes for version 1.1.1:
26
+
27
+ * Incorporate various small pull requests
28
+
29
+ ## Changes for version 1.1.0:
30
+
31
+ * Added MIB support to ObjectId and Varbind, so that to_s can return symbolic information
32
+ * Added to_str method to ObjectId to return a numeric OID string (old to_s behavior)
33
+ * TrapListener can now support multiple community strings
34
+
35
+ ## Changes for version 1.0.4:
36
+
37
+ * New option handling and added lower-case versions of all options
38
+ * Added SNMP::VERSION constant
39
+ * Experimental support for IPv6
40
+ * Removed support for installation with setup.rb
41
+
42
+ ## Changes for version 1.0.3:
43
+
44
+ * Minor changes to Manager class. The :Transport option may now be an
45
+ object or a class. Explicity call Timeout.timeout so that a timeout
46
+ method may be defined in subclasses. Thanks to Eric Monti.
47
+
48
+ ## Changes for version 1.0.2:
49
+
50
+ * Internal code changes to make this library compatible with both Ruby 1.8
51
+ and Ruby 1.9. Note that an ord() method is now added to the Fixnum class
52
+ for Ruby 1.8. See the ber.rb file for details.
53
+
54
+ ## Changes for version 1.0.1:
55
+
56
+ * Made the host configurable for the TrapListener. Previously defaulted
57
+ to 'localhost'.
58
+
59
+ ## Changes for version 1.0.0:
60
+
61
+ * Added to_s method to TimeTicks. Displays time in human-readable form
62
+ instead of just a number. The to_i method can still be used to get the
63
+ number of ticks.
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2004-2014 David R. Halliday
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # SNMP Library for Ruby
2
+ [<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License MIT" />](https://raw.githubusercontent.com/ruby-snmp/ruby-snmp/master/MIT-LICENSE)
3
+ [<img src="https://badge.fury.io/rb/snmp.svg" alt="Gem Version" />](https://badge.fury.io/rb/snmp)
4
+
5
+ ## Summary
6
+
7
+ This library implements SNMP (the Simple Network Management Protocol). It is
8
+ implemented in pure Ruby, so there are no dependencies on external libraries
9
+ like [net-snmp](http://www.net-snmp.org/). You can run this library anywhere
10
+ that Ruby can run.
11
+
12
+ This release supports the following:
13
+
14
+ * The GetRequest, GetNextRequest, GetBulkRequest, SetRequest, Response
15
+ SNMPv1_Trap, SNMPv2_Trap, and Inform PDUs
16
+ * All of the ASN.1 data types defined by SNMPv1 and SNMPv2c
17
+ * Sending informs and v1 and v2 traps
18
+ * Trap handling for informs and v1 and v2 traps
19
+ * Symbolic OID values (ie. "ifTable" instead of "1.3.6.1.2.1.2.2") as parameters to the SNMP::Manager API
20
+ * Includes symbol data files for all current IETF MIBs
21
+ * Compatible with Ruby 1.9 and higher
22
+
23
+ See the SNMP::Manager, SNMP::TrapListener, and SNMP::MIB classes and the
24
+ examples below for more details.
25
+
26
+ ## Installation
27
+
28
+ You can use [RubyGems](https://rubygems.org/) to
29
+ install the latest version of the SNMP library.
30
+
31
+ ```sh
32
+ gem install snmp
33
+ ```
34
+
35
+ ## Examples
36
+
37
+ ### Get Request
38
+
39
+ Retrieve a system description.
40
+
41
+ ```ruby
42
+ require 'snmp'
43
+
44
+ SNMP::Manager.open(:host => 'localhost') do |manager|
45
+ response = manager.get(["sysDescr.0", "sysName.0"])
46
+ response.each_varbind do |vb|
47
+ puts "#{vb.name.to_s} #{vb.value.to_s} #{vb.value.asn1_type}"
48
+ end
49
+ end
50
+ ```
51
+
52
+ ### Set Request
53
+
54
+ Create a varbind for setting the system name.
55
+
56
+ ```ruby
57
+ require 'snmp'
58
+ include SNMP
59
+
60
+ manager = Manager.new(:host => 'localhost')
61
+ varbind = VarBind.new("1.3.6.1.2.1.1.5.0", OctetString.new("My System Name"))
62
+ manager.set(varbind)
63
+ manager.close
64
+ ```
65
+
66
+ ### Table Walk
67
+
68
+ Walk the ifTable.
69
+
70
+ ```ruby
71
+ require 'snmp'
72
+
73
+ ifTable_columns = ["ifIndex", "ifDescr", "ifInOctets", "ifOutOctets"]
74
+ SNMP::Manager.open(:host => 'localhost') do |manager|
75
+ manager.walk(ifTable_columns) do |row|
76
+ row.each { |vb| print "\t#{vb.value}" }
77
+ puts
78
+ end
79
+ end
80
+ ```
81
+
82
+ ### Get-Next Request
83
+
84
+ A more difficult way to walk the ifTable.
85
+
86
+ ```ruby
87
+ require 'snmp'
88
+ include SNMP
89
+
90
+ Manager.open(:host => 'localhost') do |manager|
91
+ ifTable = ObjectId.new("1.3.6.1.2.1.2.2")
92
+ next_oid = ifTable
93
+ while next_oid.subtree_of?(ifTable)
94
+ response = manager.get_next(next_oid)
95
+ varbind = response.varbind_list.first
96
+ next_oid = varbind.name
97
+ puts varbind.to_s
98
+ end
99
+ end
100
+ ```
101
+
102
+ ### Get-Bulk Request
103
+
104
+ Get interface description and admin status for 10 rows of the ifTable.
105
+
106
+ ```ruby
107
+ require 'snmp'
108
+ include SNMP
109
+
110
+ ifDescr_OID = ObjectId.new("1.3.6.1.2.1.2.2.1.2")
111
+ ifAdminStatus_OID = ObjectId.new("1.3.6.1.2.1.2.2.1.7")
112
+ MAX_ROWS = 10
113
+ Manager.open(:host => 'localhost') do |manager|
114
+ response = manager.get_bulk(0, MAX_ROWS, [ifDescr_OID, ifAdminStatus_OID])
115
+ list = response.varbind_list
116
+ until list.empty?
117
+ ifDescr = list.shift
118
+ ifAdminStatus = list.shift
119
+ puts "#{ifDescr.value} #{ifAdminStatus.value}"
120
+ end
121
+ end
122
+ ```
123
+
124
+ ### Trap Handling
125
+
126
+ Log traps to STDOUT.
127
+
128
+ ```ruby
129
+ require 'snmp'
130
+ require 'logger'
131
+
132
+ log = Logger.new(STDOUT)
133
+ m = SNMP::TrapListener.new do |manager|
134
+ manager.on_trap_default do |trap|
135
+ log.info trap.inspect
136
+ end
137
+ end
138
+ m.join
139
+ ```
140
+
141
+ ## License
142
+
143
+ This SNMP Library is released under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,58 +1,22 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/clean'
1
+ # frozen_string_literal: true
4
2
 
5
- require 'rdoc/task'
6
- require 'rubygems/package_task'
3
+ require "bundler/gem_tasks"
7
4
 
8
- task :default => [:test]
5
+ # Avoid using `minitest/test_task` for Ruby 2.5 and earlier
6
+ require "rake/testtask"
9
7
 
10
- # test target
11
- Rake::TestTask.new do |test|
12
- test.libs << "lib"
8
+ Rake::TestTask.new(:test) do |test|
9
+ test.libs << "lib"
13
10
  end
14
11
 
15
- # package target
16
- CLEAN.include 'pkg'
17
- CLEAN.include 'doc'
18
- CLEAN.include 'web/site'
19
-
20
- spec = Gem::Specification.load "snmp.gemspec"
21
-
22
- Gem::PackageTask.new(spec) do |package|
23
- package.need_zip = false
24
- package.need_tar = false
25
- end
12
+ task default: :test
26
13
 
27
14
  # rdoc, clobber_rdoc, rerdoc targets
15
+ require 'rdoc/task'
16
+
28
17
  Rake::RDocTask.new do |doc|
29
- doc.rdoc_dir = "doc"
30
- doc.main = "README.rdoc"
31
- doc.rdoc_files.include('README.rdoc', 'lib/**/*.rb')
32
- doc.title = "SNMP Library for Ruby"
18
+ doc.rdoc_dir = "doc"
19
+ doc.main = "README.md"
20
+ doc.rdoc_files.include("README.md", "lib/**/*.rb")
21
+ doc.title = "SNMP Library for Ruby"
33
22
  end
34
-
35
- namespace :web do
36
- desc "Generate website content"
37
- task :gen => :rdoc do
38
- ROOT_PATH = File.dirname(File.expand_path(__FILE__))
39
- SRC_DIR = ROOT_PATH + "/web/content"
40
- DEST_DIR = ROOT_PATH + "/web/site"
41
-
42
- rm_rf DEST_DIR
43
- mkdir_p DEST_DIR
44
-
45
- Dir.glob(SRC_DIR + "/*").each do |name|
46
- puts "#{name}...copying"
47
- cp name, DEST_DIR + "/" + File.basename(name)
48
- end
49
-
50
- puts "Documentation...copying"
51
- cp_r ROOT_PATH + "/doc", DEST_DIR + "/doc"
52
- end
53
-
54
- desc "Publish website to RubyForge"
55
- task :publish => :gen do
56
- sh "scp -r web/site/* davehal@rubyforge.org:/var/www/gforge-projects/snmplib"
57
- end
58
- end
data/dump_yaml.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'snmp'
3
+ require 'yaml'
4
+
5
+ varbinds = []
6
+ SNMP::Manager.open do |snmp|
7
+ snmp.walk("ifTable") do |vb|
8
+ varbinds << [vb.name.to_s, vb.value.to_s, vb.value.class.to_s]
9
+ end
10
+ end
11
+
12
+ puts varbinds.to_yaml
13
+
data/import.rb ADDED
@@ -0,0 +1,22 @@
1
+ # use local implementation, not the installed gem (if any)
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/lib")
3
+
4
+ require 'snmp/mib'
5
+
6
+ if ARGV.size == 1
7
+ mib_path = ARGV[0]
8
+ else
9
+ smilint_version = `smilint --version`
10
+ libsmi_version = smilint_version.split[1]
11
+ mib_path = "/usr/local/Cellar/libsmi/#{libsmi_version}/share/mibs/ietf"
12
+ end
13
+
14
+ Dir["#{mib_path}/*"].each do |file|
15
+ print file
16
+ if (File.basename(file) == 'DOT12-RPTR-MIB')
17
+ puts " (skipping)"
18
+ else
19
+ puts
20
+ SNMP::MIB::import_module(file)
21
+ end
22
+ end
data/lib/snmp/manager.rb CHANGED
@@ -205,7 +205,8 @@ module SNMP
205
205
  @transport = config.create_transport
206
206
  @max_bytes = config.max_recv_bytes
207
207
  @mib = MIB.new
208
- load_modules(config.mib_modules, config.mib_dir)
208
+ @mib_dir = config.mib_dir
209
+ load_modules(config.mib_modules, @mib_dir)
209
210
  @ignore_oid_order = config.ignore_oid_order
210
211
  @config = config.applied_config
211
212
  end
@@ -233,10 +234,6 @@ module SNMP
233
234
  @transport.close
234
235
  end
235
236
 
236
- def load_module(name)
237
- @mib.load_module(name)
238
- end
239
-
240
237
  ##
241
238
  # Sends a get request for the supplied list of ObjectId or VarBind
242
239
  # objects.
@@ -490,8 +487,12 @@ module SNMP
490
487
  @@request_id.force_next(request_id)
491
488
  end
492
489
 
493
- def load_modules(module_list, mib_dir)
494
- module_list.each { |m| @mib.load_module(m, mib_dir) }
490
+ def load_module(name, mib_dir = @mib_dir)
491
+ @mib.load_module(name, mib_dir)
492
+ end
493
+
494
+ def load_modules(module_list, mib_dir = @mib_dir)
495
+ module_list.each { |m| load_module(m, mib_dir) }
495
496
  end
496
497
 
497
498
  private
@@ -623,7 +624,8 @@ module SNMP
623
624
  @community = config.community
624
625
  @max_bytes = config.max_recv_bytes
625
626
  @mib = MIB.new
626
- load_modules(config.mib_modules, config.mib_dir)
627
+ @mib_dir = config.mib_dir
628
+ load_modules(config.mib_modules, @mib_dir)
627
629
  @config = config.applied_config
628
630
 
629
631
  @handler_init = block
@@ -697,12 +699,16 @@ module SNMP
697
699
  alias kill exit
698
700
  alias terminate exit
699
701
 
700
- private
702
+ def load_module(name, mib_dir = @mib_dir)
703
+ @mib.load_module(name, mib_dir)
704
+ end
701
705
 
702
- def load_modules(module_list, mib_dir)
703
- module_list.each { |m| @mib.load_module(m, mib_dir) }
706
+ def load_modules(module_list, mib_dir = @mib_dir)
707
+ module_list.each { |m| load_module(m, mib_dir) }
704
708
  end
705
709
 
710
+ private
711
+
706
712
  def process_traps(trap_listener)
707
713
  @handler_init.call(trap_listener) if @handler_init
708
714
  loop do
data/lib/snmp/mib.rb CHANGED
@@ -164,6 +164,7 @@ module SNMP
164
164
  end
165
165
  @by_name.merge!(oid_hash) do |key, old, value|
166
166
  warn "warning: overwriting old MIB name '#{key}'"
167
+ value
167
168
  end
168
169
  @by_module_by_name[module_name] = {}
169
170
  @by_module_by_name[module_name].merge!(oid_hash)
data/lib/snmp/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SNMP
3
- VERSION = "1.3.2"
3
+ VERSION = "1.3.3"
4
4
  end
metadata CHANGED
@@ -1,79 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Halliday
8
- autorequire:
9
- bindir: bin
8
+ bindir: exe
10
9
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rdoc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
69
12
  description: A Ruby implementation of SNMP (the Simple Network Management Protocol).
70
- email: hallidave@gmail.com
13
+ email:
14
+ - hallidave@gmail.com
71
15
  executables: []
72
16
  extensions: []
73
17
  extra_rdoc_files:
74
- - README.rdoc
18
+ - README.md
75
19
  files:
76
- - README.rdoc
20
+ - CHANGELOG.md
21
+ - MIT-LICENSE
22
+ - README.md
77
23
  - Rakefile
78
24
  - data/ruby/snmp/mibs/ACCOUNTING-CONTROL-MIB.yaml
79
25
  - data/ruby/snmp/mibs/ADSL-LINE-EXT-MIB.yaml
@@ -345,6 +291,7 @@ files:
345
291
  - data/ruby/snmp/mibs/VPN-TC-STD-MIB.yaml
346
292
  - data/ruby/snmp/mibs/VRRP-MIB.yaml
347
293
  - data/ruby/snmp/mibs/WWW-MIB.yaml
294
+ - dump_yaml.rb
348
295
  - examples/datetime.rb
349
296
  - examples/dump.rb
350
297
  - examples/get.rb
@@ -353,6 +300,7 @@ files:
353
300
  - examples/log_traps.rb
354
301
  - examples/set.rb
355
302
  - examples/walk.rb
303
+ - import.rb
356
304
  - lib/snmp.rb
357
305
  - lib/snmp/agent.rb
358
306
  - lib/snmp/ber.rb
@@ -362,24 +310,16 @@ files:
362
310
  - lib/snmp/pdu.rb
363
311
  - lib/snmp/varbind.rb
364
312
  - lib/snmp/version.rb
365
- - test/if_table1.yaml
366
- - test/if_table6.yaml
367
- - test/test_ber.rb
368
- - test/test_manager.rb
369
- - test/test_mib.rb
370
- - test/test_pdu.rb
371
- - test/test_retry.rb
372
- - test/test_smi.rb
373
- - test/test_varbind.rb
374
- - test/test_walk.rb
375
- homepage: https://github.com/hallidave/ruby-snmp
313
+ homepage: https://github.com/ruby-snmp/ruby-snmp
376
314
  licenses:
377
315
  - MIT
378
- metadata: {}
379
- post_install_message:
316
+ metadata:
317
+ homepage_uri: https://github.com/ruby-snmp/ruby-snmp
318
+ source_code_uri: https://github.com/ruby-snmp/ruby-snmp
319
+ changelog_uri: https://github.com/ruby-snmp/ruby-snmp/CHANGELOG.md
380
320
  rdoc_options:
381
321
  - "--main"
382
- - README.rdoc
322
+ - README.md
383
323
  - "--title"
384
324
  - SNMP Library for Ruby
385
325
  require_paths:
@@ -395,8 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
395
335
  - !ruby/object:Gem::Version
396
336
  version: '0'
397
337
  requirements: []
398
- rubygems_version: 3.0.3
399
- signing_key:
338
+ rubygems_version: 3.6.9
400
339
  specification_version: 4
401
340
  summary: A Ruby implementation of SNMP (the Simple Network Management Protocol).
402
341
  test_files: []