snmp-open 0.1.5 → 0.2.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 +4 -4
- data/.travis.yml +3 -1
- data/README.md +2 -0
- data/lib/snmp/open.rb +1 -1
- data/lib/snmp/open/command_reader.rb +6 -1
- data/lib/snmp/open/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1bfb86bae4239a253fa4528be54e46a30e770d
|
4
|
+
data.tar.gz: 0574b00db365565c87e647314b00f34950ba8280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db49e2407897332554aae593b909bb74db5878a6b2f5f72779bfe6fdd1be116c2579226811bca87814c5f2ae3f55678c4a9ccbfcebd0157ccc918a4b48bea0b4
|
7
|
+
data.tar.gz: 98f0150f390faf0fe8f8cffb8e60c535aae051cda4bfa964900a4e2172449807c3e85fdcaccf9d2090c1a082084885a872d93402b423e6fa2abb94de797b086e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,8 @@ end
|
|
36
36
|
|
37
37
|
Naturally, configuration can also be supplied through `snmp.conf(5)`.
|
38
38
|
|
39
|
+
Environment variables can be given using the `env` keyword parameter to `SNMP::Open.new`. For example, the `SNMP_PERSISTENT_FILE` and `SNMPCONFPATH` variables are understood by Net-SNMP commands and indicate paths in which to look for configuration files.
|
40
|
+
|
39
41
|
## Development
|
40
42
|
|
41
43
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/snmp/open.rb
CHANGED
@@ -30,7 +30,7 @@ module SNMP
|
|
30
30
|
def get(oids)
|
31
31
|
return enum_for(:get, oids) unless block_given?
|
32
32
|
texts = oids.map { |oid| reader.capture(:get, oid) }
|
33
|
-
Parser.new(oids).parse(texts).
|
33
|
+
Parser.new(oids).parse(texts).fetch(0, []).each { |arg| yield(arg) }
|
34
34
|
end
|
35
35
|
|
36
36
|
# Perform an SNMP walk using the "snmpwalk" or "snmpbulkwalk" commands and
|
@@ -41,6 +41,7 @@ module SNMP
|
|
41
41
|
# SNMP::Open.new(hostname => nil, '-t' => '3', '-m' => miblist)
|
42
42
|
#
|
43
43
|
def initialize(options)
|
44
|
+
@env = options.delete(:env)
|
44
45
|
host = options.delete(:host) ||
|
45
46
|
(raise ArgumentError, 'Host expected but not given')
|
46
47
|
opts = merge_options(options).merge('-On' => nil, host => nil)
|
@@ -48,7 +49,11 @@ module SNMP
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def capture(cmd, oid, options = {})
|
51
|
-
out, err =
|
52
|
+
out, err = if @env
|
53
|
+
Open3.capture3(@env, cli(cmd, oid, options))
|
54
|
+
else
|
55
|
+
Open3.capture3(cli(cmd, oid, options))
|
56
|
+
end
|
52
57
|
raise CommandError, err.chomp unless err.empty?
|
53
58
|
out
|
54
59
|
end
|
data/lib/snmp/open/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snmp-open
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|