netdisco

Given snmp community and single device, discover the network via discovering LLDP/CDP neighbours, while producing list or dot file (for graphviz digraphs)

Install

% gem install netdisco

Use

% netdisco --graphiz router.example.com

Command line

Usage: netdisco [options] hostname
    -g, --graphviz       dot output use 'dot -Tpng -o map.png map.dot'
    -l, --list           list nodes
    -j, --json           json output
    -y, --yaml           yaml output
    -a, --hash           hash/associative array output
    -r, --resolve        resolve addresses to names
    -p, --purge          remove peers not in configured CIDR
    -c, --community      SNMP community to use
    -d, --debug          turn debugging on
    -h, --help           Display this help message.

  • graphiz - graphis (dot) output
  • list - list nodes found
  • json - json output
  • yaml - yaml output
  • hash - ruby hash output
  • resolve - resolve IP addresses
  • purge - remove non-cidr matching peers from output
  • community - sets snmp community
  • debug - turn on debugging

Config

---
use:
  - LLDP
  - CDP
poll:
  - 192.0.2.0/24
snmp:
  community: public
  timeout: 1
  retries: 2
  bulkrows: 35
dot:
  bothlinks: true
  color:
    - - cpe
      - gold
    - - -sw
      - blue
    - - -pe
      - red
    - - ' -p'
      - yellow
dns:
  afi:
log: STDERR
debug: false
namemap:
  - - -re\d+
    - ''
  - - (.*(?<!as23456.net)$)
    - \1.as23456.net
  • use - methods to use for crawling
  • poll - cidrs to allow snmp for
  • snmp community - snmp community to use
  • snmp timout - snmp timout in seconds
  • snmp retries - snmp retries count
  • snmp bulkrows - snmp row count for bulkget
  • dot bothlinks - show a-b and b-a link
  • dot color - regexp to color, first hit used
  • dns afi - ipv4/ipv6 or nil
  • log - STDERR/STDOUT or file
  • debug - debugging
  • namemap - map (LLDP) name to FQDN (JunOS does not give domain)

Library use

require 'netdisco' output = netdisco.new.discover('192.0.2.1').to_hash

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ciscolive/netdisco-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Netdisco project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.