snmp 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/README +31 -21
  2. data/Rakefile +4 -4
  3. data/data/ruby/snmp/mibs/ACCOUNTING-CONTROL-MIB.yaml +3 -1
  4. data/data/ruby/snmp/mibs/ADSL-LINE-EXT-MIB.yaml +59 -54
  5. data/data/ruby/snmp/mibs/ADSL-LINE-MIB.yaml +13 -1
  6. data/data/ruby/snmp/mibs/ADSL-TC-MIB.yaml +1 -1
  7. data/data/ruby/snmp/mibs/AGENTX-MIB.yaml +1 -1
  8. data/data/ruby/snmp/mibs/APM-MIB.yaml +3 -1
  9. data/data/ruby/snmp/mibs/APPC-MIB.yaml +1 -1
  10. data/data/ruby/snmp/mibs/APPLETALK-MIB.yaml +1 -1
  11. data/data/ruby/snmp/mibs/APPLICATION-MIB.yaml +1 -1
  12. data/data/ruby/snmp/mibs/APPN-DLUR-MIB.yaml +1 -1
  13. data/data/ruby/snmp/mibs/APPN-MIB.yaml +2 -1
  14. data/data/ruby/snmp/mibs/APPN-TRAP-MIB.yaml +7 -1
  15. data/data/ruby/snmp/mibs/APS-MIB.yaml +6 -1
  16. data/data/ruby/snmp/mibs/ATM-ACCOUNTING-INFORMATION-MIB.yaml +1 -1
  17. data/data/ruby/snmp/mibs/ATM-MIB.yaml +1 -1
  18. data/data/ruby/snmp/mibs/ATM-TC-MIB.yaml +1 -1
  19. data/data/ruby/snmp/mibs/ATM2-MIB.yaml +2 -1
  20. data/data/ruby/snmp/mibs/BGP4-MIB.yaml +3 -1
  21. data/data/ruby/snmp/mibs/BLDG-HVAC-MIB.yaml +1 -1
  22. data/data/ruby/snmp/mibs/BRIDGE-MIB.yaml +3 -1
  23. data/data/ruby/snmp/mibs/CHARACTER-MIB.yaml +1 -1
  24. data/data/ruby/snmp/mibs/CIRCUIT-IF-MIB.yaml +1 -1
  25. data/data/ruby/snmp/mibs/CLNS-MIB.yaml +1 -1
  26. data/data/ruby/snmp/mibs/COFFEE-POT-MIB.yaml +1 -1
  27. data/data/ruby/snmp/mibs/COPS-CLIENT-MIB.yaml +1 -1
  28. data/data/ruby/snmp/mibs/DECNET-PHIV-MIB.yaml +1 -1
  29. data/data/ruby/snmp/mibs/DIAL-CONTROL-MIB.yaml +3 -1
  30. data/data/ruby/snmp/mibs/DIFFSERV-CONFIG-MIB.yaml +1 -1
  31. data/data/ruby/snmp/mibs/DIFFSERV-DSCP-TC.yaml +1 -1
  32. data/data/ruby/snmp/mibs/DIFFSERV-MIB.yaml +1 -1
  33. data/data/ruby/snmp/mibs/DIRECTORY-SERVER-MIB.yaml +1 -1
  34. data/data/ruby/snmp/mibs/DISMAN-EVENT-MIB.yaml +6 -1
  35. data/data/ruby/snmp/mibs/DISMAN-EXPRESSION-MIB.yaml +1 -1
  36. data/data/ruby/snmp/mibs/DISMAN-NSLOOKUP-MIB.yaml +1 -1
  37. data/data/ruby/snmp/mibs/DISMAN-PING-MIB.yaml +4 -1
  38. data/data/ruby/snmp/mibs/DISMAN-SCHEDULE-MIB.yaml +2 -1
  39. data/data/ruby/snmp/mibs/DISMAN-SCRIPT-MIB.yaml +4 -1
  40. data/data/ruby/snmp/mibs/DISMAN-TRACEROUTE-MIB.yaml +4 -1
  41. data/data/ruby/snmp/mibs/DLSW-MIB.yaml +7 -1
  42. data/data/ruby/snmp/mibs/DNS-RESOLVER-MIB.yaml +1 -1
  43. data/data/ruby/snmp/mibs/DNS-SERVER-MIB.yaml +1 -1
  44. data/data/ruby/snmp/mibs/DOCS-BPI-MIB.yaml +1 -1
  45. data/data/ruby/snmp/mibs/DOCS-CABLE-DEVICE-MIB.yaml +1 -1
  46. data/data/ruby/snmp/mibs/DOCS-IF-MIB.yaml +1 -1
  47. data/data/ruby/snmp/mibs/DOT12-IF-MIB.yaml +1 -1
  48. data/data/ruby/snmp/mibs/DS0-MIB.yaml +1 -1
  49. data/data/ruby/snmp/mibs/DS0BUNDLE-MIB.yaml +1 -1
  50. data/data/ruby/snmp/mibs/DS1-MIB.yaml +2 -1
  51. data/data/ruby/snmp/mibs/DS3-MIB.yaml +2 -1
  52. data/data/ruby/snmp/mibs/DSA-MIB.yaml +1 -1
  53. data/data/ruby/snmp/mibs/DSMON-MIB.yaml +1 -1
  54. data/data/ruby/snmp/mibs/EBN-MIB.yaml +1 -1
  55. data/data/ruby/snmp/mibs/ENTITY-MIB.yaml +2 -1
  56. data/data/ruby/snmp/mibs/ENTITY-SENSOR-MIB.yaml +1 -1
  57. data/data/ruby/snmp/mibs/ETHER-CHIPSET-MIB.yaml +1 -1
  58. data/data/ruby/snmp/mibs/ETHER-WIS.yaml +1 -1
  59. data/data/ruby/snmp/mibs/EtherLike-MIB.yaml +1 -1
  60. data/data/ruby/snmp/mibs/FDDI-SMT73-MIB.yaml +1 -1
  61. data/data/ruby/snmp/mibs/FIBRE-CHANNEL-FE-MIB.yaml +1 -1
  62. data/data/ruby/snmp/mibs/FLOW-METER-MIB.yaml +1 -1
  63. data/data/ruby/snmp/mibs/FR-ATM-PVC-SERVICE-IWF-MIB.yaml +2 -1
  64. data/data/ruby/snmp/mibs/FR-MFR-MIB.yaml +2 -1
  65. data/data/ruby/snmp/mibs/FRAME-RELAY-DTE-MIB.yaml +2 -1
  66. data/data/ruby/snmp/mibs/FRNETSERV-MIB.yaml +3 -1
  67. data/data/ruby/snmp/mibs/FRSLD-MIB.yaml +1 -1
  68. data/data/ruby/snmp/mibs/Finisher-MIB.yaml +1 -1
  69. data/data/ruby/snmp/mibs/GSMP-MIB.yaml +11 -1
  70. data/data/ruby/snmp/mibs/HC-ALARM-MIB.yaml +3 -1
  71. data/data/ruby/snmp/mibs/HC-PerfHist-TC-MIB.yaml +1 -1
  72. data/data/ruby/snmp/mibs/HC-RMON-MIB.yaml +1 -1
  73. data/data/ruby/snmp/mibs/HCNUM-TC.yaml +1 -1
  74. data/data/ruby/snmp/mibs/HDSL2-SHDSL-LINE-MIB.yaml +115 -99
  75. data/data/ruby/snmp/mibs/HOST-RESOURCES-MIB.yaml +1 -1
  76. data/data/ruby/snmp/mibs/HOST-RESOURCES-TYPES.yaml +1 -1
  77. data/data/ruby/snmp/mibs/HPR-IP-MIB.yaml +1 -1
  78. data/data/ruby/snmp/mibs/HPR-MIB.yaml +1 -1
  79. data/data/ruby/snmp/mibs/IF-INVERTED-STACK-MIB.yaml +1 -1
  80. data/data/ruby/snmp/mibs/IF-MIB.yaml +3 -1
  81. data/data/ruby/snmp/mibs/IGMP-STD-MIB.yaml +1 -1
  82. data/data/ruby/snmp/mibs/INET-ADDRESS-MIB.yaml +1 -1
  83. data/data/ruby/snmp/mibs/INTEGRATED-SERVICES-GUARANTEED-MIB.yaml +1 -1
  84. data/data/ruby/snmp/mibs/INTEGRATED-SERVICES-MIB.yaml +1 -1
  85. data/data/ruby/snmp/mibs/INTERFACETOPN-MIB.yaml +1 -1
  86. data/data/ruby/snmp/mibs/IP-FORWARD-MIB.yaml +1 -1
  87. data/data/ruby/snmp/mibs/IP-MIB.yaml +1 -1
  88. data/data/ruby/snmp/mibs/IPATM-IPMC-MIB.yaml +2 -1
  89. data/data/ruby/snmp/mibs/IPMROUTE-STD-MIB.yaml +1 -1
  90. data/data/ruby/snmp/mibs/IPOA-MIB.yaml +5 -1
  91. data/data/ruby/snmp/mibs/IPV6-FLOW-LABEL-MIB.yaml +1 -1
  92. data/data/ruby/snmp/mibs/IPV6-ICMP-MIB.yaml +1 -1
  93. data/data/ruby/snmp/mibs/IPV6-MIB.yaml +2 -1
  94. data/data/ruby/snmp/mibs/IPV6-MLD-MIB.yaml +1 -1
  95. data/data/ruby/snmp/mibs/IPV6-TCP-MIB.yaml +1 -1
  96. data/data/ruby/snmp/mibs/IPV6-UDP-MIB.yaml +1 -1
  97. data/data/ruby/snmp/mibs/ISDN-MIB.yaml +2 -1
  98. data/data/ruby/snmp/mibs/Job-Monitoring-MIB.yaml +1 -1
  99. data/data/ruby/snmp/mibs/L2TP-MIB.yaml +2 -1
  100. data/data/ruby/snmp/mibs/MALLOC-MIB.yaml +1 -1
  101. data/data/ruby/snmp/mibs/MAU-MIB.yaml +3 -1
  102. data/data/ruby/snmp/mibs/MIOX25-MIB.yaml +1 -1
  103. data/data/ruby/snmp/mibs/MIP-MIB.yaml +2 -1
  104. data/data/ruby/snmp/mibs/MPLS-FTN-STD-MIB.yaml +1 -1
  105. data/data/ruby/snmp/mibs/MPLS-LDP-ATM-STD-MIB.yaml +1 -1
  106. data/data/ruby/snmp/mibs/MPLS-LDP-FRAME-RELAY-STD-MIB.yaml +1 -1
  107. data/data/ruby/snmp/mibs/MPLS-LDP-GENERIC-STD-MIB.yaml +1 -1
  108. data/data/ruby/snmp/mibs/MPLS-LDP-STD-MIB.yaml +5 -1
  109. data/data/ruby/snmp/mibs/MPLS-LSR-STD-MIB.yaml +3 -1
  110. data/data/ruby/snmp/mibs/MPLS-TC-STD-MIB.yaml +1 -1
  111. data/data/ruby/snmp/mibs/MPLS-TE-STD-MIB.yaml +5 -1
  112. data/data/ruby/snmp/mibs/MTA-MIB.yaml +1 -1
  113. data/data/ruby/snmp/mibs/Modem-MIB.yaml +1 -1
  114. data/data/ruby/snmp/mibs/NETWORK-SERVICES-MIB.yaml +1 -1
  115. data/data/ruby/snmp/mibs/NHRP-MIB.yaml +1 -1
  116. data/data/ruby/snmp/mibs/NOTIFICATION-LOG-MIB.yaml +1 -1
  117. data/data/ruby/snmp/mibs/OPT-IF-MIB.yaml +1 -1
  118. data/data/ruby/snmp/mibs/OSPF-MIB.yaml +1 -1
  119. data/data/ruby/snmp/mibs/OSPF-TRAP-MIB.yaml +17 -1
  120. data/data/ruby/snmp/mibs/P-BRIDGE-MIB.yaml +1 -1
  121. data/data/ruby/snmp/mibs/PARALLEL-MIB.yaml +1 -1
  122. data/data/ruby/snmp/mibs/PIM-MIB.yaml +2 -1
  123. data/data/ruby/snmp/mibs/PINT-MIB.yaml +1 -1
  124. data/data/ruby/snmp/mibs/POWER-ETHERNET-MIB.yaml +4 -1
  125. data/data/ruby/snmp/mibs/PPP-BRIDGE-NCP-MIB.yaml +1 -1
  126. data/data/ruby/snmp/mibs/PPP-IP-NCP-MIB.yaml +1 -1
  127. data/data/ruby/snmp/mibs/PPP-LCP-MIB.yaml +1 -1
  128. data/data/ruby/snmp/mibs/PPP-SEC-MIB.yaml +1 -1
  129. data/data/ruby/snmp/mibs/PTOPO-MIB.yaml +2 -1
  130. data/data/ruby/snmp/mibs/PerfHist-TC-MIB.yaml +1 -1
  131. data/data/ruby/snmp/mibs/Printer-MIB.yaml +2 -1
  132. data/data/ruby/snmp/mibs/Q-BRIDGE-MIB.yaml +1 -1
  133. data/data/ruby/snmp/mibs/RADIUS-ACC-CLIENT-MIB.yaml +1 -1
  134. data/data/ruby/snmp/mibs/RADIUS-ACC-SERVER-MIB.yaml +1 -1
  135. data/data/ruby/snmp/mibs/RADIUS-AUTH-CLIENT-MIB.yaml +1 -1
  136. data/data/ruby/snmp/mibs/RADIUS-AUTH-SERVER-MIB.yaml +1 -1
  137. data/data/ruby/snmp/mibs/RDBMS-MIB.yaml +3 -1
  138. data/data/ruby/snmp/mibs/RFC1065-SMI.yaml +1 -1
  139. data/data/ruby/snmp/mibs/RFC1155-SMI.yaml +1 -1
  140. data/data/ruby/snmp/mibs/RFC1158-MIB.yaml +1 -1
  141. data/data/ruby/snmp/mibs/RFC1213-MIB.yaml +1 -1
  142. data/data/ruby/snmp/mibs/RFC1269-MIB.yaml +3 -1
  143. data/data/ruby/snmp/mibs/RFC1271-MIB.yaml +1 -1
  144. data/data/ruby/snmp/mibs/RFC1285-MIB.yaml +1 -1
  145. data/data/ruby/snmp/mibs/RFC1316-MIB.yaml +1 -1
  146. data/data/ruby/snmp/mibs/RFC1381-MIB.yaml +1 -1
  147. data/data/ruby/snmp/mibs/RFC1382-MIB.yaml +3 -1
  148. data/data/ruby/snmp/mibs/RFC1414-MIB.yaml +1 -1
  149. data/data/ruby/snmp/mibs/RIPv2-MIB.yaml +1 -1
  150. data/data/ruby/snmp/mibs/RMON-MIB.yaml +3 -1
  151. data/data/ruby/snmp/mibs/RMON2-MIB.yaml +1 -1
  152. data/data/ruby/snmp/mibs/ROHC-MIB.yaml +1 -1
  153. data/data/ruby/snmp/mibs/ROHC-RTP-MIB.yaml +1 -1
  154. data/data/ruby/snmp/mibs/ROHC-UNCOMPRESSED-MIB.yaml +1 -1
  155. data/data/ruby/snmp/mibs/RS-232-MIB.yaml +1 -1
  156. data/data/ruby/snmp/mibs/RSVP-MIB.yaml +3 -1
  157. data/data/ruby/snmp/mibs/RTP-MIB.yaml +1 -1
  158. data/data/ruby/snmp/mibs/SFLOW-MIB.yaml +1 -1
  159. data/data/ruby/snmp/mibs/SIP-MIB.yaml +1 -1
  160. data/data/ruby/snmp/mibs/SLAPM-MIB.yaml +13 -1
  161. data/data/ruby/snmp/mibs/SMON-MIB.yaml +1 -1
  162. data/data/ruby/snmp/mibs/SNA-NAU-MIB.yaml +5 -1
  163. data/data/ruby/snmp/mibs/SNA-SDLC-MIB.yaml +3 -1
  164. data/data/ruby/snmp/mibs/SNMP-COMMUNITY-MIB.yaml +1 -1
  165. data/data/ruby/snmp/mibs/SNMP-FRAMEWORK-MIB.yaml +1 -1
  166. data/data/ruby/snmp/mibs/SNMP-MPD-MIB.yaml +1 -1
  167. data/data/ruby/snmp/mibs/SNMP-NOTIFICATION-MIB.yaml +1 -1
  168. data/data/ruby/snmp/mibs/SNMP-PROXY-MIB.yaml +1 -1
  169. data/data/ruby/snmp/mibs/SNMP-REPEATER-MIB.yaml +6 -1
  170. data/data/ruby/snmp/mibs/SNMP-TARGET-MIB.yaml +1 -1
  171. data/data/ruby/snmp/mibs/SNMP-USER-BASED-SM-MIB.yaml +1 -1
  172. data/data/ruby/snmp/mibs/SNMP-USM-DH-OBJECTS-MIB.yaml +1 -1
  173. data/data/ruby/snmp/mibs/SNMP-VIEW-BASED-ACM-MIB.yaml +1 -1
  174. data/data/ruby/snmp/mibs/SNMPv2-MIB.yaml +4 -1
  175. data/data/ruby/snmp/mibs/SNMPv2-SMI.yaml +1 -1
  176. data/data/ruby/snmp/mibs/SNMPv2-TM.yaml +1 -1
  177. data/data/ruby/snmp/mibs/SNMPv2-USEC-MIB.yaml +1 -1
  178. data/data/ruby/snmp/mibs/SONET-MIB.yaml +1 -1
  179. data/data/ruby/snmp/mibs/SOURCE-ROUTING-MIB.yaml +1 -1
  180. data/data/ruby/snmp/mibs/SYSAPPL-MIB.yaml +1 -1
  181. data/data/ruby/snmp/mibs/TCP-MIB.yaml +1 -1
  182. data/data/ruby/snmp/mibs/TCPIPX-MIB.yaml +1 -1
  183. data/data/ruby/snmp/mibs/TN3270E-MIB.yaml +1 -1
  184. data/data/ruby/snmp/mibs/TN3270E-RT-MIB.yaml +5 -1
  185. data/data/ruby/snmp/mibs/TOKEN-RING-RMON-MIB.yaml +1 -1
  186. data/data/ruby/snmp/mibs/TOKENRING-MIB.yaml +1 -1
  187. data/data/ruby/snmp/mibs/TOKENRING-STATION-SR-MIB.yaml +1 -1
  188. data/data/ruby/snmp/mibs/TRANSPORT-ADDRESS-MIB.yaml +1 -1
  189. data/data/ruby/snmp/mibs/TUNNEL-MIB.yaml +1 -1
  190. data/data/ruby/snmp/mibs/UDP-MIB.yaml +1 -1
  191. data/data/ruby/snmp/mibs/UPS-MIB.yaml +5 -1
  192. data/data/ruby/snmp/mibs/VDSL-LINE-MIB.yaml +13 -1
  193. data/data/ruby/snmp/mibs/VRRP-MIB.yaml +3 -1
  194. data/data/ruby/snmp/mibs/WWW-MIB.yaml +1 -1
  195. data/examples/dump.rb +1 -1
  196. data/lib/snmp/manager.rb +32 -5
  197. data/lib/snmp/mib.rb +4 -0
  198. data/lib/snmp/pdu.rb +3 -1
  199. data/test/test_ber.rb +4 -0
  200. data/test/test_manager.rb +16 -3
  201. data/test/test_mib.rb +9 -0
  202. data/test/test_pdu.rb +2 -2
  203. data/test/test_smi.rb +19 -0
  204. data/test/test_walk.rb +21 -1
  205. metadata +10 -6
@@ -88,4 +88,4 @@ wwwRequestInRequests: 1.3.6.1.2.1.65.1.2.2.1.2
88
88
  wwwResponseOutLastTime: 1.3.6.1.2.1.65.1.2.5.1.4
89
89
  wwwDocumentStatistics: 1.3.6.1.2.1.65.1.3
90
90
  wwwDocCtrlTable: 1.3.6.1.2.1.65.1.3.1
91
- wwwDocBucketIndex: 1.3.6.1.2.1.65.1.3.3.1.1
91
+ wwwDocBucketIndex: 1.3.6.1.2.1.65.1.3.3.1.1
@@ -9,7 +9,7 @@ next_oid = start_oid
9
9
  while next_oid.subtree_of?(start_oid)
10
10
  response = manager.get_next(next_oid)
11
11
  varbind = response.varbind_list.first
12
- break if varbind.value == EndOfMibView
12
+ break if EndOfMibView == varbind.value
13
13
  next_oid = varbind.name
14
14
  puts "#{varbind.name.to_s} #{varbind.value.to_s} #{varbind.value.asn1_type}"
15
15
  end
@@ -202,6 +202,28 @@ class Manager
202
202
  try_request(request)
203
203
  end
204
204
 
205
+ ##
206
+ # Sends a get request for the supplied list of ObjectId or VarBind
207
+ # objects.
208
+ #
209
+ # Returns a list of the varbind values only, not the entire response,
210
+ # in the same order as the initial object_list. This method is
211
+ # useful for retrieving scalar values.
212
+ #
213
+ # For example:
214
+ #
215
+ # SNMP::Manager.open(:Host => "localhost") do |manager|
216
+ # puts manager.get_value("sysDescr.0")
217
+ # end
218
+ #
219
+ def get_value(object_list)
220
+ if object_list.respond_to? :to_ary
221
+ get(object_list).vb_list.collect { |vb| vb.value }
222
+ else
223
+ get(object_list).vb_list.first.value
224
+ end
225
+ end
226
+
205
227
  ##
206
228
  # Sends a get-next request for the supplied list of ObjectId or VarBind
207
229
  # objects.
@@ -273,17 +295,19 @@ class Manager
273
295
  loop do
274
296
  varbind_list = get_next(varbind_list).varbind_list
275
297
  first_vb = varbind_list.first
298
+ break if EndOfMibView == first_vb.value
276
299
  stop_oid = first_vb.name
277
300
  if stop_oid <= last_oid
278
301
  warn "OIDs are not increasing, #{last_oid} followed by #{stop_oid}"
279
302
  break
280
303
  end
281
304
  break unless stop_oid.subtree_of?(start_oid)
282
- break if stop_oid == EndOfMibView
283
305
  last_oid = stop_oid
284
- if varbind_list.length == 1
306
+ if object_list.respond_to?(:to_str) ||
307
+ object_list.respond_to?(:to_varbind)
308
+ then
285
309
  yield first_vb
286
- else
310
+ else
287
311
  yield varbind_list
288
312
  end
289
313
  end
@@ -318,6 +342,8 @@ class Manager
318
342
  end
319
343
  rescue Timeout::Error
320
344
  # no action - try again
345
+ rescue => e
346
+ warn e.to_s
321
347
  end
322
348
  end
323
349
  raise RequestTimeout, "host #{@config[:Host]} not responding", caller
@@ -333,7 +359,7 @@ class Manager
333
359
  message = Message.decode(data)
334
360
  response = message.pdu
335
361
  if (request.request_id != response.request_id)
336
- raise "Request ID mismatch: expected #{request.request_id}, got #{pdu.request_id}", caller
362
+ raise RuntimeError, "Request ID mismatch: expected #{request.request_id}, got #{response.request_id}", caller
337
363
  end
338
364
  response
339
365
  end
@@ -418,7 +444,8 @@ class TrapListener
418
444
 
419
445
  ##
420
446
  # Define a trap handler block for a specific trap ObjectId. This handler
421
- # only applies to SNMPv2 traps.
447
+ # only applies to SNMPv2 traps. Note that symbolic OIDs are not
448
+ # supported by this method (like in the SNMP.Manager class).
422
449
  #
423
450
  def on_trap(object_id, &block)
424
451
  raise ArgumentError, "a block must be provided" unless block
@@ -77,8 +77,12 @@ class MIB
77
77
  if mib["nodes"]
78
78
  oid_hash = {}
79
79
  mib["nodes"].each { |key, value| oid_hash[key] = value["oid"] }
80
+ if mib["notifications"]
81
+ mib["notifications"].each { |key, value| oid_hash[key] = value["oid"] }
82
+ end
80
83
  File.open(module_file_name(module_name, mib_dir), 'w') do |file|
81
84
  YAML.dump(oid_hash, file)
85
+ file.puts
82
86
  end
83
87
  module_name
84
88
  else
@@ -111,6 +111,8 @@ class PDU
111
111
  attr_accessor :error_index
112
112
  attr_accessor :varbind_list
113
113
 
114
+ alias vb_list varbind_list
115
+
114
116
  def self.decode(pdu_class, pdu_data)
115
117
  request_id, remainder = decode_integer(pdu_data)
116
118
  error_status, remainder = decode_integer(remainder)
@@ -218,7 +220,7 @@ class Response < PDU
218
220
  class << self
219
221
  def from_pdu(request)
220
222
  Response.new(request.request_id, request.varbind_list,
221
- request.error_status, request.error_index)
223
+ :noError, 0)
222
224
  end
223
225
  end
224
226
 
@@ -1,4 +1,5 @@
1
1
  require 'test/unit'
2
+ require 'snmp/varbind'
2
3
  require 'snmp/ber'
3
4
 
4
5
  class ASN1_Test < Test::Unit::TestCase
@@ -231,6 +232,9 @@ class ASN1_Test < Test::Unit::TestCase
231
232
  assert_equal("\006\003" << 82.chr << "\202\001", encode_object_id([2,2,257]))
232
233
  assert_raise(InvalidObjectId) { encode_object_id([3,2,257]) }
233
234
  assert_raise(InvalidObjectId) { encode_object_id([]) }
235
+
236
+ assert_equal("\006\a+\203\377\177\203\377\177",
237
+ encode_object_id(SNMP::ObjectId.new("1.3.65535.65535")))
234
238
  end
235
239
  end
236
240
 
@@ -13,7 +13,7 @@ class EchoTransport
13
13
  end
14
14
 
15
15
  def recv(max_bytes)
16
- Message.decode(@data).response.encode[0,max_bytes]
16
+ SNMP::Message.decode(@data).response.encode[0,max_bytes]
17
17
  end
18
18
  end
19
19
 
@@ -58,6 +58,19 @@ class TestManager < Test::Unit::TestCase
58
58
  assert_equal(ObjectId.new("1.2.3.4.5"), response.varbind_list[1].name)
59
59
  end
60
60
 
61
+ def test_get_value
62
+ value = @manager.get_value("1.2.3.4")
63
+ assert_equal(Null, value)
64
+
65
+ value = @manager.get_value(["1.2.3.4"])
66
+ assert_equal([Null], value)
67
+
68
+ values = @manager.get_value(["1.2.3.4", "1.2.3.4.5"])
69
+ assert_equal(2, values.length)
70
+ assert_equal(Null, values[0])
71
+ assert_equal(Null, values[1])
72
+ end
73
+
61
74
  def test_get_next
62
75
  response = @manager.get_next("1.2.3.4")
63
76
  assert_equal("1.2.3.4", response.varbind_list.first.name.to_s)
@@ -82,8 +95,8 @@ class TestManager < Test::Unit::TestCase
82
95
 
83
96
  def test_get_bulk
84
97
  response = @manager.get_bulk(1, 3, ["1.3.6.1.3.1.1.1.0", "1.3.6.1.3.1.1.2.0"])
85
- assert_equal(:tooBig, response.error_status)
86
- assert_equal(3, response.error_index)
98
+ assert_equal(:noError, response.error_status)
99
+ assert_equal(0, response.error_index)
87
100
  assert_equal(2, response.varbind_list.length)
88
101
  assert_equal("1.3.6.1.3.1.1.1.0", response.varbind_list[0].name.to_s)
89
102
  assert_equal("1.3.6.1.3.1.1.2.0", response.varbind_list[1].name.to_s)
@@ -41,6 +41,10 @@ class TestMib < Test::Unit::TestCase
41
41
  assert_equal(1, vb_list.length)
42
42
  assert_equal("1.2.3.4", vb_list.first.name.to_s)
43
43
 
44
+ vb_list = @mib.varbind_list(["1.2.3.4"])
45
+ assert_equal(1, vb_list.length)
46
+ assert_equal("1.2.3.4", vb_list.first.name.to_s)
47
+
44
48
  vb_list = @mib.varbind_list(["IF-MIB::ifTable.1.23", "1.2.3.4"])
45
49
  assert_equal(2, vb_list.length)
46
50
  assert_equal("1.3.6.1.2.1.2.2.1.23", vb_list.first.name.to_s)
@@ -61,6 +65,11 @@ class TestMib < Test::Unit::TestCase
61
65
  assert_equal(4, list.length)
62
66
  end
63
67
 
68
+ # def test_import
69
+ # module_name = MIB.import_module('SNMPv2-MIB')
70
+ # assert_equal('SNMPv2-MIB', module_name)
71
+ # end
72
+
64
73
  end
65
74
 
66
75
  end
@@ -10,7 +10,7 @@ class TestProtocol < Test::Unit::TestCase
10
10
  assert_equal(:SNMPv1, message.version)
11
11
  assert_equal("public", message.community)
12
12
  assert_equal(SNMP::GetRequest, message.pdu.class)
13
- varbind_list = message.pdu.varbind_list;
13
+ varbind_list = message.pdu.vb_list;
14
14
  assert_equal(1, varbind_list.length)
15
15
  assert_equal([1,3,6,1,2,1,1,1,0], varbind_list.first.name)
16
16
  assert_equal(SNMP::Null, varbind_list.first.value)
@@ -20,7 +20,7 @@ class TestProtocol < Test::Unit::TestCase
20
20
  message = SNMP::Message.decode("0)\002\001\001\004\006public\240\034\002\0040\265\020\202\002\001\000\002\001\0000\0160\f\006\010+\006\001\002\001\001\001\000\005\000")
21
21
  assert_equal(:SNMPv2c, message.version)
22
22
  assert_equal("public", message.community)
23
- varbind_list = message.pdu.varbind_list;
23
+ varbind_list = message.pdu.vb_list;
24
24
  assert_equal(1, varbind_list.length)
25
25
  assert_equal([1,3,6,1,2,1,1,1,0], varbind_list.first.name)
26
26
  assert_equal(SNMP::Null, varbind_list.first.value)
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+
3
+ begin
4
+ require 'smi'
5
+
6
+ class TestSmi < Test::Unit::TestCase
7
+
8
+ include SNMP::SMI
9
+
10
+ def test_load
11
+ name, oid_hash = load_smi_module('test/mibs/IF-MIB')
12
+ assert_equal("IF-MIB", name)
13
+ assert_equal("1.3.6.1.2.1.2.2", oid_hash["ifTable"])
14
+ end
15
+
16
+ end
17
+ rescue LoadError
18
+ # snmp/smi may not always be available because it is a C extention
19
+ end
@@ -40,11 +40,31 @@ class TestWalk < Test::Unit::TestCase
40
40
  $transport_pdu_count = 3
41
41
  list = []
42
42
  manager.walk("ifTable") do |vb|
43
+ assert(vb.kind_of?(VarBind), "Expected a VarBind")
44
+ list << vb
45
+ end
46
+ assert_equal(3, list.length)
47
+
48
+ $transport_pdu_count = 3
49
+ list = []
50
+ manager.walk(ObjectId.new("1.3.4.5")) do |vb|
51
+ assert(vb.kind_of?(VarBind), "Expected a VarBind")
43
52
  list << vb
44
53
  end
45
54
  assert_equal(3, list.length)
46
55
  end
47
56
 
57
+ def test_single_object_list
58
+ $transport_pdu_count = 1
59
+ executed_block = false
60
+ manager.walk(["1.3.6.1"]) do |vb_list|
61
+ executed_block = true
62
+ assert_equal(1, vb_list.length)
63
+ assert_equal("1.3.6.1.1", vb_list.first.name.to_s)
64
+ end
65
+ assert(executed_block, "Did not execute block")
66
+ end
67
+
48
68
  def test_object_list
49
69
  $transport_pdu_count = 3
50
70
  list1 = []
@@ -60,7 +80,7 @@ class TestWalk < Test::Unit::TestCase
60
80
  def test_empty
61
81
  $transport_pdu_count = 0
62
82
  manager.walk("1.2.3.4") do |vb|
63
- fail { "Expected block to not be executed"}
83
+ fail("Expected block to not be executed")
64
84
  end
65
85
  end
66
86
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.3
2
+ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: snmp
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.1
7
- date: 2004-12-20
6
+ version: 0.5.0
7
+ date: 2005-06-15
8
8
  summary: A Ruby implementation of SNMP (the Simple Network Management Protocol).
9
9
  require_paths:
10
10
  - lib
@@ -41,6 +41,7 @@ files:
41
41
  - test/test_manager.rb
42
42
  - test/test_mib.rb
43
43
  - test/test_pdu.rb
44
+ - test/test_smi.rb
44
45
  - test/test_varbind.rb
45
46
  - test/test_walk.rb
46
47
  - examples/dump.rb
@@ -242,11 +243,14 @@ files:
242
243
  - data/ruby/snmp/mibs/VRRP-MIB.yaml
243
244
  - data/ruby/snmp/mibs/WWW-MIB.yaml
244
245
  test_files: []
245
- rdoc_options: []
246
+ rdoc_options:
247
+ - "--main"
248
+ - README
249
+ - "--title"
250
+ - SNMP Library for Ruby
246
251
  extra_rdoc_files:
247
252
  - README
248
253
  executables: []
249
254
  extensions: []
250
- requirements:
251
- - none
255
+ requirements: []
252
256
  dependencies: []