snmpdumper 0.0.2 → 0.0.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/README +2 -1
- data/lib/{options.rb → config.rb} +4 -2
- data/lib/runner.rb +14 -8
- data/lib/snmpwalk_reader.rb +2 -2
- metadata +6 -25
    
        data/README
    CHANGED
    
    
| @@ -3,7 +3,7 @@ require 'ostruct' | |
| 3 3 | 
             
            require 'pp'
         | 
| 4 4 |  | 
| 5 5 | 
             
            module SnmpDumper
         | 
| 6 | 
            -
              class  | 
| 6 | 
            +
              class Config
         | 
| 7 7 | 
             
                SNMP_VERSIONS = {"1" => :SNMPv1, "2c" => :SNMPv2c, "3" => :SNMPv3}
         | 
| 8 8 | 
             
                DEFAULT_PORT = 161
         | 
| 9 9 |  | 
| @@ -181,6 +181,9 @@ module SnmpDumper | |
| 181 181 |  | 
| 182 182 | 
             
                    begin
         | 
| 183 183 | 
             
                      opts.parse!(argv)
         | 
| 184 | 
            +
                      
         | 
| 185 | 
            +
                      raise NotImplementedError.new("SNMPv3 not yet implemented by snmplib") if @options.version == :SNMPv3
         | 
| 186 | 
            +
                      
         | 
| 184 187 | 
             
                      raise OptionParser::MissingArgument.new("Please provide AUTH and PRIVACY passphrase") if 
         | 
| 185 188 | 
             
                      @options.version == :SNMPv3 && 
         | 
| 186 189 | 
             
                      (@options.auth_passphrase.nil? || @options.privacy_passphrase.nil?)
         | 
| @@ -197,7 +200,6 @@ module SnmpDumper | |
| 197 200 | 
             
                      exit(-1)
         | 
| 198 201 | 
             
                    end
         | 
| 199 202 |  | 
| 200 | 
            -
             | 
| 201 203 | 
             
                  end #OptionParser.new
         | 
| 202 204 |  | 
| 203 205 | 
             
                end #parse(argv)
         | 
    
        data/lib/runner.rb
    CHANGED
    
    | @@ -1,30 +1,36 @@ | |
| 1 1 | 
             
            require 'walker'
         | 
| 2 2 | 
             
            require 'snmpwalk_reader'
         | 
| 3 | 
            -
            require ' | 
| 3 | 
            +
            require 'config'
         | 
| 4 4 |  | 
| 5 5 | 
             
            Dir.glob(File.join(File.dirname(__FILE__), 'dumper/*.rb')).each {|f| require f }
         | 
| 6 6 |  | 
| 7 7 | 
             
            module SnmpDumper
         | 
| 8 8 | 
             
              class Runner
         | 
| 9 9 | 
             
                def initialize(argv)
         | 
| 10 | 
            -
                   | 
| 10 | 
            +
                  begin
         | 
| 11 | 
            +
                    @config = Config.new(argv)
         | 
| 12 | 
            +
                    rescue Exception => e
         | 
| 13 | 
            +
                      STDERR.puts e.message
         | 
| 14 | 
            +
                      STDERR.puts e.backtrace.join("\n") if $DEBUG
         | 
| 15 | 
            +
                      exit(-1)
         | 
| 16 | 
            +
                    end
         | 
| 11 17 | 
             
                end
         | 
| 12 18 |  | 
| 13 19 | 
             
                def run
         | 
| 14 20 | 
             
                  begin
         | 
| 15 21 | 
             
                    ## interactive shell?
         | 
| 16 | 
            -
                    if !$stdin.tty? || @ | 
| 17 | 
            -
                      walker = SnmpwalkReader.new(@ | 
| 22 | 
            +
                    if !$stdin.tty? || @config.options.in_filename then
         | 
| 23 | 
            +
                      walker = SnmpwalkReader.new(@config.options)
         | 
| 18 24 | 
             
                    else
         | 
| 19 | 
            -
                      walker = Walker.new(@ | 
| 25 | 
            +
                      walker = Walker.new(@config.options)
         | 
| 20 26 | 
             
                    end
         | 
| 21 27 |  | 
| 22 | 
            -
                    dumper = SnmpDumper.const_get(@ | 
| 28 | 
            +
                    dumper = SnmpDumper.const_get(@config.options.dumper)::new(@config.options)
         | 
| 23 29 |  | 
| 24 30 | 
             
                    walker.walk(dumper)
         | 
| 25 31 |  | 
| 26 | 
            -
                    if @ | 
| 27 | 
            -
                      File.open(@ | 
| 32 | 
            +
                    if @config.options.out_filename
         | 
| 33 | 
            +
                      File.open(@config.options.out_filename, 'w') { |f| f.write(dumper.dump) }  
         | 
| 28 34 | 
             
                    else
         | 
| 29 35 | 
             
                      puts dumper.dump
         | 
| 30 36 | 
             
                    end
         | 
    
        data/lib/snmpwalk_reader.rb
    CHANGED
    
    | @@ -17,7 +17,7 @@ module SnmpDumper | |
| 17 17 | 
             
                      raise value if Regexp.last_match(0).nil?
         | 
| 18 18 | 
             
                      SNMP::TimeTicks.new(Integer(Regexp.last_match(1)))
         | 
| 19 19 | 
             
                      }, "INTEGER" => lambda { |value|
         | 
| 20 | 
            -
                        /^(.*\()*(\d+) | 
| 20 | 
            +
                        /^(.*\()*(\d+).*$/ =~ value
         | 
| 21 21 | 
             
                        return nil if Regexp.last_match(0).nil?
         | 
| 22 22 | 
             
                        SNMP::Integer.new(Integer(Regexp.last_match(2)))
         | 
| 23 23 | 
             
                        },
         | 
| @@ -70,7 +70,7 @@ module SnmpDumper | |
| 70 70 | 
             
                      #{line}\n
         | 
| 71 71 | 
             
                      Format for input:\n
         | 
| 72 72 | 
             
                      <numerical oid> = <Type>: <value>\n
         | 
| 73 | 
            -
                      Example: .1.3.6.1.2.1.1.1.0 = STRING: Linux  | 
| 73 | 
            +
                      Example: .1.3.6.1.2.1.1.1.0 = STRING: Linux lom0.taa-edu.local 2.6.17.6 #1 SMP Thu Mar 8 15:32:13 CET 2007 i686\n
         | 
| 74 74 | 
             
                      snmpwalk command example: snmpwalk -v 3 -u user -A PW -X PW -a MD5 -x DES -l authPriv -On -Oa 192.168.1.1" unless @options.force
         | 
| 75 75 | 
             
                    end
         | 
| 76 76 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: snmpdumper
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Sebastian de Castelberg
         | 
| @@ -9,30 +9,11 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2010-01-22 00:00:00 +01:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 | 
            -
            dependencies: 
         | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
              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: 
         | 
| 25 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 26 | 
            -
              name: builder
         | 
| 27 | 
            -
              type: :runtime
         | 
| 28 | 
            -
              version_requirement: 
         | 
| 29 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 30 | 
            -
                requirements: 
         | 
| 31 | 
            -
                - - "="
         | 
| 32 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 33 | 
            -
                    version: 2.1.2
         | 
| 34 | 
            -
                version: 
         | 
| 35 | 
            -
            description: Dump snmp walks in various formats
         | 
| 14 | 
            +
            dependencies: []
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            description: ""
         | 
| 36 17 | 
             
            email: snmpdumper@kpricorn.org
         | 
| 37 18 | 
             
            executables: 
         | 
| 38 19 | 
             
            - snmpdumper
         | 
| @@ -44,9 +25,9 @@ files: | |
| 44 25 | 
             
            - README
         | 
| 45 26 | 
             
            - LICENSE
         | 
| 46 27 | 
             
            - bin/snmpdumper
         | 
| 28 | 
            +
            - lib/config.rb
         | 
| 47 29 | 
             
            - lib/dumper/jalasoft_dumper.rb
         | 
| 48 30 | 
             
            - lib/dumper/simple_text_dumper.rb
         | 
| 49 | 
            -
            - lib/options.rb
         | 
| 50 31 | 
             
            - lib/runner.rb
         | 
| 51 32 | 
             
            - lib/snmpwalk_reader.rb
         | 
| 52 33 | 
             
            - lib/walker.rb
         |