corona 0.1.2 → 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: a58477906743f5fac988279012b93487a41bab83
4
- data.tar.gz: 0b29989d94860c8dc7ad9115af8ca054dee38866
2
+ SHA256:
3
+ metadata.gz: 2d9958f5986616d7963e265e51f778b6cf4e2a9822594a7e76dfac83cac2e51b
4
+ data.tar.gz: 99e860c73a163ebd88da7a03dc218fb081662395a856318b3e6dcfbd4fb5692d
5
5
  SHA512:
6
- metadata.gz: 3de9ea50f8b4df65e3690219c6ac078c9ee2ab3af19286dda0ab0593b4f5a85790b371aaa95233723acdb61e2811dbd8bf3926249293bc836675be0e056df8cc
7
- data.tar.gz: 78c5edd96e99b229212fd02b2c783251d5045be295d7db0ed5d2a846c89af575a5360ef6417ad5063093320acc3bbfc1666b168b2e112201af7c09690ab1d716
6
+ metadata.gz: c17550ebabd3b8df53695fa5312316b49cf232caf6510bcee1cffd29446a16a522d75a7e68a2929d76bc2d8365a8557886312105f55c83f8dbc3005e3a6fcf04
7
+ data.tar.gz: e011e02ae3492638948f527d4422daba7187d557aed334d442f840b07c9712c87e49e5c0c4024a325f30869c5d5d5ec13e8f1a08be38556cf8d850031fa0008c
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ gems
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
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
+
1
25
  # 0.1.2
2
26
  - FEATURE: Alcatel ISAM support
3
27
  - FEATURE: Huawei VRP support
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/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,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'corona'
3
- s.version = '0.1.2'
3
+ s.version = '0.2.0'
4
4
  s.licenses = %w( 'Apache-2.0' )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti' ]
@@ -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_runtime_dependency 'sequel', '~> 4.12'
17
- s.add_runtime_dependency 'sqlite3', '~> 1.3'
16
+ s.add_runtime_dependency 'sequel', '~> 5.10'
17
+ s.add_runtime_dependency 'sqlite3', '~> 1.4'
18
18
  s.add_runtime_dependency 'snmp', '~> 1.2'
19
- s.add_runtime_dependency 'slop', '~> 3.5'
20
- s.add_runtime_dependency 'asetus', '~> 0.1'
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
@@ -50,6 +50,10 @@ module Corona
50
50
  'isam'
51
51
  when /^\d+[A-Z]\sEthernet Switch$/
52
52
  'powerconnect'
53
+ when /Ericsson IPOS/
54
+ 'ssr'
55
+ when /Huawei Integrated Access Software/
56
+ 'hias'
53
57
  else
54
58
  case sysObjectID
55
59
  when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.12356.'))
@@ -76,6 +80,18 @@ module Corona
76
80
  'xos' # 1.3.6.1.4.1.1916.2.76 (X450a-48t)
77
81
  when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.9.1.745'))
78
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
79
95
  else
80
96
  'unsupported'
81
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.2
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: 2015-02-05 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
@@ -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