snmp4em 0.2.1 → 0.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.
metadata CHANGED
@@ -1,87 +1,113 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: snmp4em
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.3'
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Norman Elton
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-05-17 00:00:00 -04:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description: A high-performance SNMP engine built on EventMachine and Ruby-SNMP, supporting SNMPv1 and SNMPv2 operations
12
+ date: 2012-02-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: snmp
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: eventmachine
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ description: A high-performance SNMP engine built on EventMachine and Ruby-SNMP
23
47
  email: normelton@gmail.com
24
48
  executables: []
25
-
26
49
  extensions: []
27
-
28
- extra_rdoc_files:
29
- - README
30
- files:
50
+ extra_rdoc_files:
51
+ - README.rdoc
52
+ files:
53
+ - Gemfile
54
+ - README.rdoc
55
+ - Rakefile
31
56
  - lib/snmp4em.rb
32
- - lib/snmp4em/common.rb
57
+ - lib/snmp4em/common_requests.rb
58
+ - lib/snmp4em/extensions.rb
59
+ - lib/snmp4em/extensions/snmp/integer.rb
60
+ - lib/snmp4em/extensions/snmp/ip_address.rb
61
+ - lib/snmp4em/extensions/snmp/null.rb
62
+ - lib/snmp4em/extensions/snmp/object_id.rb
63
+ - lib/snmp4em/extensions/snmp/octet_string.rb
64
+ - lib/snmp4em/extensions/snmp/response_error.rb
33
65
  - lib/snmp4em/handler.rb
66
+ - lib/snmp4em/manager.rb
34
67
  - lib/snmp4em/requests/snmp_get_request.rb
35
68
  - lib/snmp4em/requests/snmp_getbulk_request.rb
36
69
  - lib/snmp4em/requests/snmp_getnext_request.rb
37
70
  - lib/snmp4em/requests/snmp_set_request.rb
38
71
  - lib/snmp4em/requests/snmp_walk_request.rb
39
72
  - lib/snmp4em/snmp_request.rb
40
- - lib/snmp4em/snmp_connection.rb
41
- - lib/snmp4em/snmp_v1.rb
42
- - lib/snmp4em/snmp_v2.rb
73
+ - lib/snmp4em/snmp_v2c_requests.rb
43
74
  - snmp4em.gemspec
75
+ - spec/models/test_message.rb
76
+ - spec/models/test_request.rb
77
+ - spec/models/test_response.rb
78
+ - spec/spec.opts
79
+ - spec/spec_helper.rb
80
+ - spec/unit/handler_spec.rb
81
+ - spec/unit/manager_spec.rb
44
82
  - Manifest
45
- - README
46
- has_rdoc: true
47
83
  homepage: http://github.com/normelton/snmp4em
48
84
  licenses: []
49
-
50
85
  post_install_message:
51
- rdoc_options:
86
+ rdoc_options:
52
87
  - --line-numbers
53
88
  - --inline-source
54
89
  - --title
55
90
  - Snmp4em
56
91
  - --main
57
- - README
58
- require_paths:
92
+ - README.rdoc
93
+ require_paths:
59
94
  - lib
60
- required_ruby_version: !ruby/object:Gem::Requirement
95
+ required_ruby_version: !ruby/object:Gem::Requirement
61
96
  none: false
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- hash: 3
66
- segments:
67
- - 0
68
- version: "0"
69
- required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
102
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 11
75
- segments:
76
- - 1
77
- - 2
78
- version: "1.2"
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '1.2'
79
107
  requirements: []
80
-
81
108
  rubyforge_project: snmp4em
82
- rubygems_version: 1.3.7
109
+ rubygems_version: 1.8.24
83
110
  signing_key:
84
111
  specification_version: 3
85
112
  summary: A high-performance SNMP engine built on EventMachine and Ruby-SNMP
86
113
  test_files: []
87
-
@@ -1,39 +0,0 @@
1
- module SNMP #:nodoc:
2
- class Null #:nodoc:
3
- class << self
4
- def rubify
5
- nil
6
- end
7
- end
8
- end
9
-
10
- class OctetString #:nodoc:
11
- alias :rubify :to_s
12
- end
13
-
14
- class Integer #:nodoc:
15
- alias :rubify :to_i
16
- end
17
-
18
- class ObjectId #:nodoc:
19
- alias :rubify :to_s
20
- end
21
-
22
- class IpAddress #:nodoc:
23
- alias :rubify :to_s
24
- end
25
-
26
- class ResponseError
27
- attr_reader :error_status
28
- alias :rubify :error_status #:nodoc:
29
-
30
- def initialize(error_status) #:nodoc:
31
- @error_status = error_status
32
- end
33
-
34
- # String representation of this error
35
- def to_s
36
- @error_status.to_s
37
- end
38
- end
39
- end
@@ -1,43 +0,0 @@
1
- # The SNMP4EM library
2
-
3
- module SNMP4EM
4
- class SnmpConnection
5
- @pending_requests = []
6
- @socket = nil
7
-
8
- class << self
9
- attr_reader :pending_requests
10
- attr_reader :socket
11
-
12
- def init_socket #:nodoc:
13
- if @socket.nil?
14
- @socket = EM::open_datagram_socket("0.0.0.0", 0, Handler)
15
- end
16
- end
17
- end
18
-
19
- attr_reader :host, :port, :timeout, :retries
20
-
21
- # Creates a new object to communicate with SNMPv1 agents. Optionally pass in the following parameters:
22
- # * _host_ - IP/hostname of remote agent (default: 127.0.0.1)
23
- # * _port_ - UDP port on remote agent (default: 161)
24
- # * _community_ - Community string to use (default: public)
25
- # * _community_ro_ - Read-only community string to use for get/getnext/walk operations (default: public)
26
- # * _community_rw_ - Read-write community string to use for set operations (default: public)
27
- # * _timeout_ - Number of seconds to wait before a request times out (default: 1)
28
- # * _retries_ - Number of retries before failing (default: 3)
29
-
30
- def initialize(args = {})
31
- @host = args[:host] || "127.0.0.1"
32
- @port = args[:port] || 161
33
- @timeout = args[:timeout] || 1
34
- @retries = args[:retries] || 3
35
-
36
- self.class.init_socket
37
- end
38
-
39
- def send(message) #:nodoc:
40
- self.class.socket.send_datagram message.encode, @host, @port
41
- end
42
- end
43
- end
@@ -1,104 +0,0 @@
1
- # The SNMP4EM library
2
-
3
- module SNMP4EM
4
- class SNMPv2 < SnmpConnection
5
- attr_reader :community_ro, :community_rw
6
-
7
- # Creates a new object to communicate with SNMPv1 agents. Optionally pass in the following parameters:
8
- # * _host_ - IP/hostname of remote agent (default: 127.0.0.1)
9
- # * _port_ - UDP port on remote agent (default: 161)
10
- # * _community_ - Community string to use (default: public)
11
- # * _community_ro_ - Read-only community string to use for get/getnext/walk operations (default: public)
12
- # * _community_rw_ - Read-write community string to use for set operations (default: public)
13
- # * _timeout_ - Number of seconds to wait before a request times out (default: 1)
14
- # * _retries_ - Number of retries before failing (default: 3)
15
-
16
- def initialize(args = {})
17
- super(args)
18
-
19
- @community_ro = args[:community_ro] || args[:community] || "public"
20
- @community_rw = args[:community_rw] || args[:community] || "public"
21
- end
22
-
23
- # Sends an SNMP-GET request to the remote agent for all OIDs specified in the _oids_ array. Returns a SnmpGetRequest object,
24
- # which implements EM::Deferrable. From there, implement a callback/errback to fetch the result. On success, the result will be
25
- # a hash, mapping requested OID values to results.
26
- #
27
- # Optional arguments can be passed into _args_, including:
28
- # * _return_raw_ - Return objects and errors as their raw SNMP types, such as SNMP::Integer instead of native Ruby integers, SNMP::OctetString instead of native Ruby strings, etc. (default: false)
29
-
30
- def get(oids, args = {})
31
- request = SnmpGetRequest.new(self, oids, args.merge(:version => :SNMPv2c))
32
- SnmpConnection.pending_requests << request
33
- return request
34
- end
35
-
36
- # Sends an SNMP-GETNEXT request to the remote agent for all OIDs specified in the _oids_ array. Returns a SnmpGetRequest object,
37
- # which implements EM::Deferrable. From there, implement a callback/errback to fetch the result. On success, the result will be
38
- # a hash, mapping requested OID values to two-element arrays consisting of [_next_oid_ , _next_value_]. Any values that produced an
39
- # error will map to a symbol representing the error.
40
- #
41
- # Optional arguments can be passed into _args_, including:
42
- # * _return_raw_ - Return objects and errors as their raw SNMP types, such as SNMP::Integer instead of native Ruby integers, SNMP::OctetString instead of native Ruby strings, etc. (default: false)
43
-
44
- def getnext(oids, args = {})
45
- request = SnmpGetNextRequest.new(self, oids, args.merge(:version => :SNMPv2c))
46
- SnmpConnection.pending_requests << request
47
- return request
48
- end
49
-
50
- # Sends an SNMP-SET request to the remote agent for all OIDs specified in the _oids_ hash. The hash must map OID values to requested
51
- # values. Values can either be specified as Ruby native strings/integers, or as SNMP-specific classes (SNMP::IpAddress, etc).
52
- # Returns a SnmpSetRequest object, which implements EM::Deferrable. From there, implement a callback/errback to fetch the result.
53
- # On success, the result will be a hash, mapping requested OID values to the returned value from the agent. Any values that were stored
54
- # successfully will map to _true_, otherwise, the value will map to a symbol representing the error.
55
- #
56
- # Optional arguments can be passed into _args_, including:
57
- # * _return_raw_ - Return error objects as SNMP::ResponseError instead of a symbol
58
-
59
- def set(oids, args = {})
60
- request = SnmpSetRequest.new(self, oids, args.merge(:version => :SNMPv2c))
61
- SnmpConnection.pending_requests << request
62
- return request
63
- end
64
-
65
- # Sends a series of SNMP-GETNEXT requests to simulate an SNMP "walk" operation. Given an OID prefix, the library will keep requesting the
66
- # next OID until that returned OID does not begin with the requested prefix. This gives the ability to retrieve entire portions of the
67
- # SNMP tree in one "operation". Multiple OID prefixes can be passed into the _oids_ array, and will be fetched in parallel. The function returns
68
- # a SnmpWalkRequest object, which implements EM::Deferrable. From there, implement a callback/errback to fetch the result. On success, the
69
- # result will be a hash, mapping requested OID prefixes to the returned value. Successful walks will be mapped to an array of two-element arrays,
70
- # each of which consists of [_oid_ , _value_]. Unsuccessful walks will be mapped to a symbol representing the error.
71
-
72
- # Optional arguments can be passed into _args_, including:
73
- # * _return_raw_ - Return objects and errors as their raw SNMP types, such as SNMP::Integer instead of native Ruby integers, SNMP::OctetString instead of native Ruby strings, etc. (default: false)
74
- # * _max_results_ - Maximum number of results to be returned for any single OID prefix (default: nil = unlimited)
75
-
76
- def walk(oids, args = {})
77
- request = SnmpWalkRequest.new(self, oids, args.merge(:version => :SNMPv2c))
78
- SnmpConnection.pending_requests << request
79
- return request
80
- end
81
-
82
- # Sends an SNMPv2 GET-BULK request to fetch multiple OID-value pairings simultaneously. This produces similar results to an SNMP-WALK using a single
83
- # request/response transaction (SNMP-WALK is actually an inefficient series of GET-NEXTs). Multiple OIDs can be passed into the _oids_ array. Two
84
- # additional parameters control how this list is processed. Setting the parameter _nonrepeaters_ to value _N_ indicates that the first _N_ OIDs will
85
- # fetch a single value. This is identical to running a single GET-NEXT for the OID. Any remaining OIDs will fetch multiple values. The number of values
86
- # fetched is controlled by the parameter _maxrepetitions_. The function returns a SnmpGetBulkRequest object, which implements EM::Deferrable. From there,
87
- # implement a callback/errback to fetch the result. On success, the result will be a hash, mapping requested OID prefixes to the returned value.
88
- # Successful fetches will be mapped to an array of two-element arrays, each of which consists of [_oid_ , _value_]. Unsuccessful fetches will be mapped to a
89
- # symbol representing the error.
90
-
91
- # For more information, see http://tools.ietf.org/html/rfc1905#section-4.2.3
92
-
93
- # Optional arguments can be passed into _args_, including:
94
- # * _return_raw_ - Return objects and errors as their raw SNMP types, such as SNMP::Integer instead of native Ruby integers, SNMP::OctetString instead of native Ruby strings, etc. (default: false)
95
- # * _nonrepeaters_ - Number of OIDs passed to which exactly one result will be returned (default is 0)
96
- # * _maxrepetitions_ - Number of OID-value pairs to be returned for each OID (default is 10)
97
-
98
- def getbulk(oids, args = {})
99
- request = SnmpGetBulkRequest.new(self, oids, args.merge(:version => :SNMPv2c))
100
- SnmpConnection.pending_requests << request
101
- return request
102
- end
103
- end
104
- end