netsnmp

The netsnmp gem provides a ruby DSL to handle SNMP queries. It currently uses the net-snmp C library using the FFI interface.

This gem started as a cleanup from net-snmp and its follow-up net-snmp2, both of which have been mostly inactive for the last year(s).

Installation

Add this line to your application's Gemfile:

gem'netsnmp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install netsnmp

Why?

You may ask, why not just use the aforementioned? I'll try to sum up the reasons.

Lack of support for some specific net-snmp versions.

Memory Leaks (both leave the responsibility of cleaning pdus to the user, and this usually creates memory leak when the responses fail).

Lack of support for some ruby > 2.1 GC directives, which makes the VM crash under certain circumstances.

Iffy EventMachine support (they basically send the request pdu, and schedule the reads to the reactor, and not really reacting on the socket handle).

Lack of support for NIO4r/Celluloid-IO (the other event loop, besides EM, that counts in the ruby world).

The default sync request calls block the whole VM, making multi-threading a non-factor, forcing you to resort to multiprocess for concurrency.

Philosophy

The main motto of the gem is: API economy. As less moving parts as possible. New features can be discussed and integrated, but they all must abide to this philosophy.

The main purpose of this gem is: SNMP v3 support. Why? Because it's the only one with authentication and security features integrated. SNMP has been a protocol which historically ignored security for many years, and even when it embraced it, its choices are by today's standards considered half-baked (MD5, SHA-1, shrug). Still, some-security is better than no-security. Also, support for v1 and v2 is something that you can get from other ruby gems (most of them refuse to support v3 altogether).

Do one thing and do it well. There's only an interface to interact with an SNMP Agent. Other features like credentials encryption or concurrency are out of the scope of this library, which only guarantees that an SNMP Client is thread-safe and performs ruby-VM-compatible IO.

Features

Client Interface, which supports SNMP 3, 2c, and 1

Supports get, set, walk and bulk calls.

Wrappers for eventmachine and celluloid-io

Ruby >= 2.0 support

net-snmp (C library) >= 5.5 support

Examples

You can use the docker container provided under spec/support to test against these examples.