arpdb 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb885013b5a04ca2912a9ad3258f9e6bb328f9f7
4
- data.tar.gz: 31de24183490c2065f51ff1afab4a10200c64f96
3
+ metadata.gz: 53646bc60980e1ce48e0786b20f190246279483e
4
+ data.tar.gz: 71eedb4dbf2ec67ea029c60f63e482849cddfb79
5
5
  SHA512:
6
- metadata.gz: f9294f9a98b874aba5885ae42a851ff70c749ea2791d8b55377f5ccf98a28f6efe4b4d6e7b6339022b0545c72b955abfaf883de1b59fd81d85fc07d254dcba65
7
- data.tar.gz: 5e6b4bfb330950762a47c45b2c968f2fc53e14c53a460a3c7573ae6758e4445333f4156b77512936047da716ab2a833cf8c4628ceedbf4a92482f7336821da22
6
+ metadata.gz: 8b1eb1491c7b49ad666a44c6562d69ebf44e366ac6d4cb0ec1daffaeba1af267eb6ee82d2b0c0fdc8c20fc933b999c398ac0ce18f68549d060e8a0091f5ff25a
7
+ data.tar.gz: 677aa71fc85228140e06d624065973872019e9755d4ac28877fea247ffa0212315a7c2fb0b5f3a5a77c1fa469818a595a4c12644cd40e51f7f3f0faaf2d13793
@@ -14,7 +14,7 @@ module Arpdb
14
14
  # Arpdb::SNMPTransport or array of those. This way we can easily pass
15
15
  # mocked SNMPTransport here for off-the-hook testing.
16
16
  def initialize(snmp_transports)
17
- snmp_transports.is_a?(Array) ? @snmp_transports = snmp_transports : @snmp_transports = [snmp_transports]
17
+ @snmp_transports = Array(snmp_transports)
18
18
  @db = Array.new
19
19
  end
20
20
 
@@ -23,16 +23,26 @@ module Arpdb
23
23
  end
24
24
 
25
25
  def scan
26
+ sys_location = '1.3.6.1.2.1.1.6.0'
27
+ ip_net_to_media_phys_address = '1.3.6.1.2.1.4.22.1.2'
28
+ ip_net_to_media_net_address = '1.3.6.1.2.1.4.22.1.3'
29
+ @db = Array.new
26
30
  handle_exceptions do
31
+ dirty = false
27
32
  snmp_transports.each do |st|
28
- location = st.get('1.3.6.1.2.1.1.6.0')
29
-
30
- st.walk(%w(1.3.6.1.2.1.4.22.1.2 1.3.6.1.2.1.4.22.1.3)).each do |row|
31
- @db << {mac: row.first, ip: row.last, host: st.host, location: location}
33
+ begin
34
+ st.walk([ip_net_to_media_phys_address, ip_net_to_media_net_address]).each do |mac, ip|
35
+ @db << {mac: mac, ip: ip, host: st.host, location: st.get(sys_location)}
36
+ end
37
+ rescue => e
38
+ dirty = true
39
+ msgs ||= []
40
+ msgs << "SNMPTransport error while scanning #{st.host}; moving to next host (if any)"
41
+ next
32
42
  end
33
43
  end
44
+ raise msgs.join("; ") if dirty
34
45
  end
35
-
36
46
  self
37
47
  end
38
48
 
@@ -75,4 +85,4 @@ module Arpdb
75
85
  end
76
86
 
77
87
  end
78
- end
88
+ end
@@ -1,3 +1,3 @@
1
1
  module Arpdb
2
- VERSION = "0.2.2"
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arpdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.K.Valk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-20 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler