corona 0.1.1 → 0.2.0

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
- SHA1:
3
- metadata.gz: a6078953b980bf735927f7648f7795262bb935dd
4
- data.tar.gz: 7c92e76091180cd0d6cf9ba21e3cb69c4fa361ff
2
+ SHA256:
3
+ metadata.gz: 2d9958f5986616d7963e265e51f778b6cf4e2a9822594a7e76dfac83cac2e51b
4
+ data.tar.gz: 99e860c73a163ebd88da7a03dc218fb081662395a856318b3e6dcfbd4fb5692d
5
5
  SHA512:
6
- metadata.gz: cfb884daf5cea206fb068ff87990e5a81a890bea7576c117f40a9a227fedb9642cf73eee46862b1781ba0d8035d1acc9213e64008a214bb0f4c0bf7859f8fc06
7
- data.tar.gz: ea16309908cbe109be9e51c94c402722bff4165dd5541c77c4ae5172b5b92c9949eb6eb336bdbad77f4ec44ac29a07eb74a6f504fd0f3d52a626d37361191be0
6
+ metadata.gz: c17550ebabd3b8df53695fa5312316b49cf232caf6510bcee1cffd29446a16a522d75a7e68a2929d76bc2d8365a8557886312105f55c83f8dbc3005e3a6fcf04
7
+ data.tar.gz: e011e02ae3492638948f527d4422daba7187d557aed334d442f840b07c9712c87e49e5c0c4024a325f30869c5d5d5ec13e8f1a08be38556cf8d850031fa0008c
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ gems
data/CHANGELOG.md CHANGED
@@ -1,2 +1,32 @@
1
+ # 0.2.0
2
+ - move to use newer sequel gem
3
+ * this drops support for schema plugin
4
+ - refresh other dependencies as well
5
+
6
+ # 0.1.10
7
+ - FIX: check error_status from snmp_response and act based on that
8
+
9
+ # 0.1.9
10
+ - FEATURE: Aruba switch support (rebranded HP Procurve)
11
+
12
+ # 0.1.8
13
+ - FEATURE: Huawei MA5800 support (HIAS)
14
+ - FIX: SSR's sysObjectID was changed in IPOS-16.1.1.8.29
15
+
16
+ # 0.1.7
17
+ - bugfix
18
+
19
+ # 0.1.6
20
+ - FIX: match older SSRs as well
21
+
22
+ # 0.1.5
23
+ - FEATURE: Ericsson SSR support
24
+
25
+ # 0.1.2
26
+ - FEATURE: Alcatel ISAM support
27
+ - FEATURE: Huawei VRP support
28
+ - FEATURE: Extreme XOS support
29
+ - FEATURE: Brocade NOS support
30
+
1
31
  # 0.1.1
2
- - fix incorrect hash assingment for results
32
+ - FIX incorrect hash assingment for results
data/Gemfile.lock CHANGED
@@ -1,25 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- corona (0.0.12)
5
- asetus
6
- sequel
7
- slop
8
- snmp
9
- sqlite3
4
+ corona (0.2.0)
5
+ asetus (~> 0.3)
6
+ sequel (~> 5.10)
7
+ slop (~> 3.6)
8
+ snmp (~> 1.2)
9
+ sqlite3 (~> 1.4)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- asetus (0.0.7)
15
- slop
16
- sequel (4.9.0)
17
- slop (3.5.0)
18
- snmp (1.1.1)
19
- sqlite3 (1.3.9)
14
+ asetus (0.3.0)
15
+ sequel (5.24.0)
16
+ slop (3.6.0)
17
+ snmp (1.3.2)
18
+ sqlite3 (1.4.1)
20
19
 
21
20
  PLATFORMS
22
21
  ruby
23
22
 
24
23
  DEPENDENCIES
25
24
  corona!
25
+
26
+ BUNDLED WITH
27
+ 2.0.2
data/TODO.md CHANGED
@@ -1,6 +1,2 @@
1
- # CLI options
2
- * option to purge old device
3
- * instead of _sqlite corona.db "delete from device where last_seen < datetime('now', '-7days')"
4
-
5
1
  # Core#process
6
2
  * maybe it can be made cleaner/smarter
data/bin/corona CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require 'corona/cli'
4
+ require_relative '../lib/corona/cli'
5
5
  Corona::CLI.new.run
6
6
  rescue => error
7
7
  warn "#{error}"
data/corona.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'corona'
3
- s.version = '0.1.1'
4
- s.licenses = ['Apache-2.0']
3
+ s.version = '0.2.0'
4
+ s.licenses = %w( 'Apache-2.0' )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti' ]
7
7
  s.email = %w( saku@ytti.fi )
@@ -13,9 +13,9 @@ Gem::Specification.new do |s|
13
13
  s.executables = %w( corona )
14
14
  s.require_path = 'lib'
15
15
 
16
- s.add_dependency 'sequel', '~> 4.12'
17
- s.add_dependency 'sqlite3', '~> 1.3'
18
- s.add_dependency 'snmp', '~> 1.2'
19
- s.add_dependency 'slop', '~> 3.5'
20
- s.add_dependency 'asetus', '~> 0.1'
16
+ s.add_runtime_dependency 'sequel', '~> 5.10'
17
+ s.add_runtime_dependency 'sqlite3', '~> 1.4'
18
+ s.add_runtime_dependency 'snmp', '~> 1.2'
19
+ s.add_runtime_dependency 'slop', '~> 3.6'
20
+ s.add_runtime_dependency 'asetus', '~> 0.3'
21
21
  end
data/lib/corona/cli.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module Corona
2
2
  class CLI
3
3
  MAX_DELETE = 1
4
- require 'corona'
4
+ gem 'slop', "=3.6.0"
5
5
  require 'slop'
6
+ require_relative '../corona'
6
7
  class NoConfig < CoronaError; end
7
8
 
8
9
  def run
data/lib/corona/core.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'corona/log'
2
- require 'corona/config'
3
- require 'corona/snmp'
4
- require 'corona/db/db'
5
- require 'corona/model'
1
+ require_relative 'log'
2
+ require_relative 'config'
3
+ require_relative 'snmp'
4
+ require_relative 'db/db'
5
+ require_relative 'model'
6
6
  require 'ipaddr'
7
7
  require 'resolv'
8
8
 
@@ -56,6 +56,7 @@ module Corona
56
56
  snmp = SNMP.new ip.to_s, @community
57
57
  oids = snmp.dbget
58
58
  if oids
59
+ return nil if oids[:sysDescr] == ::SNMP::NoSuchObject
59
60
  result = {:oids=>oids, :ip=>ip, :int=>'n/a'}
60
61
  if index = snmp.ip2index(ip.to_s)
61
62
  if int = snmp.ifdescr(index)
data/lib/corona/db/db.rb CHANGED
@@ -3,8 +3,8 @@ module Corona
3
3
  require 'sequel'
4
4
  require 'sqlite3'
5
5
  def initialize
6
- Sequel::Model.plugin :schema
7
6
  @db = Sequel.sqlite(CFG.db, :max_connections => 1, :pool_timeout => 60)
7
+ create_table #unless @db.table_exists?(:devices)
8
8
  require_relative 'model'
9
9
  end
10
10
 
@@ -27,5 +27,25 @@ module Corona
27
27
  sysName = Device[:oid_sysName => oid_sysName]
28
28
  [ip, sysName]
29
29
  end
30
+
31
+ private
32
+
33
+ def create_table
34
+ @db.create_table? :devices do
35
+ primary_key :id
36
+ String :ip
37
+ String :ptr
38
+ String :model
39
+ String :oid_ifDescr
40
+ Boolean :active
41
+ Time :first_seen
42
+ Time :last_seen
43
+ String :oid_sysName
44
+ String :oid_sysLocation
45
+ String :oid_sysDescr
46
+ String :oid_sysObjectID
47
+ end
48
+ end
49
+
30
50
  end
31
51
  end
@@ -1,21 +1,6 @@
1
1
  module Corona
2
2
  class DB
3
3
  class Device < Sequel::Model
4
- set_schema do
5
- primary_key :id
6
- String :ip
7
- String :ptr
8
- String :model
9
- String :oid_ifDescr
10
- Boolean :active
11
- Time :first_seen
12
- Time :last_seen
13
- String :oid_sysName
14
- String :oid_sysLocation
15
- String :oid_sysDescr
16
- String :oid_sysObjectID
17
- end
18
- create_table unless table_exists?
19
4
  end
20
5
  end
21
6
  end
data/lib/corona/model.rb CHANGED
@@ -18,14 +18,20 @@ module Corona
18
18
  'ironware'
19
19
  when /TiMOS/
20
20
  'timos'
21
+ when /ExtremeXOS/
22
+ 'xos'
21
23
  when /Cisco Adaptive Security Appliance/
22
24
  'asa'
23
25
  when /Brocade Fibre Channel Switch/
24
26
  'fabricos'
27
+ when /Brocade VDX/
28
+ 'nos'
25
29
  when /cisco/i, /Application Control Engine/i
26
30
  'ios'
27
31
  when /Force10 OS/
28
32
  'ftos'
33
+ when /Versatile Routing Platform/
34
+ 'vrp'
29
35
  when /^NetScreen/, /^SSG-\d+/
30
36
  'screenos'
31
37
  when /^Summit/
@@ -40,8 +46,14 @@ module Corona
40
46
  'acos'
41
47
  when /ProCurve/ # ProCurve OS does not seem to have name?
42
48
  'procurve'
49
+ when /ASAM/
50
+ 'isam'
43
51
  when /^\d+[A-Z]\sEthernet Switch$/
44
52
  'powerconnect'
53
+ when /Ericsson IPOS/
54
+ 'ssr'
55
+ when /Huawei Integrated Access Software/
56
+ 'hias'
45
57
  else
46
58
  case sysObjectID
47
59
  when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.12356.'))
@@ -58,8 +70,28 @@ module Corona
58
70
  'powerconnect' # 1.3.6.1.4.1.674.10895.3031
59
71
  when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.22610.'))
60
72
  'acos' # 1.3.6.1.4.1.22610.1.3.14
73
+ when Regexp.new('^' + Regexp.quote('.1.3.6.1.4.1.637.'))
74
+ 'isam' # 1.3.6.1.4.1.637.61.1
75
+ when Regexp.new('^' + Regexp.quote('.1.3.6.1.4.1.2011.'))
76
+ 'vrp' # 1.3.6.1.4.1.2011.2.224.67 (AR1220F)
77
+ when Regexp.new('^' + Regexp.quote('.1.3.6.1.4.1.1588.'))
78
+ 'nos' # 1.3.6.1.4.1.1588.2.2.1.1.1.5 (VDX)
79
+ when Regexp.new('^' + Regexp.quote('.1.3.6.1.4.1.1916.'))
80
+ 'xos' # 1.3.6.1.4.1.1916.2.76 (X450a-48t)
61
81
  when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.9.1.745'))
62
82
  'asa' # 1.3.6.1.4.1.9.1.745
83
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.20858.2.600'))
84
+ 'casa' # 1.3.6.1.4.1.20858.2.600
85
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.2011.2.169'))
86
+ 'hias' # 1.3.6.1.4.1.2011.2.169
87
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.2011.2.300'))
88
+ 'hias' # 1.3.6.1.4.1.2011.2.300 (MA5800 OLT)
89
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.2352.1'))
90
+ 'ssr' # 1.3.6.1.4.1.2352.1.17 and .18
91
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.193.218.1'))
92
+ 'ssr' # 1.3.6.1.4.1.193.218.1.17 and .18
93
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.11.2.3.7.11'))
94
+ 'procurve' # Aruba switches are really HP Procurve
63
95
  else
64
96
  'unsupported'
65
97
  end
data/lib/corona/snmp.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Corona
2
2
  class SNMP
3
+ class InvalidResponse < StandardError; end
3
4
  DB_OID = {
4
5
  :sysDescr => '1.3.6.1.2.1.1.1.0',
5
6
  :sysObjectID => '1.3.6.1.2.1.1.2.0',
@@ -35,7 +36,9 @@ module Corona
35
36
  def mget oids=DB_OID
36
37
  result = {}
37
38
  begin
38
- @snmp.get(oids.map{|_,oid|oid}).each_varbind do |vb|
39
+ res = @snmp.get(oids.map{|_,oid|oid})
40
+ raise InvalidResponse, "#{res.error_status} from #{@snmp.config[:host]}" unless res.error_status == :noError
41
+ res.each_varbind do |vb|
39
42
  oids.each do |name,oid|
40
43
  if vb.name.to_str == oid
41
44
  result[name] = vb.value
@@ -45,6 +48,8 @@ module Corona
45
48
  end
46
49
  rescue ::SNMP::RequestTimeout, Errno::EACCES
47
50
  return false
51
+ rescue InvalidResponse => e
52
+ return false
48
53
  end
49
54
  result
50
55
  end
data/lib/corona.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Corona
2
2
  class CoronaError < StandardError; end
3
- require 'corona/core'
3
+ require_relative 'corona/core'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saku Ytti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.12'
19
+ version: '5.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.12'
26
+ version: '5.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '1.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: snmp
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.5'
61
+ version: '3.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.5'
68
+ version: '3.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: asetus
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.1'
75
+ version: '0.3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.1'
82
+ version: '0.3'
83
83
  description: Threaded SNMP poll based network discovery. Devices are stored in SQL
84
84
  email:
85
85
  - saku@ytti.fi
@@ -88,6 +88,7 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".gitignore"
91
92
  - ".rspec"
92
93
  - CHANGELOG.md
93
94
  - Gemfile
@@ -108,7 +109,7 @@ files:
108
109
  - lib/corona/snmp.rb
109
110
  homepage: http://github.com/ytti/corona
110
111
  licenses:
111
- - Apache-2.0
112
+ - "'Apache-2.0'"
112
113
  metadata: {}
113
114
  post_install_message:
114
115
  rdoc_options: []
@@ -125,8 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  - !ruby/object:Gem::Version
126
127
  version: '0'
127
128
  requirements: []
128
- rubyforge_project: corona
129
- rubygems_version: 2.2.2
129
+ rubygems_version: 3.0.3.1
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: device discovery via snmp polls