snmp 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. data/README.rdoc +179 -0
  2. data/Rakefile +34 -39
  3. data/data/ruby/snmp/mibs/ACCOUNTING-CONTROL-MIB.yaml +33 -32
  4. data/data/ruby/snmp/mibs/ADSL-LINE-EXT-MIB.yaml +57 -56
  5. data/data/ruby/snmp/mibs/ADSL-LINE-MIB.yaml +224 -223
  6. data/data/ruby/snmp/mibs/ADSL-TC-MIB.yaml +1 -0
  7. data/data/ruby/snmp/mibs/ADSL2-LINE-MIB.yaml +321 -0
  8. data/data/ruby/snmp/mibs/ADSL2-LINE-TC-MIB.yaml +3 -0
  9. data/data/ruby/snmp/mibs/AGENTX-MIB.yaml +25 -24
  10. data/data/ruby/snmp/mibs/AGGREGATE-MIB.yaml +28 -0
  11. data/data/ruby/snmp/mibs/ALARM-MIB.yaml +77 -0
  12. data/data/ruby/snmp/mibs/APM-MIB.yaml +75 -74
  13. data/data/ruby/snmp/mibs/APPC-MIB.yaml +261 -260
  14. data/data/ruby/snmp/mibs/APPLETALK-MIB.yaml +255 -254
  15. data/data/ruby/snmp/mibs/APPLICATION-MIB.yaml +138 -137
  16. data/data/ruby/snmp/mibs/APPN-DLUR-MIB.yaml +30 -29
  17. data/data/ruby/snmp/mibs/APPN-MIB.yaml +325 -324
  18. data/data/ruby/snmp/mibs/APPN-TRAP-MIB.yaml +10 -9
  19. data/data/ruby/snmp/mibs/APS-MIB.yaml +50 -49
  20. data/data/ruby/snmp/mibs/ARC-MIB.yaml +19 -0
  21. data/data/ruby/snmp/mibs/ATM-ACCOUNTING-INFORMATION-MIB.yaml +22 -21
  22. data/data/ruby/snmp/mibs/ATM-MIB.yaml +94 -93
  23. data/data/ruby/snmp/mibs/ATM-TC-MIB.yaml +12 -11
  24. data/data/ruby/snmp/mibs/ATM2-MIB.yaml +156 -155
  25. data/data/ruby/snmp/mibs/BGP4-MIB.yaml +48 -41
  26. data/data/ruby/snmp/mibs/BLDG-HVAC-MIB.yaml +25 -24
  27. data/data/ruby/snmp/mibs/BRIDGE-MIB.yaml +50 -44
  28. data/data/ruby/snmp/mibs/CHARACTER-MIB.yaml +35 -34
  29. data/data/ruby/snmp/mibs/CIRCUIT-IF-MIB.yaml +13 -12
  30. data/data/ruby/snmp/mibs/CLNS-MIB.yaml +98 -97
  31. data/data/ruby/snmp/mibs/COFFEE-POT-MIB.yaml +8 -7
  32. data/data/ruby/snmp/mibs/COPS-CLIENT-MIB.yaml +38 -37
  33. data/data/ruby/snmp/mibs/DECNET-PHIV-MIB.yaml +209 -208
  34. data/data/ruby/snmp/mibs/DIAL-CONTROL-MIB.yaml +72 -71
  35. data/data/ruby/snmp/mibs/DIFFSERV-CONFIG-MIB.yaml +11 -10
  36. data/data/ruby/snmp/mibs/DIFFSERV-DSCP-TC.yaml +1 -0
  37. data/data/ruby/snmp/mibs/DIFFSERV-MIB.yaml +151 -150
  38. data/data/ruby/snmp/mibs/DIRECTORY-SERVER-MIB.yaml +35 -34
  39. data/data/ruby/snmp/mibs/DISMAN-EVENT-MIB.yaml +95 -94
  40. data/data/ruby/snmp/mibs/DISMAN-EXPRESSION-MIB.yaml +37 -36
  41. data/data/ruby/snmp/mibs/DISMAN-NSLOOKUP-MIB.yaml +15 -14
  42. data/data/ruby/snmp/mibs/DISMAN-PING-MIB.yaml +43 -42
  43. data/data/ruby/snmp/mibs/DISMAN-SCHEDULE-MIB.yaml +22 -21
  44. data/data/ruby/snmp/mibs/DISMAN-SCRIPT-MIB.yaml +64 -63
  45. data/data/ruby/snmp/mibs/DISMAN-TRACEROUTE-MIB.yaml +59 -58
  46. data/data/ruby/snmp/mibs/DLSW-MIB.yaml +172 -171
  47. data/data/ruby/snmp/mibs/DNS-RESOLVER-MIB.yaml +70 -69
  48. data/data/ruby/snmp/mibs/DNS-SERVER-MIB.yaml +57 -56
  49. data/data/ruby/snmp/mibs/DOCS-BPI-MIB.yaml +81 -80
  50. data/data/ruby/snmp/mibs/DOCS-CABLE-DEVICE-MIB.yaml +114 -89
  51. data/data/ruby/snmp/mibs/DOCS-IETF-BPI2-MIB.yaml +187 -0
  52. data/data/ruby/snmp/mibs/DOCS-IETF-CABLE-DEVICE-NOTIFICATION-MIB.yaml +39 -0
  53. data/data/ruby/snmp/mibs/DOCS-IETF-QOS-MIB.yaml +166 -0
  54. data/data/ruby/snmp/mibs/DOCS-IETF-SUBMGT-MIB.yaml +32 -0
  55. data/data/ruby/snmp/mibs/DOCS-IF-MIB.yaml +208 -119
  56. data/data/ruby/snmp/mibs/DOT12-IF-MIB.yaml +21 -20
  57. data/data/ruby/snmp/mibs/DOT3-EPON-MIB.yaml +101 -0
  58. data/data/ruby/snmp/mibs/DOT3-OAM-MIB.yaml +82 -0
  59. data/data/ruby/snmp/mibs/DS0-MIB.yaml +11 -10
  60. data/data/ruby/snmp/mibs/DS0BUNDLE-MIB.yaml +9 -8
  61. data/data/ruby/snmp/mibs/DS1-MIB.yaml +102 -98
  62. data/data/ruby/snmp/mibs/DS3-MIB.yaml +84 -83
  63. data/data/ruby/snmp/mibs/DSA-MIB.yaml +31 -30
  64. data/data/ruby/snmp/mibs/DSMON-MIB.yaml +193 -192
  65. data/data/ruby/snmp/mibs/EBN-MIB.yaml +32 -31
  66. data/data/ruby/snmp/mibs/EFM-CU-MIB.yaml +113 -0
  67. data/data/ruby/snmp/mibs/ENTITY-MIB.yaml +41 -38
  68. data/data/ruby/snmp/mibs/ENTITY-SENSOR-MIB.yaml +8 -7
  69. data/data/ruby/snmp/mibs/ENTITY-STATE-MIB.yaml +18 -0
  70. data/data/ruby/snmp/mibs/ENTITY-STATE-TC-MIB.yaml +3 -0
  71. data/data/ruby/snmp/mibs/ETHER-CHIPSET-MIB.yaml +61 -60
  72. data/data/ruby/snmp/mibs/ETHER-WIS.yaml +16 -15
  73. data/data/ruby/snmp/mibs/EtherLike-MIB.yaml +43 -42
  74. data/data/ruby/snmp/mibs/FC-MGMT-MIB.yaml +154 -0
  75. data/data/ruby/snmp/mibs/FCIP-MGMT-MIB.yaml +68 -0
  76. data/data/ruby/snmp/mibs/FDDI-SMT73-MIB.yaml +107 -106
  77. data/data/ruby/snmp/mibs/FIBRE-CHANNEL-FE-MIB.yaml +100 -99
  78. data/data/ruby/snmp/mibs/FLOW-METER-MIB.yaml +92 -91
  79. data/data/ruby/snmp/mibs/FR-ATM-PVC-SERVICE-IWF-MIB.yaml +33 -32
  80. data/data/ruby/snmp/mibs/FR-MFR-MIB.yaml +38 -37
  81. data/data/ruby/snmp/mibs/FRAME-RELAY-DTE-MIB.yaml +41 -40
  82. data/data/ruby/snmp/mibs/FRNETSERV-MIB.yaml +92 -91
  83. data/data/ruby/snmp/mibs/FRSLD-MIB.yaml +66 -65
  84. data/data/ruby/snmp/mibs/Finisher-MIB.yaml +38 -37
  85. data/data/ruby/snmp/mibs/GMPLS-LABEL-STD-MIB.yaml +27 -0
  86. data/data/ruby/snmp/mibs/GMPLS-LSR-STD-MIB.yaml +20 -0
  87. data/data/ruby/snmp/mibs/GMPLS-TC-STD-MIB.yaml +3 -0
  88. data/data/ruby/snmp/mibs/GMPLS-TE-STD-MIB.yaml +72 -0
  89. data/data/ruby/snmp/mibs/GSMP-MIB.yaml +75 -74
  90. data/data/ruby/snmp/mibs/HC-ALARM-MIB.yaml +26 -25
  91. data/data/ruby/snmp/mibs/HC-PerfHist-TC-MIB.yaml +1 -0
  92. data/data/ruby/snmp/mibs/HC-RMON-MIB.yaml +164 -163
  93. data/data/ruby/snmp/mibs/HCNUM-TC.yaml +1 -0
  94. data/data/ruby/snmp/mibs/HDSL2-SHDSL-LINE-MIB.yaml +117 -112
  95. data/data/ruby/snmp/mibs/HOST-RESOURCES-MIB.yaml +82 -81
  96. data/data/ruby/snmp/mibs/HOST-RESOURCES-TYPES.yaml +40 -39
  97. data/data/ruby/snmp/mibs/HPR-IP-MIB.yaml +17 -16
  98. data/data/ruby/snmp/mibs/HPR-MIB.yaml +64 -63
  99. data/data/ruby/snmp/mibs/IANA-ITU-ALARM-TC-MIB.yaml +3 -0
  100. data/data/ruby/snmp/mibs/IF-CAP-STACK-MIB.yaml +13 -0
  101. data/data/ruby/snmp/mibs/IF-INVERTED-STACK-MIB.yaml +6 -5
  102. data/data/ruby/snmp/mibs/IF-MIB.yaml +57 -56
  103. data/data/ruby/snmp/mibs/IFCP-MGMT-MIB.yaml +65 -0
  104. data/data/ruby/snmp/mibs/IGMP-STD-MIB.yaml +24 -23
  105. data/data/ruby/snmp/mibs/INET-ADDRESS-MIB.yaml +1 -0
  106. data/data/ruby/snmp/mibs/INTEGRATED-SERVICES-GUARANTEED-MIB.yaml +6 -5
  107. data/data/ruby/snmp/mibs/INTEGRATED-SERVICES-MIB.yaml +29 -28
  108. data/data/ruby/snmp/mibs/INTERFACETOPN-MIB.yaml +21 -20
  109. data/data/ruby/snmp/mibs/IP-FORWARD-MIB.yaml +49 -27
  110. data/data/ruby/snmp/mibs/IP-MIB.yaml +243 -40
  111. data/data/ruby/snmp/mibs/IPATM-IPMC-MIB.yaml +179 -178
  112. data/data/ruby/snmp/mibs/IPMCAST-MIB.yaml +105 -0
  113. data/data/ruby/snmp/mibs/IPMROUTE-STD-MIB.yaml +49 -48
  114. data/data/ruby/snmp/mibs/IPOA-MIB.yaml +74 -73
  115. data/data/ruby/snmp/mibs/IPS-AUTH-MIB.yaml +68 -0
  116. data/data/ruby/snmp/mibs/IPSEC-SPD-MIB.yaml +121 -0
  117. data/data/ruby/snmp/mibs/IPV6-FLOW-LABEL-MIB.yaml +1 -0
  118. data/data/ruby/snmp/mibs/IPV6-ICMP-MIB.yaml +27 -26
  119. data/data/ruby/snmp/mibs/IPV6-MIB.yaml +70 -69
  120. data/data/ruby/snmp/mibs/IPV6-MLD-MIB.yaml +18 -17
  121. data/data/ruby/snmp/mibs/IPV6-TCP-MIB.yaml +7 -6
  122. data/data/ruby/snmp/mibs/IPV6-UDP-MIB.yaml +6 -5
  123. data/data/ruby/snmp/mibs/ISCSI-MIB.yaml +199 -0
  124. data/data/ruby/snmp/mibs/ISDN-MIB.yaml +57 -56
  125. data/data/ruby/snmp/mibs/ISIS-MIB.yaml +247 -0
  126. data/data/ruby/snmp/mibs/ISNS-MIB.yaml +179 -0
  127. data/data/ruby/snmp/mibs/ITU-ALARM-MIB.yaml +34 -0
  128. data/data/ruby/snmp/mibs/ITU-ALARM-TC-MIB.yaml +3 -0
  129. data/data/ruby/snmp/mibs/Job-Monitoring-MIB.yaml +26 -27
  130. data/data/ruby/snmp/mibs/L2TP-MIB.yaml +138 -137
  131. data/data/ruby/snmp/mibs/LANGTAG-TC-MIB.yaml +3 -0
  132. data/data/ruby/snmp/mibs/LMP-MIB.yaml +202 -0
  133. data/data/ruby/snmp/mibs/MALLOC-MIB.yaml +66 -65
  134. data/data/ruby/snmp/mibs/MAU-MIB.yaml +55 -95
  135. data/data/ruby/snmp/mibs/MIDCOM-MIB.yaml +83 -0
  136. data/data/ruby/snmp/mibs/MIOX25-MIB.yaml +28 -27
  137. data/data/ruby/snmp/mibs/MIP-MIB.yaml +157 -156
  138. data/data/ruby/snmp/mibs/MOBILEIPV6-MIB.yaml +189 -0
  139. data/data/ruby/snmp/mibs/MPLS-FTN-STD-MIB.yaml +29 -28
  140. data/data/ruby/snmp/mibs/MPLS-L3VPN-STD-MIB.yaml +88 -0
  141. data/data/ruby/snmp/mibs/MPLS-LC-ATM-STD-MIB.yaml +19 -0
  142. data/data/ruby/snmp/mibs/MPLS-LC-FR-STD-MIB.yaml +16 -0
  143. data/data/ruby/snmp/mibs/MPLS-LDP-ATM-STD-MIB.yaml +23 -22
  144. data/data/ruby/snmp/mibs/MPLS-LDP-FRAME-RELAY-STD-MIB.yaml +17 -16
  145. data/data/ruby/snmp/mibs/MPLS-LDP-GENERIC-STD-MIB.yaml +9 -8
  146. data/data/ruby/snmp/mibs/MPLS-LDP-STD-MIB.yaml +103 -102
  147. data/data/ruby/snmp/mibs/MPLS-LSR-STD-MIB.yaml +85 -84
  148. data/data/ruby/snmp/mibs/MPLS-TC-STD-MIB.yaml +1 -0
  149. data/data/ruby/snmp/mibs/MPLS-TE-STD-MIB.yaml +106 -105
  150. data/data/ruby/snmp/mibs/MSDP-MIB.yaml +71 -0
  151. data/data/ruby/snmp/mibs/MTA-MIB.yaml +42 -41
  152. data/data/ruby/snmp/mibs/Modem-MIB.yaml +87 -86
  153. data/data/ruby/snmp/mibs/NAT-MIB.yaml +116 -0
  154. data/data/ruby/snmp/mibs/NETWORK-SERVICES-MIB.yaml +18 -17
  155. data/data/ruby/snmp/mibs/NHRP-MIB.yaml +140 -139
  156. data/data/ruby/snmp/mibs/NOTIFICATION-LOG-MIB.yaml +37 -36
  157. data/data/ruby/snmp/mibs/OPT-IF-MIB.yaml +394 -393
  158. data/data/ruby/snmp/mibs/OSPF-MIB.yaml +192 -123
  159. data/data/ruby/snmp/mibs/OSPF-TRAP-MIB.yaml +24 -19
  160. data/data/ruby/snmp/mibs/P-BRIDGE-MIB.yaml +37 -35
  161. data/data/ruby/snmp/mibs/PARALLEL-MIB.yaml +16 -15
  162. data/data/ruby/snmp/mibs/PIM-MIB.yaml +47 -46
  163. data/data/ruby/snmp/mibs/PIM-STD-MIB.yaml +235 -0
  164. data/data/ruby/snmp/mibs/PINT-MIB.yaml +38 -37
  165. data/data/ruby/snmp/mibs/PKTC-IETF-MTA-MIB.yaml +81 -0
  166. data/data/ruby/snmp/mibs/PKTC-IETF-SIG-MIB.yaml +128 -0
  167. data/data/ruby/snmp/mibs/POLICY-BASED-MANAGEMENT-MIB.yaml +94 -0
  168. data/data/ruby/snmp/mibs/POWER-ETHERNET-MIB.yaml +27 -26
  169. data/data/ruby/snmp/mibs/PPP-BRIDGE-NCP-MIB.yaml +16 -15
  170. data/data/ruby/snmp/mibs/PPP-IP-NCP-MIB.yaml +7 -6
  171. data/data/ruby/snmp/mibs/PPP-LCP-MIB.yaml +33 -32
  172. data/data/ruby/snmp/mibs/PPP-SEC-MIB.yaml +13 -12
  173. data/data/ruby/snmp/mibs/PTOPO-MIB.yaml +29 -28
  174. data/data/ruby/snmp/mibs/PerfHist-TC-MIB.yaml +1 -0
  175. data/data/ruby/snmp/mibs/Printer-MIB.yaml +185 -184
  176. data/data/ruby/snmp/mibs/Q-BRIDGE-MIB.yaml +96 -82
  177. data/data/ruby/snmp/mibs/RADIUS-ACC-CLIENT-MIB.yaml +34 -16
  178. data/data/ruby/snmp/mibs/RADIUS-ACC-SERVER-MIB.yaml +40 -24
  179. data/data/ruby/snmp/mibs/RADIUS-AUTH-CLIENT-MIB.yaml +38 -18
  180. data/data/ruby/snmp/mibs/RADIUS-AUTH-SERVER-MIB.yaml +40 -23
  181. data/data/ruby/snmp/mibs/RADIUS-DYNAUTH-CLIENT-MIB.yaml +44 -0
  182. data/data/ruby/snmp/mibs/RADIUS-DYNAUTH-SERVER-MIB.yaml +40 -0
  183. data/data/ruby/snmp/mibs/RAQMON-MIB.yaml +90 -0
  184. data/data/ruby/snmp/mibs/RDBMS-MIB.yaml +69 -68
  185. data/data/ruby/snmp/mibs/RFC1065-SMI.yaml +4 -5
  186. data/data/ruby/snmp/mibs/RFC1155-SMI.yaml +4 -5
  187. data/data/ruby/snmp/mibs/RFC1158-MIB.yaml +174 -173
  188. data/data/ruby/snmp/mibs/RFC1213-MIB.yaml +173 -172
  189. data/data/ruby/snmp/mibs/RFC1269-MIB.yaml +20 -19
  190. data/data/ruby/snmp/mibs/RFC1271-MIB.yaml +185 -184
  191. data/data/ruby/snmp/mibs/RFC1285-MIB.yaml +85 -84
  192. data/data/ruby/snmp/mibs/RFC1316-MIB.yaml +30 -29
  193. data/data/ruby/snmp/mibs/RFC1381-MIB.yaml +40 -39
  194. data/data/ruby/snmp/mibs/RFC1382-MIB.yaml +149 -148
  195. data/data/ruby/snmp/mibs/RFC1414-MIB.yaml +4 -3
  196. data/data/ruby/snmp/mibs/RIPv2-MIB.yaml +25 -24
  197. data/data/ruby/snmp/mibs/RMON-MIB.yaml +192 -191
  198. data/data/ruby/snmp/mibs/RMON2-MIB.yaml +253 -252
  199. data/data/ruby/snmp/mibs/ROHC-MIB.yaml +49 -48
  200. data/data/ruby/snmp/mibs/ROHC-RTP-MIB.yaml +19 -18
  201. data/data/ruby/snmp/mibs/ROHC-UNCOMPRESSED-MIB.yaml +6 -5
  202. data/data/ruby/snmp/mibs/RS-232-MIB.yaml +36 -35
  203. data/data/ruby/snmp/mibs/RSTP-MIB.yaml +18 -0
  204. data/data/ruby/snmp/mibs/RSVP-MIB.yaml +137 -136
  205. data/data/ruby/snmp/mibs/RTP-MIB.yaml +42 -41
  206. data/data/ruby/snmp/mibs/SCSI-MIB.yaml +160 -0
  207. data/data/ruby/snmp/mibs/SCTP-MIB.yaml +83 -0
  208. data/data/ruby/snmp/mibs/SFLOW-MIB.yaml +15 -14
  209. data/data/ruby/snmp/mibs/SIP-COMMON-MIB.yaml +112 -0
  210. data/data/ruby/snmp/mibs/SIP-MIB.yaml +56 -55
  211. data/data/ruby/snmp/mibs/SIP-SERVER-MIB.yaml +52 -0
  212. data/data/ruby/snmp/mibs/SIP-TC-MIB.yaml +3 -0
  213. data/data/ruby/snmp/mibs/SIP-UA-MIB.yaml +14 -0
  214. data/data/ruby/snmp/mibs/SLAPM-MIB.yaml +134 -133
  215. data/data/ruby/snmp/mibs/SMON-MIB.yaml +47 -46
  216. data/data/ruby/snmp/mibs/SNA-NAU-MIB.yaml +117 -116
  217. data/data/ruby/snmp/mibs/SNA-SDLC-MIB.yaml +126 -125
  218. data/data/ruby/snmp/mibs/SNMP-COMMUNITY-MIB.yaml +12 -11
  219. data/data/ruby/snmp/mibs/SNMP-FRAMEWORK-MIB.yaml +8 -7
  220. data/data/ruby/snmp/mibs/SNMP-MPD-MIB.yaml +6 -5
  221. data/data/ruby/snmp/mibs/SNMP-NOTIFICATION-MIB.yaml +16 -15
  222. data/data/ruby/snmp/mibs/SNMP-PROXY-MIB.yaml +10 -9
  223. data/data/ruby/snmp/mibs/SNMP-REPEATER-MIB.yaml +120 -119
  224. data/data/ruby/snmp/mibs/SNMP-TARGET-MIB.yaml +19 -18
  225. data/data/ruby/snmp/mibs/SNMP-USER-BASED-SM-MIB.yaml +26 -25
  226. data/data/ruby/snmp/mibs/SNMP-USM-AES-MIB.yaml +4 -0
  227. data/data/ruby/snmp/mibs/SNMP-USM-DH-OBJECTS-MIB.yaml +10 -9
  228. data/data/ruby/snmp/mibs/SNMP-VIEW-BASED-ACM-MIB.yaml +26 -25
  229. data/data/ruby/snmp/mibs/SNMPv2-MIB.yaml +46 -45
  230. data/data/ruby/snmp/mibs/SNMPv2-SMI.yaml +12 -11
  231. data/data/ruby/snmp/mibs/SNMPv2-TM.yaml +5 -4
  232. data/data/ruby/snmp/mibs/SNMPv2-USEC-MIB.yaml +10 -9
  233. data/data/ruby/snmp/mibs/SONET-MIB.yaml +110 -109
  234. data/data/ruby/snmp/mibs/SOURCE-ROUTING-MIB.yaml +18 -17
  235. data/data/ruby/snmp/mibs/SSPM-MIB.yaml +67 -0
  236. data/data/ruby/snmp/mibs/SYSAPPL-MIB.yaml +65 -64
  237. data/data/ruby/snmp/mibs/T11-FC-FABRIC-ADDR-MGR-MIB.yaml +63 -0
  238. data/data/ruby/snmp/mibs/T11-FC-FABRIC-CONFIG-SERVER-MIB.yaml +100 -0
  239. data/data/ruby/snmp/mibs/T11-FC-FABRIC-LOCK-MIB.yaml +22 -0
  240. data/data/ruby/snmp/mibs/T11-FC-FSPF-MIB.yaml +70 -0
  241. data/data/ruby/snmp/mibs/T11-FC-NAME-SERVER-MIB.yaml +56 -0
  242. data/data/ruby/snmp/mibs/T11-FC-ROUTE-MIB.yaml +27 -0
  243. data/data/ruby/snmp/mibs/T11-FC-RSCN-MIB.yaml +47 -0
  244. data/data/ruby/snmp/mibs/T11-FC-VIRTUAL-FABRIC-MIB.yaml +31 -0
  245. data/data/ruby/snmp/mibs/T11-FC-ZONE-SERVER-MIB.yaml +124 -0
  246. data/data/ruby/snmp/mibs/T11-TC-MIB.yaml +3 -0
  247. data/data/ruby/snmp/mibs/TCP-ESTATS-MIB.yaml +167 -0
  248. data/data/ruby/snmp/mibs/TCP-MIB.yaml +37 -18
  249. data/data/ruby/snmp/mibs/TCPIPX-MIB.yaml +16 -15
  250. data/data/ruby/snmp/mibs/TE-LINK-STD-MIB.yaml +82 -0
  251. data/data/ruby/snmp/mibs/TE-MIB.yaml +81 -0
  252. data/data/ruby/snmp/mibs/TIME-AGGREGATE-MIB.yaml +22 -0
  253. data/data/ruby/snmp/mibs/TN3270E-MIB.yaml +85 -84
  254. data/data/ruby/snmp/mibs/TN3270E-RT-MIB.yaml +33 -32
  255. data/data/ruby/snmp/mibs/TOKEN-RING-RMON-MIB.yaml +159 -158
  256. data/data/ruby/snmp/mibs/TOKENRING-MIB.yaml +42 -41
  257. data/data/ruby/snmp/mibs/TOKENRING-STATION-SR-MIB.yaml +8 -7
  258. data/data/ruby/snmp/mibs/TRANSPORT-ADDRESS-MIB.yaml +13 -12
  259. data/data/ruby/snmp/mibs/TRIP-MIB.yaml +118 -0
  260. data/data/ruby/snmp/mibs/TRIP-TC-MIB.yaml +3 -0
  261. data/data/ruby/snmp/mibs/TUNNEL-MIB.yaml +29 -13
  262. data/data/ruby/snmp/mibs/UDP-MIB.yaml +19 -6
  263. data/data/ruby/snmp/mibs/UDPLITE-MIB.yaml +26 -0
  264. data/data/ruby/snmp/mibs/UPS-MIB.yaml +100 -99
  265. data/data/ruby/snmp/mibs/URI-TC-MIB.yaml +3 -0
  266. data/data/ruby/snmp/mibs/VDSL-LINE-EXT-MCM-MIB.yaml +42 -0
  267. data/data/ruby/snmp/mibs/VDSL-LINE-EXT-SCM-MIB.yaml +27 -0
  268. data/data/ruby/snmp/mibs/VDSL-LINE-MIB.yaml +162 -161
  269. data/data/ruby/snmp/mibs/VPN-TC-STD-MIB.yaml +3 -0
  270. data/data/ruby/snmp/mibs/VRRP-MIB.yaml +39 -38
  271. data/data/ruby/snmp/mibs/WWW-MIB.yaml +75 -74
  272. data/examples/dump.rb +5 -5
  273. data/examples/iftable.rb +4 -4
  274. data/examples/link_down.rb +18 -18
  275. data/examples/log_traps.rb +9 -9
  276. data/examples/walk.rb +4 -4
  277. data/lib/snmp/agent.rb +42 -43
  278. data/lib/snmp/ber.rb +155 -156
  279. data/lib/snmp/manager.rb +412 -372
  280. data/lib/snmp/mib.rb +172 -182
  281. data/lib/snmp/options.rb +64 -0
  282. data/lib/snmp/pdu.rb +245 -245
  283. data/lib/snmp/varbind.rb +346 -341
  284. data/lib/snmp/version.rb +3 -0
  285. data/test/test_ber.rb +232 -233
  286. data/test/test_manager.rb +277 -238
  287. data/test/test_mib.rb +57 -57
  288. data/test/test_pdu.rb +172 -172
  289. data/test/test_retry.rb +54 -54
  290. data/test/test_smi.rb +10 -10
  291. data/test/test_varbind.rb +342 -331
  292. data/test/test_walk.rb +150 -150
  293. metadata +103 -45
  294. data/README +0 -252
  295. data/setup.rb +0 -1360
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2004 David R. Halliday
2
+ # Copyright (c) 2004-2010 David R. Halliday
3
3
  # All rights reserved.
4
4
  #
5
5
  # This SNMP library is free software. Redistribution is permitted under the
@@ -9,191 +9,216 @@
9
9
 
10
10
  require 'snmp/pdu'
11
11
  require 'snmp/mib'
12
+ require 'snmp/options'
12
13
  require 'socket'
13
14
  require 'timeout'
14
15
  require 'thread'
15
16
 
16
17
  module SNMP
17
18
 
18
- class RequestTimeout < RuntimeError; end
19
+ class RequestTimeout < RuntimeError; end
19
20
 
20
- ##
21
- # Wrap socket so that it can be easily substituted for testing or for
22
- # using other transport types (e.g. TCP)
23
- #
24
- class UDPTransport
25
- def initialize
26
- @socket = UDPSocket.open
21
+ ##
22
+ # Wrap socket so that it can be easily substituted for testing or for
23
+ # using other transport types (e.g. TCP)
24
+ #
25
+ class UDPTransport
26
+ def initialize(address_family)
27
+ @socket = UDPSocket.open(address_family)
27
28
  end
28
29
 
29
30
  def close
30
- @socket.close
31
+ @socket.close
31
32
  end
32
33
 
33
34
  def send(data, host, port)
34
- @socket.send(data, 0, host, port)
35
+ @socket.send(data, 0, host, port)
35
36
  end
36
37
 
37
38
  def recv(max_bytes)
38
- @socket.recv(max_bytes)
39
+ @socket.recv(max_bytes)
39
40
  end
40
- end
41
+ end
41
42
 
42
- ##
43
- # Manage a request-id in the range 1..2**31-1
44
- #
45
- class RequestId
43
+ ##
44
+ # Manage a request-id in the range 1..2**31-1
45
+ #
46
+ class RequestId
46
47
  MAX_REQUEST_ID = 2**31
47
-
48
+
48
49
  def initialize
49
- @lock = Mutex.new
50
- @request_id = rand(MAX_REQUEST_ID)
50
+ @lock = Mutex.new
51
+ @request_id = rand(MAX_REQUEST_ID)
51
52
  end
52
53
 
53
54
  def next
54
- @lock.synchronize do
55
- @request_id += 1
56
- @request_id = 1 if @request_id == MAX_REQUEST_ID
57
- return @request_id
58
- end
55
+ @lock.synchronize do
56
+ @request_id += 1
57
+ @request_id = 1 if @request_id == MAX_REQUEST_ID
58
+ return @request_id
59
+ end
59
60
  end
60
-
61
+
61
62
  def force_next(next_id)
62
- new_request_id = next_id.to_i
63
- if new_request_id < 1 || new_request_id >= MAX_REQUEST_ID
64
- raise "Invalid request id: #{new_request_id}"
65
- end
66
- new_request_id = MAX_REQUEST_ID if new_request_id == 1
67
- @lock.synchronize do
68
- @request_id = new_request_id - 1
69
- end
70
- end
71
- end
72
-
73
- ##
74
- # == SNMP Manager
75
- #
76
- # This class provides a manager for interacting with a single SNMP agent.
77
- #
78
- # = Example
79
- #
80
- # require 'snmp'
81
- #
82
- # manager = SNMP::Manager.new(:Host => 'localhost', :Port => 1061)
83
- # response = manager.get(["1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.2.0"])
84
- # response.each_varbind {|vb| puts vb.inspect}
85
- # manager.close
86
- #
87
- # == Symbolic Object Names
88
- #
89
- # Symbolic names for SNMP object IDs can be used as parameters to the
90
- # APIs in this class if the MIB modules are imported and the names of the
91
- # MIBs are included in the MibModules configuration parameter.
92
- #
93
- # See MIB.varbind_list for a description of valid parameter formats.
94
- #
95
- # The following modules are loaded by default: "SNMPv2-SMI", "SNMPv2-MIB",
96
- # "IF-MIB", "IP-MIB", "TCP-MIB", "UDP-MIB". All of the current IETF MIBs
97
- # have been imported and are available for loading.
98
- #
99
- # Additional modules may be imported using the MIB class. The
100
- # current implementation of the importing code requires that the
101
- # external 'smidump' tool is available in your PATH. This tool can be
102
- # obtained from the libsmi website at
103
- # http://www.ibr.cs.tu-bs.de/projects/libsmi/ .
104
- #
105
- # = Example
106
- #
107
- # Do this once:
108
- #
109
- # SNMP::MIB.import_module(MY_MODULE_FILENAME, MIB_OUTPUT_DIR)
110
- #
111
- # Include your module in MibModules each time you create a Manager:
112
- #
113
- # SNMP::Manager.new(:Host => 'localhost', :MibDir => MIB_OUTPUT_DIR,
114
- # :MibModules => ["MY-MODULE-MIB", "SNMPv2-MIB", ...])
115
- #
63
+ new_request_id = next_id.to_i
64
+ if new_request_id < 1 || new_request_id >= MAX_REQUEST_ID
65
+ raise "Invalid request id: #{new_request_id}"
66
+ end
67
+ new_request_id = MAX_REQUEST_ID if new_request_id == 1
68
+ @lock.synchronize do
69
+ @request_id = new_request_id - 1
70
+ end
71
+ end
72
+ end
116
73
 
117
- class Manager
118
74
 
119
- ##
120
- # Default configuration. Individual options may be overridden when
121
- # the Manager is created.
122
- #
123
- DefaultConfig = {
124
- :Host => 'localhost',
125
- :Port => 161,
126
- :TrapPort => 162,
127
- :Community => 'public',
128
- :WriteCommunity => nil,
129
- :Version => :SNMPv2c,
130
- :Timeout => 1,
131
- :Retries => 5,
132
- :Transport => UDPTransport,
133
- :MaxReceiveBytes => 8000,
134
- :MibDir => MIB::DEFAULT_MIB_PATH,
135
- :MibModules => ["SNMPv2-SMI", "SNMPv2-MIB", "IF-MIB", "IP-MIB", "TCP-MIB", "UDP-MIB"]}
75
+ ##
76
+ # This class provides a manager for interacting with a single SNMP agent.
77
+ #
78
+ # == Example
79
+ #
80
+ # require 'snmp'
81
+ #
82
+ # manager = SNMP::Manager.new(:host => 'localhost', :port => 1061)
83
+ # response = manager.get(["1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.2.0"])
84
+ # response.each_varbind {|vb| puts vb.inspect}
85
+ # manager.close
86
+ #
87
+ # == Symbolic Object Names
88
+ #
89
+ # Symbolic names for SNMP object IDs can be used as parameters to the
90
+ # APIs in this class if the MIB modules are imported and the names of the
91
+ # MIBs are included in the MibModules configuration parameter.
92
+ #
93
+ # See MIB.varbind_list for a description of valid parameter formats.
94
+ #
95
+ # The following modules are loaded by default: "SNMPv2-SMI", "SNMPv2-MIB",
96
+ # "IF-MIB", "IP-MIB", "TCP-MIB", "UDP-MIB". All of the current IETF MIBs
97
+ # have been imported and are available for loading.
98
+ #
99
+ # Additional modules may be imported using the MIB class. The
100
+ # current implementation of the importing code requires that the
101
+ # external 'smidump' tool is available in your PATH. This tool can be
102
+ # obtained from the libsmi website at
103
+ # http://www.ibr.cs.tu-bs.de/projects/libsmi/ .
104
+ #
105
+ # == Example
106
+ #
107
+ # Do this once:
108
+ #
109
+ # SNMP::MIB.import_module(MY_MODULE_FILENAME, MIB_OUTPUT_DIR)
110
+ #
111
+ # Include your module in MibModules each time you create a Manager:
112
+ #
113
+ # SNMP::Manager.new(:host => 'localhost', :mib_dir => MIB_OUTPUT_DIR,
114
+ # :mib_modules => ["MY-MODULE-MIB", "SNMPv2-MIB", ...])
115
+ #
116
+
117
+ class Manager
118
+
119
+ class Config < Options
120
+ option :host, :Host, 'localhost'
121
+ option :port, :Port, 161
122
+ option :trap_port, :TrapPort, 162
123
+ option :community, :Community, 'public'
124
+ option :write_community, :WriteCommunity, lambda { |c| c.community }
125
+ option :version, :Version, :SNMPv2c
126
+ option :timeout, :Timeout, 1
127
+ option :retries, :Retries, 5
128
+ option :transport, :Transport, UDPTransport
129
+ option :max_recv_bytes, :MaxReceiveBytes, 8000
130
+ option :mib_dir, :MibDir, MIB::DEFAULT_MIB_PATH
131
+ option :mib_modules, :MibModules, default_modules
132
+ option :use_IPv6, :use_IPv6, lambda { |c| ipv6_address?(c) }
133
+
134
+ def create_transport
135
+ transport.respond_to?(:new) ? transport.new(socket_address_family) : transport
136
+ end
137
+ end
136
138
 
137
139
  @@request_id = RequestId.new
138
-
140
+
139
141
  ##
140
142
  # Retrieves the current configuration of this Manager.
141
143
  #
142
144
  attr_reader :config
143
-
145
+
144
146
  ##
145
147
  # Retrieves the MIB for this Manager.
146
148
  #
147
149
  attr_reader :mib
148
-
149
- def initialize(config = {})
150
- if block_given?
151
- warn "SNMP::Manager::new() does not take block; use SNMP::Manager::open() instead"
152
- end
153
- @config = DefaultConfig.merge(config)
154
- @config[:WriteCommunity] = @config[:WriteCommunity] || @config[:Community]
155
- @host = @config[:Host]
156
- @port = @config[:Port]
157
- @trap_port = @config[:TrapPort]
158
- @community = @config[:Community]
159
- @write_community = @config[:WriteCommunity]
160
- @snmp_version = @config[:Version]
161
- @timeout = @config[:Timeout]
162
- @retries = @config[:Retries]
163
- transport = @config[:Transport]
164
- @transport = transport.respond_to?(:new) ? transport.new : transport
165
- @max_bytes = @config[:MaxReceiveBytes]
166
- @mib = MIB.new
167
- load_modules(@config[:MibModules], @config[:MibDir])
168
- end
169
-
150
+
151
+ ##
152
+ # Creates a Manager. The following are valid options and their default values.
153
+ #
154
+ # <b>Note: The upper-case options supported in previous versions of this library are
155
+ # deprecated, but still supported for now. Use at your own risk.</b>
156
+ #
157
+ # Option Default Value
158
+ # --------------------------------------
159
+ # :host 'localhost'
160
+ # :port 161
161
+ # :trap_port 162
162
+ # :community 'public'
163
+ # :write_community Same as :community
164
+ # :version :SNMPv2c
165
+ # :timeout 1 (timeout units are seconds)
166
+ # :retries 5
167
+ # :transport UDPTransport
168
+ # :max_recv_bytes 8000 bytes
169
+ # :mib_dir MIB::DEFAULT_MIB_PATH
170
+ # :mib_modules SNMPv2-SMI, SNMPv2-MIB, IF-MIB, IP-MIB, TCP-MIB, UDP-MIB
171
+ # :use_IPv6 false, unless :host is formatted like an IPv6 address
172
+ #
173
+ # Use {:version => :SNMPv1} for SNMP v1. SNMP v3 is not supported.
174
+ #
175
+ def initialize(options = {})
176
+ if block_given?
177
+ warn "SNMP::Manager.new() does not take block; use SNMP::Manager.open() instead"
178
+ end
179
+ config = Config.new(options)
180
+ @host = config.host
181
+ @port = config.port
182
+ @trap_port = config.trap_port
183
+ @community = config.community
184
+ @write_community = config.write_community
185
+ @snmp_version = config.version
186
+ @timeout = config.timeout
187
+ @retries = config.retries
188
+ @transport = config.create_transport
189
+ @max_bytes = config.max_recv_bytes
190
+ @mib = MIB.new
191
+ load_modules(config.mib_modules, config.mib_dir)
192
+ @config = config.applied_config
193
+ end
194
+
170
195
  ##
171
196
  # Creates a Manager but also takes an optional block and automatically
172
197
  # closes the transport connection used by this manager after the block
173
198
  # completes.
174
199
  #
175
200
  def self.open(config = {})
176
- manager = Manager.new(config)
177
- if block_given?
178
- begin
179
- yield manager
180
- ensure
181
- manager.close
182
- end
201
+ manager = Manager.new(config)
202
+ if block_given?
203
+ begin
204
+ yield manager
205
+ ensure
206
+ manager.close
183
207
  end
208
+ end
184
209
  end
185
-
210
+
186
211
  ##
187
212
  # Close the transport connection for this manager.
188
213
  #
189
214
  def close
190
- @transport.close
215
+ @transport.close
191
216
  end
192
-
217
+
193
218
  def load_module(name)
194
- @mib.load_module(name)
219
+ @mib.load_module(name)
195
220
  end
196
-
221
+
197
222
  ##
198
223
  # Sends a get request for the supplied list of ObjectId or VarBind
199
224
  # objects.
@@ -201,9 +226,9 @@ class Manager
201
226
  # Returns a Response PDU with the results of the request.
202
227
  #
203
228
  def get(object_list)
204
- varbind_list = @mib.varbind_list(object_list, :NullValue)
205
- request = GetRequest.new(@@request_id.next, varbind_list)
206
- try_request(request)
229
+ varbind_list = @mib.varbind_list(object_list, :NullValue)
230
+ request = GetRequest.new(@@request_id.next, varbind_list)
231
+ try_request(request)
207
232
  end
208
233
 
209
234
  ##
@@ -216,18 +241,18 @@ class Manager
216
241
  #
217
242
  # For example:
218
243
  #
219
- # SNMP::Manager.open(:Host => "localhost") do |manager|
244
+ # SNMP::Manager.open(:host => "localhost") do |manager|
220
245
  # puts manager.get_value("sysDescr.0")
221
246
  # end
222
247
  #
223
248
  def get_value(object_list)
224
- if object_list.respond_to? :to_ary
225
- get(object_list).vb_list.collect { |vb| vb.value }
226
- else
227
- get(object_list).vb_list.first.value
228
- end
249
+ if object_list.respond_to? :to_ary
250
+ get(object_list).vb_list.collect { |vb| vb.value }
251
+ else
252
+ get(object_list).vb_list.first.value
253
+ end
229
254
  end
230
-
255
+
231
256
  ##
232
257
  # Sends a get-next request for the supplied list of ObjectId or VarBind
233
258
  # objects.
@@ -235,11 +260,11 @@ class Manager
235
260
  # Returns a Response PDU with the results of the request.
236
261
  #
237
262
  def get_next(object_list)
238
- varbind_list = @mib.varbind_list(object_list, :NullValue)
239
- request = GetNextRequest.new(@@request_id.next, varbind_list)
240
- try_request(request)
263
+ varbind_list = @mib.varbind_list(object_list, :NullValue)
264
+ request = GetNextRequest.new(@@request_id.next, varbind_list)
265
+ try_request(request)
241
266
  end
242
-
267
+
243
268
  ##
244
269
  # Sends a get-bulk request. The non_repeaters parameter specifies
245
270
  # the number of objects in the object_list to be retrieved once. The
@@ -247,24 +272,24 @@ class Manager
247
272
  # times specified by max_repetitions.
248
273
  #
249
274
  def get_bulk(non_repeaters, max_repetitions, object_list)
250
- varbind_list = @mib.varbind_list(object_list, :NullValue)
251
- request = GetBulkRequest.new(
252
- @@request_id.next,
253
- varbind_list,
254
- non_repeaters,
255
- max_repetitions)
256
- try_request(request)
257
- end
258
-
275
+ varbind_list = @mib.varbind_list(object_list, :NullValue)
276
+ request = GetBulkRequest.new(
277
+ @@request_id.next,
278
+ varbind_list,
279
+ non_repeaters,
280
+ max_repetitions)
281
+ try_request(request)
282
+ end
283
+
259
284
  ##
260
285
  # Sends a set request using the supplied list of VarBind objects.
261
286
  #
262
287
  # Returns a Response PDU with the results of the request.
263
288
  #
264
289
  def set(object_list)
265
- varbind_list = @mib.varbind_list(object_list, :KeepValue)
266
- request = SetRequest.new(@@request_id.next, varbind_list)
267
- try_request(request, @write_community)
290
+ varbind_list = @mib.varbind_list(object_list, :KeepValue)
291
+ request = SetRequest.new(@@request_id.next, varbind_list)
292
+ try_request(request, @write_community)
268
293
  end
269
294
 
270
295
  ##
@@ -278,7 +303,7 @@ class Manager
278
303
  #
279
304
  # generic_trap: The generic trap identifier. One of :coldStart,
280
305
  # :warmStart, :linkDown, :linkUp, :authenticationFailure,
281
- # :egpNeighborLoss, or :enterpriseSpecific
306
+ # :egpNeighborLoss, or :enterpriseSpecific
282
307
  #
283
308
  # specific_trap: An integer representing the specific trap type for
284
309
  # an enterprise-specific trap.
@@ -286,7 +311,7 @@ class Manager
286
311
  # timestamp: An integer respresenting the number of hundredths of
287
312
  # a second that this system has been up.
288
313
  #
289
- # object_list: A list of additional varbinds to send with the trap.
314
+ # object_list: A list of additional varbinds to send with the trap.
290
315
  #
291
316
  # For example:
292
317
  #
@@ -301,15 +326,15 @@ class Manager
301
326
  # end
302
327
  #
303
328
  def trap_v1(enterprise, agent_addr, generic_trap, specific_trap, timestamp, object_list=[])
304
- vb_list = @mib.varbind_list(object_list, :KeepValue)
305
- ent_oid = @mib.oid(enterprise)
306
- agent_ip = IpAddress.new(agent_addr)
307
- specific_int = Integer(specific_trap)
308
- ticks = TimeTicks.new(timestamp)
309
- trap = SNMPv1_Trap.new(ent_oid, agent_ip, generic_trap, specific_int, ticks, vb_list)
310
- send_request(trap, @community, @host, @trap_port)
311
- end
312
-
329
+ vb_list = @mib.varbind_list(object_list, :KeepValue)
330
+ ent_oid = @mib.oid(enterprise)
331
+ agent_ip = IpAddress.new(agent_addr)
332
+ specific_int = Integer(specific_trap)
333
+ ticks = TimeTicks.new(timestamp)
334
+ trap = SNMPv1_Trap.new(ent_oid, agent_ip, generic_trap, specific_int, ticks, vb_list)
335
+ send_request(trap, @community, @host, @trap_port)
336
+ end
337
+
313
338
  ##
314
339
  # Sends an SNMPv2c style trap.
315
340
  #
@@ -319,16 +344,16 @@ class Manager
319
344
  # trap_oid: An ObjectId or String with the OID identifier for this
320
345
  # trap.
321
346
  #
322
- # object_list: A list of additional varbinds to send with the trap.
347
+ # object_list: A list of additional varbinds to send with the trap.
323
348
  #
324
349
  def trap_v2(sys_up_time, trap_oid, object_list=[])
325
- vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
326
- trap = SNMPv2_Trap.new(@@request_id.next, vb_list)
327
- send_request(trap, @community, @host, @trap_port)
350
+ vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
351
+ trap = SNMPv2_Trap.new(@@request_id.next, vb_list)
352
+ send_request(trap, @community, @host, @trap_port)
328
353
  end
329
-
354
+
330
355
  ##
331
- # Sends an inform request using the supplied varbind list.
356
+ # Sends an inform request using the supplied varbind list.
332
357
  #
333
358
  # sys_up_time: An integer respresenting the number of hundredths of
334
359
  # a second that this system has been up.
@@ -336,24 +361,24 @@ class Manager
336
361
  # trap_oid: An ObjectId or String with the OID identifier for this
337
362
  # inform request.
338
363
  #
339
- # object_list: A list of additional varbinds to send with the inform.
364
+ # object_list: A list of additional varbinds to send with the inform.
340
365
  #
341
366
  def inform(sys_up_time, trap_oid, object_list=[])
342
- vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
343
- request = InformRequest.new(@@request_id.next, vb_list)
344
- try_request(request, @community, @host, @trap_port)
367
+ vb_list = create_trap_vb_list(sys_up_time, trap_oid, object_list)
368
+ request = InformRequest.new(@@request_id.next, vb_list)
369
+ try_request(request, @community, @host, @trap_port)
345
370
  end
346
-
371
+
347
372
  ##
348
373
  # Helper method for building VarBindList for trap and inform requests.
349
374
  #
350
375
  def create_trap_vb_list(sys_up_time, trap_oid, object_list)
351
- vb_args = @mib.varbind_list(object_list, :KeepValue)
352
- uptime_vb = VarBind.new(SNMP::SYS_UP_TIME_OID, TimeTicks.new(sys_up_time.to_int))
353
- trap_vb = VarBind.new(SNMP::SNMP_TRAP_OID_OID, @mib.oid(trap_oid))
354
- VarBindList.new([uptime_vb, trap_vb, *vb_args])
376
+ vb_args = @mib.varbind_list(object_list, :KeepValue)
377
+ uptime_vb = VarBind.new(SNMP::SYS_UP_TIME_OID, TimeTicks.new(sys_up_time.to_int))
378
+ trap_vb = VarBind.new(SNMP::SNMP_TRAP_OID_OID, @mib.oid(trap_oid))
379
+ VarBindList.new([uptime_vb, trap_vb, *vb_args])
355
380
  end
356
-
381
+
357
382
  ##
358
383
  # Walks a list of ObjectId or VarBind objects using get_next until
359
384
  # the response to the first OID in the list reaches the end of its
@@ -368,12 +393,12 @@ class Manager
368
393
  #
369
394
  # For example:
370
395
  #
371
- # SNMP::Manager.open(:Host => "localhost") do |manager|
396
+ # SNMP::Manager.open(:host => "localhost") do |manager|
372
397
  # manager.walk("ifTable") { |vb| puts vb }
373
398
  # end
374
399
  #
375
- # SNMP::Manager.open(:Host => "localhost") do |manager|
376
- # manager.walk(["ifIndex", "ifDescr"]) do |index, descr|
400
+ # SNMP::Manager.open(:host => "localhost") do |manager|
401
+ # manager.walk(["ifIndex", "ifDescr"]) do |index, descr|
377
402
  # puts "#{index.value} #{descr.value}"
378
403
  # end
379
404
  # end
@@ -386,36 +411,36 @@ class Manager
386
411
  # Note: If you are getting back rows where all columns have a value of
387
412
  # NoSuchInstance then your index column is probably missing one of the
388
413
  # rows. Choose an index column that includes all indexes for the table.
389
- #
414
+ #
390
415
  def walk(object_list, index_column=0)
391
- raise ArgumentError, "expected a block to be given" unless block_given?
392
- vb_list = @mib.varbind_list(object_list, :NullValue)
393
- raise ArgumentError, "index_column is past end of varbind list" if index_column >= vb_list.length
394
- is_single_vb = object_list.respond_to?(:to_str) ||
395
- object_list.respond_to?(:to_varbind)
396
- start_list = vb_list
397
- start_oid = vb_list[index_column].name
398
- last_oid = start_oid
399
- loop do
400
- vb_list = get_next(vb_list).vb_list
401
- index_vb = vb_list[index_column]
402
- break if EndOfMibView == index_vb.value
403
- stop_oid = index_vb.name
404
- if stop_oid <= last_oid
405
- warn "OIDs are not increasing, #{last_oid} followed by #{stop_oid}"
406
- break
407
- end
408
- break unless stop_oid.subtree_of?(start_oid)
409
- last_oid = stop_oid
410
- if is_single_vb
411
- yield index_vb
412
- else
413
- vb_list = validate_row(vb_list, start_list, index_column)
414
- yield vb_list
415
- end
416
+ raise ArgumentError, "expected a block to be given" unless block_given?
417
+ vb_list = @mib.varbind_list(object_list, :NullValue)
418
+ raise ArgumentError, "index_column is past end of varbind list" if index_column >= vb_list.length
419
+ is_single_vb = object_list.respond_to?(:to_str) ||
420
+ object_list.respond_to?(:to_varbind)
421
+ start_list = vb_list
422
+ start_oid = vb_list[index_column].name
423
+ last_oid = start_oid
424
+ loop do
425
+ vb_list = get_next(vb_list).vb_list
426
+ index_vb = vb_list[index_column]
427
+ break if EndOfMibView == index_vb.value
428
+ stop_oid = index_vb.name
429
+ if stop_oid <= last_oid
430
+ warn "OIDs are not increasing, #{last_oid} followed by #{stop_oid}"
431
+ break
416
432
  end
433
+ break unless stop_oid.subtree_of?(start_oid)
434
+ last_oid = stop_oid
435
+ if is_single_vb
436
+ yield index_vb
437
+ else
438
+ vb_list = validate_row(vb_list, start_list, index_column)
439
+ yield vb_list
440
+ end
441
+ end
417
442
  end
418
-
443
+
419
444
  ##
420
445
  # Helper method for walk. Checks all of the VarBinds in vb_list to
421
446
  # make sure that the row indices match. If the row index does not
@@ -423,123 +448,135 @@ class Manager
423
448
  # with a value of NoSuchInstance.
424
449
  #
425
450
  def validate_row(vb_list, start_list, index_column)
426
- start_vb = start_list[index_column]
427
- index_vb = vb_list[index_column]
428
- row_index = index_vb.name.index(start_vb.name)
429
- vb_list.each_index do |i|
430
- if i != index_column
431
- expected_oid = start_list[i].name + row_index
432
- if vb_list[i].name != expected_oid
433
- vb_list[i] = VarBind.new(expected_oid, NoSuchInstance)
434
- end
435
- end
451
+ start_vb = start_list[index_column]
452
+ index_vb = vb_list[index_column]
453
+ row_index = index_vb.name.index(start_vb.name)
454
+ vb_list.each_index do |i|
455
+ if i != index_column
456
+ expected_oid = start_list[i].name + row_index
457
+ if vb_list[i].name != expected_oid
458
+ vb_list[i] = VarBind.new(expected_oid, NoSuchInstance)
459
+ end
436
460
  end
437
- vb_list
461
+ end
462
+ vb_list
438
463
  end
439
464
  private :validate_row
440
-
465
+
441
466
  ##
442
467
  # Set the next request-id instead of letting it be generated
443
468
  # automatically. This method is useful for testing and debugging.
444
469
  #
445
470
  def next_request_id=(request_id)
446
- @@request_id.force_next(request_id)
471
+ @@request_id.force_next(request_id)
447
472
  end
448
-
473
+
449
474
  private
450
475
 
451
- def warn(message)
476
+ def warn(message)
452
477
  trace = caller(2)
453
478
  location = trace[0].sub(/:in.*/,'')
454
479
  Kernel::warn "#{location}: warning: #{message}"
455
- end
456
-
457
- def load_modules(module_list, mib_dir)
480
+ end
481
+
482
+ def load_modules(module_list, mib_dir)
458
483
  module_list.each { |m| @mib.load_module(m, mib_dir) }
459
- end
460
-
461
- def try_request(request, community=@community, host=@host, port=@port)
484
+ end
485
+
486
+ def try_request(request, community=@community, host=@host, port=@port)
462
487
  (@retries + 1).times do |n|
463
- send_request(request, community, host, port)
464
- begin
465
- Timeout.timeout(@timeout) do
466
- return get_response(request)
467
- end
468
- rescue Timeout::Error
469
- # no action - try again
470
- rescue => e
471
- warn e.to_s
488
+ send_request(request, community, host, port)
489
+ begin
490
+ Timeout.timeout(@timeout) do
491
+ return get_response(request)
472
492
  end
493
+ rescue Timeout::Error
494
+ # no action - try again
495
+ rescue => e
496
+ warn e.to_s
497
+ end
473
498
  end
474
- raise RequestTimeout, "host #{@config[:Host]} not responding", caller
475
- end
476
-
477
- def send_request(request, community, host, port)
499
+ raise RequestTimeout, "host #{config[:host]} not responding", caller
500
+ end
501
+
502
+ def send_request(request, community, host, port)
478
503
  message = Message.new(@snmp_version, community, request)
479
504
  @transport.send(message.encode, host, port)
480
- end
481
-
482
- ##
483
- # Wait until response arrives. Ignore responses with mismatched IDs;
484
- # these responses are typically from previous requests that timed out
485
- # or almost timed out.
486
- #
487
- def get_response(request)
505
+ end
506
+
507
+ ##
508
+ # Wait until response arrives. Ignore responses with mismatched IDs;
509
+ # these responses are typically from previous requests that timed out
510
+ # or almost timed out.
511
+ #
512
+ def get_response(request)
488
513
  begin
489
- data = @transport.recv(@max_bytes)
490
- message = Message.decode(data)
491
- response = message.pdu
514
+ data = @transport.recv(@max_bytes)
515
+ message = Message.decode(data)
516
+ response = message.pdu
492
517
  end until request.request_id == response.request_id
493
518
  response
494
- end
495
- end
519
+ end
520
+ end
496
521
 
497
- class UDPServerTransport
498
- def initialize(host, port)
499
- @socket = UDPSocket.open
500
- @socket.bind(host, port)
522
+ class UDPServerTransport
523
+ def initialize(host, port, address_family)
524
+ @socket = UDPSocket.open(address_family)
525
+ @socket.bind(host, port)
501
526
  end
502
-
527
+
503
528
  def close
504
- @socket.close
529
+ @socket.close
505
530
  end
506
531
 
507
532
  def send(data, host, port)
508
- @socket.send(data, 0, host, port)
533
+ @socket.send(data, 0, host, port)
509
534
  end
510
-
535
+
511
536
  def recvfrom(max_bytes)
512
- data, host_info = @socket.recvfrom(max_bytes)
513
- flags, host_port, host_name, host_ip = host_info
514
- return data, host_ip, host_port
537
+ data, host_info = @socket.recvfrom(max_bytes)
538
+ flags, host_port, host_name, host_ip = host_info
539
+ return data, host_ip, host_port
515
540
  end
516
- end
541
+ end
517
542
 
518
- ##
519
- # == SNMP Trap Listener
520
- #
521
- # Listens to a socket and processes received traps and informs in a separate
522
- # thread.
523
- #
524
- # === Example
525
- #
526
- # require 'snmp'
527
- #
528
- # m = SNMP::TrapListener.new(:Port => 1062, :Community => 'public') do |manager|
529
- # manager.on_trap_default { |trap| p trap }
530
- # end
531
- # m.join
532
- #
533
- class TrapListener
534
- DefaultConfig = {
535
- :Host => 'localhost',
536
- :Port => 162,
537
- :Community => 'public',
538
- :ServerTransport => UDPServerTransport,
539
- :MaxReceiveBytes => 8000}
543
+ ##
544
+ # == SNMP Trap Listener
545
+ #
546
+ # Listens to a socket and processes received traps and informs in a separate
547
+ # thread.
548
+ #
549
+ # === Example
550
+ #
551
+ # require 'snmp'
552
+ #
553
+ # m = SNMP::TrapListener.new(:Port => 1062, :Community => 'public') do |manager|
554
+ # manager.on_trap_default { |trap| p trap }
555
+ # end
556
+ # m.join
557
+ #
558
+ class TrapListener
559
+ class Config < Options
560
+ option :host, :Host, 'localhost'
561
+ option :port, :Port, 162
562
+ option :community, :Community, 'public'
563
+ option :server_transport, :ServerTransport, UDPServerTransport
564
+ option :max_recv_bytes, :MaxReceiveBytes, 8000
565
+ option :use_IPv6, :use_IPv6, false
566
+
567
+ def create_transport
568
+ server_transport.respond_to?(:new) ?
569
+ server_transport.new(host, port, socket_address_family) : server_transport
570
+ end
571
+ end
540
572
 
541
573
  NULL_HANDLER = Proc.new {}
542
-
574
+
575
+ ##
576
+ # Retrieves the current configuration of this TrapListener.
577
+ #
578
+ attr_reader :config
579
+
543
580
  ##
544
581
  # Start a trap handler thread. If a block is provided then the block
545
582
  # is executed before trap handling begins. This block is typically used
@@ -554,37 +591,40 @@ class TrapListener
554
591
  # 2. handler for a specific SNMP version
555
592
  # 3. default handler
556
593
  #
557
- def initialize(config={}, &block)
558
- @config = DefaultConfig.dup.update(config)
559
- @transport = @config[:ServerTransport].new(@config[:Host], @config[:Port])
560
- @max_bytes = @config[:MaxReceiveBytes]
561
- @handler_init = block
562
- @oid_handler = {}
563
- @v1_handler = nil
564
- @v2c_handler = nil
565
- @default_handler = nil
566
- @lock = Mutex.new
567
- @handler_thread = Thread.new(self) { |m| process_traps(m) }
568
- end
569
-
594
+ def initialize(options={}, &block)
595
+ config = Config.new(options)
596
+ @transport = config.create_transport
597
+ @community = config.community
598
+ @max_bytes = config.max_recv_bytes
599
+ @config = config.applied_config
600
+
601
+ @handler_init = block
602
+ @oid_handler = {}
603
+ @v1_handler = nil
604
+ @v2c_handler = nil
605
+ @default_handler = nil
606
+ @lock = Mutex.new
607
+ @handler_thread = Thread.new(self) { |m| process_traps(m) }
608
+ end
609
+
570
610
  ##
571
611
  # Define the default trap handler. The default trap handler block is
572
612
  # executed only if no other block is applicable. This handler should
573
613
  # expect to receive both SNMPv1_Trap and SNMPv2_Trap objects.
574
614
  #
575
615
  def on_trap_default(&block)
576
- raise ArgumentError, "a block must be provided" unless block
577
- @lock.synchronize { @default_handler = block }
616
+ raise ArgumentError, "a block must be provided" unless block
617
+ @lock.synchronize { @default_handler = block }
578
618
  end
579
-
619
+
580
620
  ##
581
621
  # Define a trap handler block for a specific trap ObjectId. This handler
582
622
  # only applies to SNMPv2 traps. Note that symbolic OIDs are not
583
623
  # supported by this method (like in the SNMP.Manager class).
584
624
  #
585
625
  def on_trap(object_id, &block)
586
- raise ArgumentError, "a block must be provided" unless block
587
- @lock.synchronize { @oid_handler[ObjectId.new(object_id)] = block }
626
+ raise ArgumentError, "a block must be provided" unless block
627
+ @lock.synchronize { @oid_handler[ObjectId.new(object_id)] = block }
588
628
  end
589
629
 
590
630
  ##
@@ -592,10 +632,10 @@ class TrapListener
592
632
  # to the block will always be an SNMPv1_Trap.
593
633
  #
594
634
  def on_trap_v1(&block)
595
- raise ArgumentError, "a block must be provided" unless block
596
- @lock.synchronize { @v1_handler = block }
635
+ raise ArgumentError, "a block must be provided" unless block
636
+ @lock.synchronize { @v1_handler = block }
597
637
  end
598
-
638
+
599
639
  ##
600
640
  # Define a trap handler block for all SNMPv2c traps. The trap yielded
601
641
  # to the block will always be an SNMPv2_Trap. Note that InformRequest
@@ -603,83 +643,83 @@ class TrapListener
603
643
  # this handler.
604
644
  #
605
645
  def on_trap_v2c(&block)
606
- raise ArgumentError, "a block must be provided" unless block
607
- @lock.synchronize { @v2c_handler = block }
646
+ raise ArgumentError, "a block must be provided" unless block
647
+ @lock.synchronize { @v2c_handler = block }
608
648
  end
609
-
649
+
610
650
  ##
611
651
  # Joins the current thread to the trap handler thread.
612
652
  #
613
653
  # See also Thread#join.
614
654
  #
615
655
  def join
616
- @handler_thread.join
656
+ @handler_thread.join
617
657
  end
618
-
658
+
619
659
  ##
620
660
  # Stops the trap handler thread and releases the socket.
621
661
  #
622
662
  # See also Thread#exit.
623
663
  #
624
664
  def exit
625
- @handler_thread.exit
626
- @transport.close
665
+ @handler_thread.exit
666
+ @transport.close
627
667
  end
628
-
668
+
629
669
  alias kill exit
630
670
  alias terminate exit
631
-
671
+
632
672
  private
633
-
634
- def process_traps(trap_listener)
673
+
674
+ def process_traps(trap_listener)
635
675
  @handler_init.call(trap_listener) if @handler_init
636
676
  loop do
637
- data, source_ip, source_port = @transport.recvfrom(@max_bytes)
638
- begin
639
- message = Message.decode(data)
640
- if @config[:Community] == message.community
641
- trap = message.pdu
642
- if trap.kind_of?(InformRequest)
643
- @transport.send(message.response.encode, source_ip, source_port)
644
- end
645
- trap.source_ip = source_ip
646
- select_handler(trap).call(trap)
647
- end
648
- rescue => e
649
- puts "Error handling trap: #{e}"
650
- puts e.backtrace.join("\n")
651
- puts "Received data:"
652
- p data
677
+ data, source_ip, source_port = @transport.recvfrom(@max_bytes)
678
+ begin
679
+ message = Message.decode(data)
680
+ if @community == message.community
681
+ trap = message.pdu
682
+ if trap.kind_of?(InformRequest)
683
+ @transport.send(message.response.encode, source_ip, source_port)
684
+ end
685
+ trap.source_ip = source_ip
686
+ select_handler(trap).call(trap)
653
687
  end
688
+ rescue => e
689
+ puts "Error handling trap: #{e}"
690
+ puts e.backtrace.join("\n")
691
+ puts "Received data:"
692
+ p data
693
+ end
654
694
  end
655
- end
656
-
657
- def select_handler(trap)
695
+ end
696
+
697
+ def select_handler(trap)
658
698
  @lock.synchronize do
659
- if trap.kind_of?(SNMPv2_Trap)
660
- oid = trap.trap_oid
661
- if @oid_handler[oid]
662
- return @oid_handler[oid]
663
- elsif @v2c_handler
664
- return @v2c_handler
665
- elsif @default_handler
666
- return @default_handler
667
- else
668
- return NULL_HANDLER
669
- end
670
- elsif trap.kind_of?(SNMPv1_Trap)
671
- if @v1_handler
672
- return @v1_handler
673
- elsif @default_handler
674
- return @default_handler
675
- else
676
- return NULL_HANDLER
677
- end
699
+ if trap.kind_of?(SNMPv2_Trap)
700
+ oid = trap.trap_oid
701
+ if @oid_handler[oid]
702
+ return @oid_handler[oid]
703
+ elsif @v2c_handler
704
+ return @v2c_handler
705
+ elsif @default_handler
706
+ return @default_handler
678
707
  else
679
- return NULL_HANDLER
708
+ return NULL_HANDLER
680
709
  end
710
+ elsif trap.kind_of?(SNMPv1_Trap)
711
+ if @v1_handler
712
+ return @v1_handler
713
+ elsif @default_handler
714
+ return @default_handler
715
+ else
716
+ return NULL_HANDLER
717
+ end
718
+ else
719
+ return NULL_HANDLER
720
+ end
681
721
  end
682
- end
683
- end
722
+ end
723
+ end
684
724
 
685
725
  end