snmp4em 1.0.1 → 1.0.2
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/README.rdoc +28 -2
- data/lib/snmp4em/manager.rb +1 -1
- data/lib/snmp4em/requests/snmp_bulkwalk_request.rb +2 -2
- data/lib/snmp4em/requests/snmp_get_request.rb +2 -2
- data/lib/snmp4em/requests/snmp_getbulk_request.rb +2 -2
- data/lib/snmp4em/requests/snmp_getnext_request.rb +2 -2
- data/lib/snmp4em/requests/snmp_set_request.rb +2 -2
- data/lib/snmp4em/requests/snmp_walk_request.rb +2 -2
- data/lib/snmp4em/snmp_request.rb +15 -10
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -7,7 +7,7 @@ This gem extends Ruby-SNMP[http://snmplib.rubyforge.org] to use the asynchronous
|
|
7
7
|
|
8
8
|
== Features
|
9
9
|
|
10
|
-
|
10
|
+
The library currently supports:
|
11
11
|
|
12
12
|
* SNMP v1 and v2
|
13
13
|
* SNMP Get, GetNext, Set, and Walk requests. For SNMPv2 clients, GetBulk and WalkBulk
|
@@ -17,7 +17,29 @@ Future revisions of this library may support:
|
|
17
17
|
|
18
18
|
* Ability to act as an SNMP agent, responding to external queries.
|
19
19
|
|
20
|
-
There are no plans to support SNMP v3.
|
20
|
+
There are no plans to support SNMP v3 or the parsing of MIB files.
|
21
|
+
|
22
|
+
|
23
|
+
== Options
|
24
|
+
|
25
|
+
You may set the following options:
|
26
|
+
|
27
|
+
SNMP4EM::Manager.new(
|
28
|
+
:version => :SNMPv2c,
|
29
|
+
:host => "127.0.0.1",
|
30
|
+
:port => 161,
|
31
|
+
:community => "public", # Shorthand for setting both :community_ro and :community_rw
|
32
|
+
:community_ro => "public",
|
33
|
+
:community_rw => "public",
|
34
|
+
:timeout => 1,
|
35
|
+
:retries => 3 # Can also be specified as an array of individual timeouts
|
36
|
+
# For instance, [0.5, 1, 2.5] would send three requests with increasing timeout values
|
37
|
+
)
|
38
|
+
|
39
|
+
These options may also be passed to an individual query method, for instance:
|
40
|
+
|
41
|
+
snmp = SNMP4EM::Manager.new(...)
|
42
|
+
snmp.get(OID, :retries => 2, :timeout => 1)
|
21
43
|
|
22
44
|
|
23
45
|
== Backwards compatibility
|
@@ -162,6 +184,10 @@ A simple SNMP-GET-BULK:
|
|
162
184
|
|
163
185
|
== Change Log
|
164
186
|
|
187
|
+
Version 1.0.2:
|
188
|
+
|
189
|
+
* Ability to specify timeouts as an array of timeout values. Inspired by https://github.com/calmh/node-snmp-native.
|
190
|
+
|
165
191
|
Version 1.0.1:
|
166
192
|
|
167
193
|
* Requests resulting in an error now return nil unless return_raw is enabled
|
data/lib/snmp4em/manager.rb
CHANGED
@@ -47,12 +47,12 @@ module SNMP4EM
|
|
47
47
|
return
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
send_msg
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|
54
54
|
|
55
|
-
def
|
55
|
+
def send_msg
|
56
56
|
Manager.track_request(self)
|
57
57
|
|
58
58
|
pending_varbinds = pending_oids.collect{|oid| SNMP::VarBind.new(oid[:requested_oid], oid[:value])}
|
data/lib/snmp4em/snmp_request.rb
CHANGED
@@ -9,15 +9,21 @@ module SNMP4EM
|
|
9
9
|
|
10
10
|
@oids ||= [*oids].collect { |oid_str| { :requested_string => oid_str, :requested_oid => SNMP::ObjectId.new(oid_str), :state => :pending }}
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
retries = args[:retries] || @sender.retries
|
13
|
+
timeout = args[:timeout] || @sender.timeout
|
14
|
+
|
15
|
+
if retries.is_a?(Array)
|
16
|
+
@timeouts = retries.clone
|
17
|
+
else
|
18
|
+
@timeouts = (retries + 1).times.collect { timeout }
|
19
|
+
end
|
14
20
|
|
15
21
|
@return_raw = args[:return_raw] || false
|
16
22
|
@max_results = args[:max_results] || nil
|
17
23
|
|
18
24
|
init_callbacks
|
19
25
|
on_init(args) if respond_to?(:on_init)
|
20
|
-
|
26
|
+
send_msg
|
21
27
|
end
|
22
28
|
|
23
29
|
def pending_oids # @private
|
@@ -55,17 +61,16 @@ module SNMP4EM
|
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
58
|
-
def
|
59
|
-
@sender.
|
64
|
+
def send_msg(msg) # @private
|
65
|
+
@sender.send_msg msg
|
60
66
|
|
61
67
|
@timeout_timer.cancel if @timeout_timer.is_a?(EM::Timer)
|
62
68
|
|
63
|
-
@timeout_timer = EM::Timer.new(@
|
64
|
-
if @
|
65
|
-
send
|
66
|
-
@timeout_retries -= 1
|
67
|
-
else
|
69
|
+
@timeout_timer = EM::Timer.new(@timeouts.shift) do
|
70
|
+
if @timeouts.empty?
|
68
71
|
fail "exhausted all timeout retries"
|
72
|
+
else
|
73
|
+
send_msg
|
69
74
|
end
|
70
75
|
end
|
71
76
|
end
|