copian 1.3.2 → 1.3.3

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.
data/.gitignore CHANGED
@@ -1,5 +1,18 @@
1
- *.sw?
2
- .DS_Store
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
3
9
  coverage
10
+ doc/
11
+ lib/bundler/man
4
12
  pkg
5
13
  rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in copian.gemspec
4
+ gemspec
@@ -22,7 +22,7 @@ Collecting the status of all the network interfaces on a Cisco Router
22
22
  # Port 1/e1 is 1 @ 100000000. mtu(1500)
23
23
  # ...
24
24
 
25
- presently the admin_status and oper_status are not interpreted, but equate to
25
+ presently the +admin_status+ and +oper_status+ are not interpreted, but equate to
26
26
 
27
27
  1. up
28
28
  2. down
@@ -30,6 +30,11 @@ presently the admin_status and oper_status are not interpreted, but equate to
30
30
 
31
31
  == History
32
32
 
33
+ === 1.3.3 - 2012/02/20
34
+
35
+ - 1 major enhancement
36
+ - Add interface description collector
37
+
33
38
  === 1.3.2 - 2009/10/06
34
39
 
35
40
  - 1 major correction
data/Rakefile CHANGED
@@ -1,45 +1,2 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |s|
8
- s.name = "copian"
9
- s.summary = %Q{Suite of SNMP collectors for different types of network devices}
10
- s.email = "geoff@geoffgarside.co.uk"
11
- s.homepage = "http://github.com/geoffgarside/copian"
12
- s.description = "Suite of SNMP collectors for different types of network devices"
13
- s.authors = ["Geoff Garside"]
14
- s.add_dependency('snmp', '>= 1.0.2')
15
- end
16
- rescue LoadError
17
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
- end
19
-
20
- Rake::TestTask.new do |t|
21
- t.libs << 'lib'
22
- t.pattern = 'test/**/*_test.rb'
23
- t.verbose = false
24
- end
25
-
26
- Rake::RDocTask.new do |rdoc|
27
- rdoc.rdoc_dir = 'rdoc'
28
- rdoc.title = 'copian'
29
- rdoc.options << '--line-numbers' << '--inline-source'
30
- rdoc.rdoc_files.include('README*')
31
- rdoc.rdoc_files.include('LICENSE')
32
- rdoc.rdoc_files.include('lib/**/*.rb')
33
- end
34
-
35
- begin
36
- require 'rcov/rcovtask'
37
- Rcov::RcovTask.new do |t|
38
- t.libs << 'test'
39
- t.test_files = FileList['test/**/*_test.rb']
40
- t.verbose = true
41
- end
42
- rescue LoadError
43
- end
44
-
45
- task :default => :test
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/copian/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Geoff Garside"]
6
+ gem.email = ["geoff@geoffgarside.co.uk"]
7
+ gem.description = %q{Suite of SNMP collectors for different types of network devices}
8
+ gem.summary = %q{SNMP Information statistics}
9
+ gem.homepage = "http://github.com/geoffgarside/copian"
10
+
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "copian"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Copian::VERSION
16
+
17
+ gem.add_dependency "snmp", ">= 1.0.4"
18
+ end
@@ -1,3 +1,6 @@
1
+ require 'snmp'
2
+
3
+ require 'copian/version'
1
4
  require 'copian/collector/abstract_collector'
2
5
  require 'copian/collector/addresses_collector'
3
6
  require 'copian/collector/bandwidth_collector'
@@ -9,8 +12,6 @@ require 'copian/collector/cisco'
9
12
  require 'copian/collector/dell'
10
13
  require 'copian/collector/hp'
11
14
 
12
- require 'snmp'
13
-
14
15
  # :stopdoc:
15
16
  class SNMP::Manager
16
17
  attr_reader :host, :community, :version
@@ -1,8 +1,12 @@
1
1
  module Copian
2
2
  module Collector
3
3
  class CiscoAddressesCollector < AddressesCollector # :nodoc:
4
+ IpNetToMediaPhysAddress = SNMP::ObjectId.new('1.3.6.1.2.1.4.22.1.2') # IPv4 only
5
+ IpNetToPhysicalPhysAddresss = SNMP::ObjectId.new('1.3.6.1.2.1.4.35.1.4') # IP version agnostic
6
+
4
7
  def collect
5
- oid = SNMP::ObjectId.new('1.3.6.1.2.1.4.22.1.2')
8
+ oid = IpNetToMediaPhysAddress
9
+
6
10
  @manager.walk(oid) do |r|
7
11
  r.each do |varbind|
8
12
  mac_addr = value_to_mac_address(varbind.value)
@@ -15,6 +19,30 @@ module Copian
15
19
  yield mac.dup, ips if block_given?
16
20
  end
17
21
  end
22
+ protected
23
+ def name_to_ip_address(name, oid)
24
+ if oid == IpNetToMediaPhysAddress
25
+ # Strip off the parent and IDX oid
26
+ # the rest is an IPv4 address
27
+ name.index(oid)[1..-1].to_s
28
+ elsif oid == IpNetToPhysicalPhysAddresss
29
+ # Strip off the parent and IDX oid
30
+ sub = name.index(oid)[1..-1]
31
+ family = sub.shift
32
+ addrlen = sub.shift
33
+
34
+ case family
35
+ when 1 # IPv4
36
+ sub[0..addrlen].to_s
37
+ when 2 # IPv6
38
+ sub[0..addrlen].map do |i|
39
+ "%02x" % i.to_i
40
+ end.join.split(/([a-f0-9]{4})/).reject do |i|
41
+ i == ""
42
+ end.join(":")
43
+ end
44
+ end
45
+ end
18
46
  end
19
47
  end
20
48
  end
@@ -19,9 +19,9 @@ module Copian
19
19
  private
20
20
  def each_vlan
21
21
  @vlans_collector.collect do |vlan_id, vlan_index|
22
- yield SNMP::Manager.new(:Host => @manager.host,
23
- :Version => @manager.version,
24
- :Community => "#{@manager.community}@#{vlan_id}")
22
+ yield SNMP::Manager.new(:host => @manager.host,
23
+ :version => @manager.version,
24
+ :community => "#{@manager.community}@#{vlan_id}")
25
25
  end
26
26
  end
27
27
  def gather_mac_bridge_ports(manager)
@@ -5,8 +5,8 @@ module Copian
5
5
  "#<#{self.class} #{@manager.host}@#{@manager.community}>"
6
6
  end
7
7
  def initialize(ip_addr, community, version = :SNMPv2c)
8
- @manager = SNMP::Manager.new(:Host => ip_addr,
9
- :Community => community, :Version => version)
8
+ @manager = SNMP::Manager.new(:host => ip_addr,
9
+ :community => community, :version => version)
10
10
  end
11
11
  def port_stats # :yields: ifindex, name, mtu, speed, admin_status, oper_status
12
12
  load_ifnames
@@ -23,7 +23,7 @@ module Copian
23
23
  #
24
24
  # Valid Options
25
25
  # +:b64+ :Set to true to enable b64 bandwidth collection. Default false.
26
- def bandwidth(options = {}) # :yields: ifindex, inoctets, outoctets
26
+ def bandwidth(options = {}) # :yields: ifindex, ifname, inoctets, outoctets
27
27
  load_ifnames
28
28
 
29
29
  collect_method = options[:b64] == true ? :collect64 : :collect
@@ -0,0 +1,3 @@
1
+ module Copian
2
+ VERSION = "1.3.3"
3
+ end
metadata CHANGED
@@ -1,47 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: copian
3
- version: !ruby/object:Gem::Version
4
- version: 1.3.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.3
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Geoff Garside
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-10-06 00:00:00 +01:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: snmp
16
+ requirement: &70195160173080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.4
17
22
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.0.2
24
- version:
23
+ prerelease: false
24
+ version_requirements: *70195160173080
25
25
  description: Suite of SNMP collectors for different types of network devices
26
- email: geoff@geoffgarside.co.uk
26
+ email:
27
+ - geoff@geoffgarside.co.uk
27
28
  executables: []
28
-
29
29
  extensions: []
30
-
31
- extra_rdoc_files:
32
- - LICENSE
33
- - README
34
- files:
30
+ extra_rdoc_files: []
31
+ files:
35
32
  - .gitignore
33
+ - Gemfile
36
34
  - LICENSE
37
- - README
35
+ - README.rdoc
38
36
  - Rakefile
39
- - VERSION.yml
37
+ - copian.gemspec
40
38
  - lib/copian.rb
41
39
  - lib/copian/collector/abstract_collector.rb
42
40
  - lib/copian/collector/addresses_collector.rb
43
41
  - lib/copian/collector/bandwidth_collector.rb
44
- - lib/copian/collector/description_collector.rb
45
42
  - lib/copian/collector/cisco.rb
46
43
  - lib/copian/collector/cisco/addresses.rb
47
44
  - lib/copian/collector/cisco/ports.rb
@@ -49,42 +46,46 @@ files:
49
46
  - lib/copian/collector/dell.rb
50
47
  - lib/copian/collector/dell/ports.rb
51
48
  - lib/copian/collector/dell/vlans.rb
49
+ - lib/copian/collector/description_collector.rb
52
50
  - lib/copian/collector/generic.rb
53
51
  - lib/copian/collector/hp.rb
54
52
  - lib/copian/collector/hp/ports.rb
55
53
  - lib/copian/collector/hp/vlans.rb
56
54
  - lib/copian/collector/port_stats_collector.rb
57
55
  - lib/copian/collector/ports_collector.rb
56
+ - lib/copian/version.rb
58
57
  - test/copian_test.rb
59
58
  - test/test_helper.rb
60
- has_rdoc: true
61
59
  homepage: http://github.com/geoffgarside/copian
62
60
  licenses: []
63
-
64
61
  post_install_message:
65
- rdoc_options:
66
- - --charset=UTF-8
67
- require_paths:
62
+ rdoc_options: []
63
+ require_paths:
68
64
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: "0"
74
- version:
75
- required_rubygems_version: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
80
- version:
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ segments:
72
+ - 0
73
+ hash: -1816480518592960478
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ segments:
81
+ - 0
82
+ hash: -1816480518592960478
81
83
  requirements: []
82
-
83
84
  rubyforge_project:
84
- rubygems_version: 1.3.5
85
+ rubygems_version: 1.8.11
85
86
  signing_key:
86
87
  specification_version: 3
87
- summary: Suite of SNMP collectors for different types of network devices
88
- test_files:
88
+ summary: SNMP Information statistics
89
+ test_files:
89
90
  - test/copian_test.rb
90
91
  - test/test_helper.rb
@@ -1,4 +0,0 @@
1
- ---
2
- :major: 1
3
- :minor: 3
4
- :patch: 2