snob
= snob :description: Snob Network Object Browser :fontawesome-ref: http://fontawesome.github.io/Font-Awesome
{description}
== Introduction
This utility is experimental, it will change radically as I learn more of the Crystal language, so use at your own risk! There will be warts!
Please, see the <
snob is a rewrite of one of my Ruby apps in the Crystal programming language. It's basically a wrapper around snmpwalk. The idea is to:
- have a somewhat easily distributable utility for probing network devices using snmpV3
- share this utility with colleagues without them having to install some development environment
- build fast performing apps
- learn Crystal while leveraging my Ruby experience
- have fun:)
This utility is written specifically for snmp version 3 because of its security features. Backwards compatibility to version 2c is not included at this time. Sorry:(.
The special --list switch is included to provide easily remembered names for 1.0.8802.1.1.2.1.4.1.1.9 or ipNetToPhysicalPhysAddress or other cryptic looking oids.
The output is raw by default. In addition, a --dump option is included for dumping the resulting output to a file, raw_dump.txt, for later perusal. A --format option exists in an attempt to pretty-print the output for display on screen. The --only-values flag allows output to be used raw by another application like RRDTool for graphing trends when you know which OID you want.
== Installation This covers Ubuntu (14 - 22). See notes below for other distros.
=== Required Required utilities for nms (network management station):
- git
- Install Crystal from the website, crystal-lang, to build the utility from source.
- snmp
- libsnmp-dev
- snmp-mibs-downloader
=== Snmp configuration There is an excellant write up on snmp by Justin Ellingwood and Vadym Kalsin on the https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-an-snmp-daemon-and-client-on-ubuntu-18-04[DigitalOcean website] . They show how to configure a server and clients.
You need the snmp-mibs-downloader so you can refer to mibs by colorful names like system instead of 1.3.6.1.... There is an entry in /etc/snmp/snmp.conf on some Debian-based systems that prevents that from happening. Comment out the line that contains mibs: [source,text]
As the snmp packages come without MIB files due to license reasons, loading
of MIBs is disabled by default. If you added the MIBs you can reenable
loading them by commenting out the following line.
mibs :
=== Preferred Installation A script, install.sh, is included to manage the installation process. It allows for installation of a pre compiled binary or building from source. It also allows for upgrading and uninstalling. Installation on RaspberryPi devices and RedHat/CentOS systems is done by linking included object files. All included documentation is installed in /usr/local/share.
Check out install.sh to see what the script is doing.
[source,bash]
$ git clone https://github.com/lebogan/snob.git $ cd snob $ ./install.sh
=== Manual Installation (if you gotta!) Note: not for Raspberry Pi! A Makefile is included for compiling and installing the binary and man pages. Crystal is required to be preinstalled. The binary is copied to /usr/local/bin. The Makefile also provides for uninstalling and compliation cleanup. The compiled binary is in ./bin. Make also builds and installs man pages as necessary to /usr/local/share. AsciiDoctor was used to build the documentation.
[source,bash]
$ git clone https://github.com/lebogan/snob.git $ cd snob $ shards install $ make clean $ make help $ make prod $ sudo make install
==== RPM-based (RedHat) and other distributions
The source will have to be recompiled with Crystal. + From the website, https://crystal-lang.org/install/[crystal-lang] + Install snmp-utils + See <
>
==== Deb-based (Debian, Ubuntu, Mint) and others
Install Crystal https://crystal-lang.org/install/[crystal-lang] + Install git and curl + Install libyaml-dev + Install apt-transport-https, dirmngr + For snmp, add to file: /etc/apt/sources.list + [source,text]
deb http://ftp.br.debian.org/debian/ wheezy main contrib non-free deb-src http://ftp.br.debian.org/debian/ wheezy main contrib non-free
See <
>
== Usage
$ snob --help Usage: snob [OPTIONS] [HOST] Browse a host's snmpv3 mib tree.
Prompts for HOST if not specified on the command-line. Also, prompts for security credentials if HOST is not in the config file, snobrc.yml.
Options: -l, --list List some pre-defined OIDs -m OID, --mib=OID Display information for this oid (Default: system) -d, --dump Write output to file, raw only by default -e, --edit Edit global config file -f, --formatted Display as formatted table -o, --only-values Display values only (not OID = value)
General options: -h, --help Show this help -v, --version Show version
$ snob --list
OIDS - Included pre-defined flag names
flag name |oid name =================+================================================= arp |ipNetToPhysicalPhysAddress -----------------+------------------------------------------------- lldp |1.0.8802.1.1.2.1.4.1.1.9 -----------------+------------------------------------------------- sys |system -----------------+------------------------------------------------- mem |memory -----------------+------------------------------------------------- dsk |dskTable -----------------+------------------------------------------------- ifdesc |ifDescr -----------------+------------------------------------------------- distro |ucdavis.7890.1.4 -----------------+------------------------------------------------- temp |lmTempSensorsDevice -----------------+-------------------------------------------------
== Config file A first run will create a default YAML config file named .snob/snobrc.yml if it doesn't already exist. The directory's permissions are set to 0o700 (drwx------) for added security. The initial set of credentials is for a host named dummy. Afterwards, if the host is not in the config file, you will be asked to enter credentials manually with the option to save them.
[source,bash]
$ snob myserver Config file doesn't exist. Create it(Y/n)? <Default: Yes> 'myserver' is not in config file. Configuring...
Enter security name: Enter authentication phrase: Enter privacy phrase: Authentication: [MD5/SHA]: Default: SHA Crypto algorithm [AES/DES]: Default: DES
Save these credentials(Y/n)? <Default: Yes>
The config file is YAML format and can be edited manually. [source,text]
/home//.snob/snobrc.yml
dummy: user: username auth_pass: auth passphrase priv_pass: priv passphrase auth: MD5/SHA crypto: AES/DES
myserver: user: myname auth: secret priv: realsecret auth: SHA crypto: AES
== TODO
- Add ability to do on-the-fly editing of config file using default system editor.
- Replace reliance on external snmpwalk to make this app even more portable.
- Add build for Raspberry Pi Model 4
- Add cross-compiled object files for systems that don't have Crystal installed.
== Development Please, see the <
Check out the repo on GitHub at https://github.com/lebogan/snob.git
== Contributing Please, see the <
- Fork it https://github.com/[your-github-name]/snob/fork
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
== Contributors
- https://github.com/lebogan/snob.git[lebogan] - creator, maintainer
== License This utility is available as open source under the terms of the http://opensource.org/licenses/MIT[MIT License].
== Usage Disclaimer This utility was originally created for my personal use in my work as a network specialist. Developed around 2017 using Crystal 0.21.0 on Ubuntu 14.04 virtual workstation running under Vagrant with VirtualBox provider. I have since upgraded to Ubuntu 20.04LTS and Crystal 1.5.1 with upgrades to Vagrant and VirtualBox. Tested on RaspberryPi(Buster 10), RaspberryPi(Ubuntu 20.04 server), CentOS 8, and Debian 10, Ubuntu 22.04 server.
I am not a professional software developer nor do I pretend to be. I am a retired IT network specialist and this is a hobby to keep me out of trouble. If you use this application and it doesn't work the way you would want, feel free to fork it and modify it to your liking. Fork on GitHub at https://github.com/lebogan/snob.git
snob
- 3
- 0
- 0
- 0
- 2
- almost 2 years ago
- December 18, 2017
MIT License
Thu, 07 Nov 2024 02:39:15 GMT