Skip to main content

A blazingly fast and Pythonic SNMP library based on the official Net-SNMP bindings

Project description

Build Status Coverage Status Join the chat at https://gitter.im/easysnmp/Lobby License

Easy SNMP Logo

Artwork courtesy of Open Clip Art Library

Introduction

Easy SNMP is a fork of Net-SNMP Python Bindings that attempts to bring a more Pythonic interface to the library. Check out the Net-SNMP website for more information about SNMP.

This module provides a full-featured SNMP client API and supports all dialects of the SNMP protocol.

Why Another Library?

  • The original Net-SNMP Python library is a great starting point but is quite un-Pythonic and lacks proper unit tests and documentation.

  • PySNMP is entirely written in Python and therefore has a huge performance hit. In some brief tests, I estimate that both the Net-SNMP Python bindings and Easy SNMP are more than 4 times faster than PySNMP. Further to this, PySNMP has an even less Pythonic interface than the official Net-SNMP bindings.

  • Many other libraries like Snimpy are sadly based on PySNMP, so they also suffer performance penalty.

Quick Start

There are primarily two ways you can use the Easy SNMP library:

1. By using a Session object which is most suitable when you want to request multiple pieces of SNMP data from a source:

from easysnmp import Session

# Create an SNMP session to be used for all our requests
session = Session(hostname='localhost', community='public', version=2)

# You may retrieve an individual OID using an SNMP GET
location = session.get('sysLocation.0')

# You may also specify the OID as a tuple (name, index)
# Note: the index is specified as a string as it can be of other types than
# just a regular integer
contact = session.get(('sysContact', '0'))

# And of course, you may use the numeric OID too
description = session.get('.1.3.6.1.2.1.1.1.0')

# Set a variable using an SNMP SET
session.set('sysLocation.0', 'The SNMP Lab')

# Perform an SNMP walk
system_items = session.walk('system')

# Each returned item can be used normally as its related type (str or int)
# but also has several extended attributes with SNMP-specific information
for item in system_items:
    print '{oid}.{oid_index} {snmp_type} = {value}'.format(
        oid=item.oid,
        oid_index=item.oid_index,
        snmp_type=item.snmp_type,
        value=item.value
    )

2. By using Easy SNMP via its simple interface which is intended for one-off operations (where you wish to specify all details in the request):

from easysnmp import snmp_get, snmp_set, snmp_walk

# Grab a single piece of information using an SNMP GET
snmp_get('sysDescr.0', hostname='localhost', community='public', version=1)

# Perform an SNMP SET to update data
snmp_set(
    'sysLocation.0', 'My Cool Place',
    hostname='localhost', community='public', version=1
)

# Perform an SNMP walk
snmp_walk('system', hostname='localhost', community='public', version=1)

Documentation

Please check out the Easy SNMP documentation at Read the Docs. This includes installation instructions for various operating systems.

You may generate the documentation as follows:

# Install Sphinx
pip install sphinx

# You may optionally export the READTHEDOCS environment variable to build docs
# on systems where you haven't built the C interface
export READTHEDOCS=1

# Build the documentation into static HTML pages
cd docs
make html

Acknowledgments

I’d like to say thanks to the following folks who have made this project possible:

  • Giovanni Marzot: the original author

  • ScienceLogic, LLC: sponsored the initial development of this module

  • Wes Hardaker and the net-snmp-coders: for their hard work and dedication

Running Tests

You may run the unit tests as follows:

git clone https://github.com/fgimian/painter.git
cd painter
python setup.py test

License

Easy SNMP is released under the BSD license. Please see the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chturne-easysnmp-0.2.5.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

chturne_easysnmp-0.2.5-cp310-cp310-manylinux1_x86_64.whl (118.4 kB view details)

Uploaded CPython 3.10

File details

Details for the file chturne-easysnmp-0.2.5.tar.gz.

File metadata

  • Download URL: chturne-easysnmp-0.2.5.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for chturne-easysnmp-0.2.5.tar.gz
Algorithm Hash digest
SHA256 c13224de429dd5d0da36e8a932dbb72e9322667de856217d6cd25ede0c7b5366
MD5 8b52c13781822eea4da3d09b4d41b8c5
BLAKE2b-256 9d5a6bbc7f379bd9ec9a9730c1f917c265623a9a0fea50864f3b5155e6d0af97

See more details on using hashes here.

File details

Details for the file chturne_easysnmp-0.2.5-cp310-cp310-manylinux1_x86_64.whl.

File metadata

  • Download URL: chturne_easysnmp-0.2.5-cp310-cp310-manylinux1_x86_64.whl
  • Upload date:
  • Size: 118.4 kB
  • Tags: CPython 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for chturne_easysnmp-0.2.5-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2c332c7176d09bf6239db47e5e37bff6e06814772640fc5187b3117603fd6edc
MD5 5beb8190e5b37fb9721aa1267c611889
BLAKE2b-256 bad7ea20f2254f6d74a1ca035205e8a03147b3f072c2f7dc1ae0c1630fcd950f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page