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 +4 -4
- data/lib/arpdb/arp.rb +17 -7
- data/lib/arpdb/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: 53646bc60980e1ce48e0786b20f190246279483e
|
4
|
+
data.tar.gz: 71eedb4dbf2ec67ea029c60f63e482849cddfb79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b1eb1491c7b49ad666a44c6562d69ebf44e366ac6d4cb0ec1daffaeba1af267eb6ee82d2b0c0fdc8c20fc933b999c398ac0ce18f68549d060e8a0091f5ff25a
|
7
|
+
data.tar.gz: 677aa71fc85228140e06d624065973872019e9755d4ac28877fea247ffa0212315a7c2fb0b5f3a5a77c1fa469818a595a4c12644cd40e51f7f3f0faaf2d13793
|
data/lib/arpdb/arp.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
data/lib/arpdb/version.rb
CHANGED
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.
|
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:
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|