Package: ezsnmp
Artwork courtesy ofOpen Clip Art
LibraryIntroductionEz SNMP is a fork ofEasy SNMPWhy Another Library?Simple, because the maintainer ofEasy SNMPseems to have abandoned the project and or isn’t actively working on it.This version (Ez SNMP) will attempt to remain up to date with Python versions that are supported byPythonand net-snmp versions that are supported byNet-SNMPQuick StartThere are primarily two ways you can use the Ez 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:fromezsnmpimportSession# Create an SNMP session to be used for all our requestssession=Session(hostname='localhost',community='public',version=2)# You may retrieve an individual OID using an SNMP GETlocation=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 integercontact=session.get(('sysContact','0'))# And of course, you may use the numeric OID toodescription=session.get('.1.3.6.1.2.1.1.1.0')# Set a variable using an SNMP SETsession.set('sysLocation.0','The SNMP Lab')# Perform an SNMP walksystem_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 informationforiteminsystem_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 Ez SNMP via its simple interface which is intended
for one-off operations (where you wish to specify all details in the
request):fromezsnmpimportsnmp_get,snmp_set,snmp_walk# Grab a single piece of information using an SNMP GETsnmp_get('sysDescr.0',hostname='localhost',community='public',version=1)# Perform an SNMP SET to update datasnmp_set('sysLocation.0','My Cool Place',hostname='localhost',community='public',version=1)# Perform an SNMP walksnmp_walk('system',hostname='localhost',community='public',version=1)DocumentationPlease check out theEz SNMP documentation at. This includes installation
instructions for various operating systems.You may generate the documentation as follows:# Install Sphinx
# See this website for install instructions https://www.sphinx-doc.org/en/master/usage/installation.html# Build the documentation into static HTML pagescdsphinx_docs_buildmakehtmlAcknowledgmentsI’d like to say thanks to the following folks who have made this project
possible:Giovanni Marzot: the original authorScienceLogic, LLC: sponsored the initial development of this
moduleWes Hardaker and the net-snmp-coders: for their hard work and
dedicationfgimian and nnathan: the original contributors to this codebaseKent Coble: who was the most recent maintainer.Easy SNMPRunning TestsTests usePytest. You can run
them with the following on Linux:gitclonehttps://github.com/ezsnmp/ezsnmp.git;cdezsnmp;sudoaptupdate&&sudoaptupgrade-y;sudoaptinstall-ysnmpsnmpdlibsnmp-devlibperl-devsnmp-mibs-downloadervalgrind;sudoaptinstall-ypython3-pippython3-devpython3-setuptoolsgdb-y;sudosystemctlstopsnmpd;sudomv/etc/snmp/snmpd.conf/etc/snmp/snmpd.conf.orig;sudocptests/snmpd.conf/etc/snmp/snmpd.conf;sudodownload-mibs;mkdir-p-m0755~/.snmp;echo'mibs +ALL'>~/.snmp/snmp.conf;sudosystemctlstartsnmpd;rm-drfbuild/dist/ezsnmp.egg-info;python3-mpipinstall-rrequirements.txt;python3setup.pybuild&&python3-mpipinstall-e.&&python3-mpytest.;# Bottom one for debug. Replace the top one with it if needed.
# python3 setup.py build && python3 -m pip install -e . && gdb -ex run -ex bt -ex quit --args python3 -m pytest .;
# Bottom one for valgrind. Replace the top one with it if needed.
# python3 setup.py build && python3 -m pip install -e . && valgrind --tool=memcheck --leak-check=full --show-leak-kinds=definite,indirect,possible python3 -m pytest .On MacOSgitclonehttps://github.com/ezsnmp/ezsnmp.git;cdezsnmp;mv/etc/snmp/snmpd.conf/etc/snmp/snmpd.conf.orig;cptests/snmpd.conf/etc/snmp/snmpd.conf;launchctlunload/System/Library/LaunchDaemons/org.net-snmp.snmpd.plist;launchctlload-w/System/Library/LaunchDaemons/org.net-snmp.snmpd.plist;rm-drfbuild/dist/ezsnmp.egg-info;python3setup.pybuild&&python3-mpipinstall-e.&&python3-mpytest.;Running cibuildwheelsFor Linux builds on a Linux machineclear&&rm-drfwheelhouse/build/ezsnmp.egg-info/&&python3-mcibuildwheel--output-dirwheelhouse--platformlinuxFor MacOS builds on a MacOS machineclear&&rm-drfwheelhouse/build/ezsnmp.egg-info/&&python3-mcibuildwheel--output-dirwheelhouse--platformmacosLicenseEz SNMP is released under theBSDlicense. Please see theLICENSEfile for more details.CopyrightThe original version of this library is copyright (c) 2006 G. S. Marzot.
All rights reserved.This program is free software; you can redistribute it and/or modify it
under the same terms as Net-SNMP itself.Copyright (c) 2006 SPARTA, Inc. All Rights Reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Net-SNMP itself.Copyright (c) 2024 carlkidcrypto All Rights Reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Net-SNMP itself.