基于官方网络snmp绑定的快速pythonicsnmp库

easysnmp的Python项目详细描述


Build StatusCoverage StatusJoin the chat at https://gitter.im/easysnmp/LobbyLicense

Easy SNMP Logo

艺术作品由Open Clip Art Library

简介

简单snmp是官方的分支Net-SNMP Python Bindings 但是试图给图书馆带来一个更像Python的界面支票 为了更多 有关SNMP的信息

此模块提供一个功能齐全的SNMP客户端API,支持所有 SNMP协议的方言

为什么是另一个图书馆?

  • original Net-SNMP Python library 是一个很好的起点,但很不象话,缺乏适当的 单元测试和文档。
  • PySNMP是用纯python编写的 因此有着巨大的性能冲击。在一些简短的测试中,我 估计net snmp python绑定和easy snmp都是 速度快了4倍多。此外,pysnmp的 pythonic接口比官方的net snmp绑定。
  • 许多其他的图书馆 Snimpy很遗憾 基于pysnmp,因此它们遭受相同的性能损失。

快速启动

使用Easy SNMP库的方法主要有两种。

第一种是使用最适合的会话对象 当您计划从 来源。

fromeasysnmpimportSession# 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)

您也可以通过其简单的接口使用easy snmp 对于一次性操作,您希望在 请求:

fromeasysnmpimportsnmp_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)

文件

请查看Easy SNMP documentation at Read the Docs。这包括安装 各种操作系统的说明。

您可以按如下方式生成文档:

# 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
exportREADTHEDOCS=1# Build the documentation into static HTML pages
cd docs
make html

致谢

我要感谢以下参与这个项目的人 可能:

  • giovanni marzot:原作者
  • sciencelogic,llc:发起了这项技术的初步开发 模块
  • wes hardaker和net snmp编码器:为他们的辛勤工作和 奉献精神

运行测试

您可以按如下方式运行单元测试:

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

许可证

Easy SNMP是在bsd许可证下发布的。请看 LICENSE 文件以获取更多详细信息。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Hibernate:jpamodelgen生成java而不是类   java如何在第二次活动结束后显示广告?   javascript如何在linux或windows上将java导出到jar   java One ArrayList添加了2个不同的选项   AmazonWeb服务如何在java中使用AWS Textract检索pdf中存在的表   java为什么RecycleView中的水平项在单击时不起作用?   java计算如果存在映射   java在捕获的组上应用正则表达式   如何使用Java在MySQL的同一个表中插入来自不同类的值   java字符串中最常见的字母(大写和小写)   Spring SessionBean实例正在由java中的多个用户共享   使用Spring Boot将@WebInitParam中的值外部化   java一创建线程就开始执行(多线程)   java是安卓所需的系统权限。意图行动给你打电话?