netsnmp 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +42 -0
- data/AUTHORS +1 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +201 -0
- data/README.md +162 -0
- data/Rakefile +26 -0
- data/lib/netsnmp.rb +16 -0
- data/lib/netsnmp/client.rb +131 -0
- data/lib/netsnmp/core.rb +12 -0
- data/lib/netsnmp/core/client.rb +15 -0
- data/lib/netsnmp/core/constants.rb +153 -0
- data/lib/netsnmp/core/inline.rb +20 -0
- data/lib/netsnmp/core/libc.rb +48 -0
- data/lib/netsnmp/core/libsnmp.rb +44 -0
- data/lib/netsnmp/core/structures.rb +167 -0
- data/lib/netsnmp/core/utilities.rb +13 -0
- data/lib/netsnmp/errors.rb +8 -0
- data/lib/netsnmp/handlers/celluloid.rb +27 -0
- data/lib/netsnmp/handlers/em.rb +56 -0
- data/lib/netsnmp/oid.rb +94 -0
- data/lib/netsnmp/pdu.rb +105 -0
- data/lib/netsnmp/session.rb +306 -0
- data/lib/netsnmp/varbind.rb +181 -0
- data/lib/netsnmp/version.rb +3 -0
- data/netsnmp.gemspec +36 -0
- data/spec/client_spec.rb +90 -0
- data/spec/core/libc_spec.rb +2 -0
- data/spec/core/libsnmp_spec.rb +32 -0
- data/spec/core/structures_spec.rb +54 -0
- data/spec/handlers/celluloid_spec.rb +29 -0
- data/spec/handlers/em_client_spec.rb +34 -0
- data/spec/oid_spec.rb +9 -0
- data/spec/pdu_spec.rb +29 -0
- data/spec/session_spec.rb +34 -0
- data/spec/spec_helper.rb +114 -0
- data/spec/support/Dockerfile +14 -0
- data/spec/support/celluloid.rb +22 -0
- data/spec/support/start_docker.sh +4 -0
- data/spec/support/stop_docker.sh +5 -0
- data/spec/varbind_spec.rb +54 -0
- metadata +187 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM python:2
|
2
|
+
Maintainer Tiago Cardoso <tiago.cardoso@swisscom.com>
|
3
|
+
|
4
|
+
RUN easy_install snmpsim
|
5
|
+
RUN easy_install pycrypto
|
6
|
+
EXPOSE 1161
|
7
|
+
# Create non-privileged user
|
8
|
+
RUN useradd -m snmp_server
|
9
|
+
|
10
|
+
|
11
|
+
USER snmp_server
|
12
|
+
ENTRYPOINT ["/usr/local/bin/snmpsimd.py"]
|
13
|
+
|
14
|
+
CMD ["--help"]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copied from celluloid-io spec helpers
|
2
|
+
module CelluloidHelpers
|
3
|
+
class WrapperActor
|
4
|
+
include ::Celluloid::IO
|
5
|
+
execute_block_on_receiver :wrap
|
6
|
+
|
7
|
+
def wrap
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def with_wrapper_actor
|
13
|
+
WrapperActor.new
|
14
|
+
end
|
15
|
+
def within_io_actor(&block)
|
16
|
+
actor = WrapperActor.new
|
17
|
+
actor.wrap(&block)
|
18
|
+
ensure
|
19
|
+
actor.terminate if actor.alive? rescue nil
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
sudo docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -t snmp-server-emulator -f spec/support/Dockerfile .
|
2
|
+
sudo docker run -d -p :1161/udp --name test-snmp-emulator snmp-server-emulator --agent-udpv4-endpoint=0.0.0.0:1161 --agent-udpv6-endpoint='[::0]:1161'
|
3
|
+
|
4
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
RSpec.describe NETSNMP::Varbind do
|
2
|
+
let(:struct) { double(:structure) }
|
3
|
+
let(:pointer) { double(:pointer) }
|
4
|
+
subject { NETSNMP::Varbind.new(pointer) }
|
5
|
+
before do
|
6
|
+
allow(NETSNMP::Core::Structures::VariableList).to receive(:new).with(pointer).and_return(struct)
|
7
|
+
end
|
8
|
+
|
9
|
+
it { is_expected.to respond_to(:struct) }
|
10
|
+
|
11
|
+
describe NETSNMP::RequestVarbind do
|
12
|
+
subject { NETSNMP::RequestVarbind.new(pdu, oid, value) }
|
13
|
+
let(:p1) { double(:pdu_pointer) }
|
14
|
+
let(:p2) { double(:oid_pointer) }
|
15
|
+
let(:pdu) { double(:pdu, pointer: p1) }
|
16
|
+
let(:oid) { double(:oid, pointer: p2, length: 2) }
|
17
|
+
context "on initialization" do
|
18
|
+
after { subject }
|
19
|
+
context "when not passed type" do
|
20
|
+
context "and the value is a fixnum" do
|
21
|
+
let(:value) { 1 }
|
22
|
+
it { expect(NETSNMP::Core::LibSNMP).to receive(:snmp_pdu_add_variable).with(p1, p2, 2, instance_of(Fixnum), instance_of(FFI::MemoryPointer), value.size).and_return(pointer) }
|
23
|
+
# TODO: value.length is too abstract. but this value differs between 32 and 64 bit architectures...
|
24
|
+
end
|
25
|
+
context "and the value is a string" do
|
26
|
+
let(:value) { "value" }
|
27
|
+
it { expect(NETSNMP::Core::LibSNMP).to receive(:snmp_pdu_add_variable).with(p1, p2, 2, instance_of(Fixnum), value, 5).and_return(pointer) }
|
28
|
+
end
|
29
|
+
context "and the value is a oid" do
|
30
|
+
let(:value) { NETSNMP::OID.new("SNMPv2-MIB::sysDescr.0") }
|
31
|
+
let(:p3) { double(:value_pointer) }
|
32
|
+
let(:len) { double(:length) }
|
33
|
+
before do
|
34
|
+
expect(value).to receive(:size).and_return(len)
|
35
|
+
expect(value).to receive(:pointer).and_return(p3)
|
36
|
+
end
|
37
|
+
it { expect(NETSNMP::Core::LibSNMP).to receive(:snmp_pdu_add_variable).with(p1, p2, 2, instance_of(Fixnum), p3, len).and_return(pointer) }
|
38
|
+
end
|
39
|
+
context "and the value is nothing" do
|
40
|
+
let(:value) { nil }
|
41
|
+
it { expect(NETSNMP::Core::LibSNMP).to receive(:snmp_pdu_add_variable).with(p1, p2, 2, instance_of(Fixnum), nil, 0).and_return(pointer) }
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
describe NETSNMP::ResponseVarbind do
|
50
|
+
let(:value) { "value" }
|
51
|
+
before { allow(subject).to receive(:load_varbind_value).and_return(value) }
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: netsnmp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tiago Cardoso
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: RubyInline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 10.4.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 10.4.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.3.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: em-synchrony
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.4
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.4
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: celluloid-io
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.17.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.17.2
|
97
|
+
description: |
|
98
|
+
Wraps the net-snmp core usage into idiomatic ruby.
|
99
|
+
It is designed to support as many environments and concurrency frameworks as possible.
|
100
|
+
email: cardoso_tiago@hotmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .rspec
|
107
|
+
- .travis.yml
|
108
|
+
- AUTHORS
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- lib/netsnmp.rb
|
114
|
+
- lib/netsnmp/client.rb
|
115
|
+
- lib/netsnmp/core.rb
|
116
|
+
- lib/netsnmp/core/client.rb
|
117
|
+
- lib/netsnmp/core/constants.rb
|
118
|
+
- lib/netsnmp/core/inline.rb
|
119
|
+
- lib/netsnmp/core/libc.rb
|
120
|
+
- lib/netsnmp/core/libsnmp.rb
|
121
|
+
- lib/netsnmp/core/structures.rb
|
122
|
+
- lib/netsnmp/core/utilities.rb
|
123
|
+
- lib/netsnmp/errors.rb
|
124
|
+
- lib/netsnmp/handlers/celluloid.rb
|
125
|
+
- lib/netsnmp/handlers/em.rb
|
126
|
+
- lib/netsnmp/oid.rb
|
127
|
+
- lib/netsnmp/pdu.rb
|
128
|
+
- lib/netsnmp/session.rb
|
129
|
+
- lib/netsnmp/varbind.rb
|
130
|
+
- lib/netsnmp/version.rb
|
131
|
+
- netsnmp.gemspec
|
132
|
+
- spec/client_spec.rb
|
133
|
+
- spec/core/libc_spec.rb
|
134
|
+
- spec/core/libsnmp_spec.rb
|
135
|
+
- spec/core/structures_spec.rb
|
136
|
+
- spec/handlers/celluloid_spec.rb
|
137
|
+
- spec/handlers/em_client_spec.rb
|
138
|
+
- spec/oid_spec.rb
|
139
|
+
- spec/pdu_spec.rb
|
140
|
+
- spec/session_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/support/Dockerfile
|
143
|
+
- spec/support/celluloid.rb
|
144
|
+
- spec/support/start_docker.sh
|
145
|
+
- spec/support/stop_docker.sh
|
146
|
+
- spec/varbind_spec.rb
|
147
|
+
homepage: ''
|
148
|
+
licenses:
|
149
|
+
- Apache-2.0
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.0.0
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements:
|
166
|
+
- net-snmp
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.5.2
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: SNMP Client library
|
172
|
+
test_files:
|
173
|
+
- spec/client_spec.rb
|
174
|
+
- spec/core/libc_spec.rb
|
175
|
+
- spec/core/libsnmp_spec.rb
|
176
|
+
- spec/core/structures_spec.rb
|
177
|
+
- spec/handlers/celluloid_spec.rb
|
178
|
+
- spec/handlers/em_client_spec.rb
|
179
|
+
- spec/oid_spec.rb
|
180
|
+
- spec/pdu_spec.rb
|
181
|
+
- spec/session_spec.rb
|
182
|
+
- spec/spec_helper.rb
|
183
|
+
- spec/support/Dockerfile
|
184
|
+
- spec/support/celluloid.rb
|
185
|
+
- spec/support/start_docker.sh
|
186
|
+
- spec/support/stop_docker.sh
|
187
|
+
- spec/varbind_spec.rb
|