netsnmp 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01d3849f1d3acbab7fa9b57055aafd5150fd3865
4
+ data.tar.gz: 444a3fae5b5d38df3873a4ee0c35cf16f3bf16a6
5
+ SHA512:
6
+ metadata.gz: 6cd620b0b6cc65ba8f58d6c0ec5168270f9f814f930b6bc56bd8f82e26cbc4bb5b146858bf328a27265cc149b5e73ca521655250d6a36e4ccec65b0cc64fa5fc
7
+ data.tar.gz: 0be3b839d7992a719f4efa6a823899d9b1b98a206ef4a780bf6b044fbf655860daf800534aad976861dbbb39215ddb5ed537df0ff39e4bb0a68a22c94fbd1049
@@ -0,0 +1,14 @@
1
+ /coverage/
2
+ /doc/
3
+ /pkg/
4
+ /tmp/
5
+ /log/
6
+ /.yardoc/
7
+ /.bundle
8
+ /Gemfile.lock
9
+ /vendor
10
+ .env
11
+
12
+ *.DS_Store
13
+ *.sw[po]
14
+ *.nfs*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,42 @@
1
+ sudo: required
2
+ services:
3
+ - docker
4
+
5
+ before_install:
6
+ - sudo apt-add-repository multiverse
7
+ - sudo apt-get update
8
+ - sudo apt-get install -y sed
9
+ - sudo apt-get install -y snmp
10
+ - sudo apt-get install -y libsnmp-dev
11
+ - sudo apt-get install -y snmp-mibs-downloader
12
+ - sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-engine
13
+
14
+ before_script:
15
+ - sudo download-mibs
16
+ - sudo sed -i 's/^mibs/#mibs/g' /etc/snmp/snmp.conf
17
+ - spec/support/start_docker.sh
18
+ after_script: spec/support/stop_docker.sh
19
+
20
+ install:
21
+ - bundle install --path .bundle
22
+
23
+ script:
24
+ - bundle exec rake spec:ci
25
+
26
+ language: ruby
27
+ rvm:
28
+ - 2.0
29
+ - 2.1
30
+ - 2.2
31
+ - 2.3.1
32
+ - ruby-head
33
+ - jruby-9.1.1.0
34
+ - jruby-head
35
+ - rbx-2
36
+ matrix:
37
+ allow_failures:
38
+ - rvm: ruby-head
39
+ - rvm: jruby-head
40
+ # to figure out later
41
+ - rvm: jruby-9.1.1.0
42
+ - rvm: rbx-2
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ * Tiago Cardoso (cardoso_tiago@hotmail.com)
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org/"
2
+
3
+ gemspec
4
+
5
+ gem 'coveralls', require: false
6
+
7
+ group :development do
8
+ gem 'pry'
9
+ gem 'pry-byebug'
10
+ end
11
+
12
+
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,162 @@
1
+ # netsnmp
2
+
3
+ [![Build Status](https://travis-ci.org/swisscom/ruby-netsnmp.svg?branch=master)](https://travis-ci.org/swisscom/ruby-netsnmp)
4
+ [![Coverage Status](https://coveralls.io/repos/github/swisscom/ruby-netsnmp/badge.svg?branch=master)](https://coveralls.io/github/swisscom/ruby-netsnmp?branch=master)
5
+ [![Code Climate](https://codeclimate.com/github/swisscom/ruby-netsnmp/badges/gpa.svg)](https://codeclimate.com/github/swisscom/ruby-netsnmp)
6
+ [![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/swisscom/ruby-netsnmp/master)
7
+
8
+ The netsnmp gem provides a ruby DSL to handle SNMP queries. It currently uses the net-snmp C library using the FFI interface.
9
+
10
+ This gem started as a cleanup from [net-snmp](https://github.com/mixtli/net-snmp) and its follow-up [net-snmp2](https://github.com/jbreeden/net-snmp2), both of which have been mostly inactive for the last year(s).
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'netsnmp'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```
23
+ $ bundle
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```
29
+ $ gem install netsnmp
30
+ ```
31
+
32
+ ## Why?
33
+
34
+ You may ask, why not just use the aforementioned? I'll try to sum up the reasons.
35
+
36
+ * Lack of support for some specific net-snmp versions.
37
+ * Memory Leaks (both leave the responsibility of cleaning pdus to the user, and this usually creates memory leak when the responses fail).
38
+ * Lack of support for some ruby > 2.1 GC directives, which makes the VM crash under certain circumstances.
39
+ * Iffy EventMachine support (they basically send the request pdu, and schedule the reads to the reactor, and not really reacting on the socket handle).
40
+ * Lack of support for NIO4r/Celluloid-IO (the other event loop, besides EM, that counts in the ruby world).
41
+ * The default sync request calls block the whole VM, making multi-threading a non-factor, forcing you to resort to multiprocess for concurrency.
42
+
43
+
44
+ ## Philosophy
45
+
46
+ The main motto of the gem is: API economy. As less moving parts as possible. New features can be discussed and integrated, but they all must abide to this philosophy.
47
+
48
+ The main purpose of this gem is: SNMP v3 support. Why? Because it's the only one with authentication and security features integrated. SNMP has been a protocol which historically ignored security for many years, and even when it embraced it, its choices are by today's standards considered half-baked (MD5, SHA-1, shrug). Still, some-security is better than no-security. Also, support for v1 and v2 is something that you can get from other ruby gems (most of them refuse to support v3 altogether).
49
+
50
+ Do one thing and do it well. There's only an interface to interact with an SNMP Agent. Other features like credentials encryption or concurrency are out of the scope of this library, which only guarantees that an SNMP Client is thread-safe and performs ruby-VM-compatible IO.
51
+
52
+ ## Features
53
+
54
+ * Client Interface, which supports SNMP 3, 2c, and 1
55
+ * Supports get, set, walk and bulk calls.
56
+ * Wrappers for eventmachine and celluloid-io
57
+ * Ruby >= 2.0 support
58
+ * net-snmp (C library) >= 5.5 support
59
+
60
+ ## Examples
61
+
62
+ You can use the docker container provided under spec/support to test against these examples (the port used in the examples should be the docker external port mapped to port 161).
63
+
64
+ ```ruby
65
+ require 'netsnmp'
66
+
67
+ manager = NETSNMP::Client.new("localhost", port: 33445, username: "simulator",
68
+ auth_password: "auctoritas", auth_protocol: :md5,
69
+ priv_password: "privatus", priv_protocol: :des,
70
+ context: "a172334d7d97871b72241397f713fa12")
71
+
72
+ # SNMP get
73
+ manager.get("sysName.0") #=> 'tt'
74
+
75
+ # SNMP walk
76
+ manager.walk("sysORDescr") do |oid_code, value|
77
+ # do something with them
78
+ puts "for #{oid_code}: #{value}"
79
+ end
80
+
81
+ # SNMP get_bulk
82
+ manager.get_bulk("sysOrDescr") do |oid_code, value|
83
+ # do something with them
84
+ puts "for #{oid_code}: #{value}"
85
+ end
86
+
87
+ manager.close
88
+
89
+ # SNMP set
90
+ manager2 = NETSNMP::Client.new("localhost", port: 33445, username: "simulator",
91
+ auth_password: "auctoritas", auth_protocol: :md5,
92
+ priv_password: "privatus", priv_protocol: :des,
93
+ context: "0886e1397d572377c17c15036a1e6c66")
94
+
95
+ # setting to 43, becos yes
96
+ manager2.set("sysUpTimeInstance", 43)
97
+
98
+ manager2.close
99
+ ```
100
+
101
+ ## Tests
102
+
103
+ This library uses RSpec. The client specs are "integration" tests, in that we communicate with an snmp agent simulator.
104
+
105
+ To start the simulator locally, you'll need docker 1.9 or higher (Why 1.9? ```--build-arg``` parameter support was needed for our builds in the CI. You could use a lower version by providing the proxy environment variables in the Dockerfile directly, provided you don't merge these changes to master, thereby exposing your proxy).
106
+
107
+ ```
108
+ > spec/support/start_docker.sh
109
+ ```
110
+
111
+ this builds and starts the docker image in deamonized mode. You can afterwards run your specs:
112
+
113
+ ```
114
+ > bundle exec rspec
115
+ ```
116
+
117
+ To stop the image, you can just:
118
+
119
+ ```
120
+ > spec/supoprt/stop_docker.sh
121
+ ```
122
+
123
+ ## Notes
124
+
125
+ This library provides support for C net-snmp 5.5 or higher, as this has been considered the most stable SNMP v3 implementation.
126
+
127
+ To install it in your environment, just use your package manager:
128
+
129
+ ```
130
+ # on OSX
131
+ > brew install net-snmp
132
+
133
+ # Linux
134
+ # centOS
135
+ > sudo yum install net-snmp
136
+ # Ubuntu
137
+ > sudo apt-get install net-snmp
138
+ > sudo apt-get install libsnmp-dev
139
+ ```
140
+
141
+ Ubuntu doesn't come with the default mibs, you might have to download the mibs downloader package:
142
+
143
+ ```
144
+ > sudo apt-get install -y snmp-mibs-downloader
145
+ > sudo download-mibs
146
+ ```
147
+
148
+ TODO: on Windows(?)
149
+
150
+ ## Contributing
151
+
152
+ * Fork this repository
153
+ * Make your changes and send me a pull request
154
+ * If I like them I'll merge them
155
+ * If I've accepted a patch, feel free to ask for a commit bit!
156
+
157
+ ## TODO
158
+
159
+ There are a few features still to be added, like:
160
+
161
+ * [JRuby Support](https://github.com/celluloid/nio4r/issues/94)
162
+