一个自以为是的python SNMPv2库,用于快速获取数据库。
snmp-fetch的Python项目详细描述
一个固执己见的python3.7snmpv2包,专为快速数据库摄取而设计。这个包是一个源发行版,其中包含一个封装net-snmp的C模块。此包中不进行MIB处理。C模块将来自netsnmp的原始结果复制到numpy数组中,以便使用numpy或pandas进行快速后处理。其他封装netsnmp的库通常会在每个PDU请求响应之间将控制权返回给python。snmpfetch被设计成线程安全和高效,通过在GIL发布的情况下遍历C模块中的多个目标。提供了Helper模块来帮助使用MIB之类的定义进行后处理,以便将原始数据转换为可用的数据帧。在
先决条件
snmpfetch需要python3.7、一个c++17编译器(目前只支持gcc-8)和cmake 3.12.4+。生成此包不需要其他用户安装的依赖项。在
注意!在
安装可能需要一段时间,因为安装脚本将下载boost并在包中下载并构建netsnmp5.8的轻量级版本。在
boost下载可能需要一段时间,因为它克隆每个子模块,而不是下载压缩发行版。通过cmake下载压缩发行版时存在问题,其中302个重定向指向cURL失败的文件。在
cmake脚本将尝试检测主机上的核心数量,以加快下载和构建时间。安装时间预计为5分钟(4核超线程)到30分钟以上(1核)。在
安装
# poetry poetry add snmp-fetch --no-dev # pip pip install snmp-fetch
示例
示例使用jupyter,并且可以使用以下方法安装依赖项:
^{pr2}$发展
开发snmp获取需要Poetry。在
# clone the respository git clone --recurse-submodules -j8 https://github.com/higherorderfunctor/snmp-fetch.git cd snmp-fetch #if working off an existing clone, update the current branch git pull # pull the latest code git submodule update --init --recursive # pull the latest submodule version # setup the virtual environment - mypy uses symbolic links in the 'stubs' directory to # expose packages that play nicely with the static type checker virtualenv -p python3.7 ENV source ENV/bin/activate poetry install
# C++ headers are in the following folders for linters export CPLUS_INCLUDE_PATH="build/temp.linux-x86_64-3.7/include:lib/pybind11/include:lib/Catch2/single_include/catch2" # python linting poetry run isort -rc --atomic . poetry run pylint snmp_fetch tests poetry run flake8 snmp_fetch tests poetry run mypy -p snmp_fetch -p tests poetry run bandit -r snmp_fetch # C++ linting # TODO # python testing poetry run pytest -v --hypothesis-show-statistics tests # fail fast testing poetry run pytest -x --ff tests # C++ testing pushd build/temp.linux-x86_64-3.7/ cmake -DBUILD_TESTING=ON ../.. && make test_capi test popd
已知限制
- v0.1.x版本之间的更改可能会导致重大更改。在
- 库目前只支持SNMPv2。在
- BULKGET请求和下一个请求总是执行一次行走。在
- 如果OID的根超出请求的OID,则行走将始终结束。在
- 同一主机/请求上的重复对象将被自动丢弃。
- 这包括初始请求;必须在第一个所需的OID上执行遍历。在
- 没有任何_-sus-hu实例、NO-sus-sug-OBJECT和END-OF-fn-OF-MIB-VIEW-response变量绑定作为错误公开给客户机处理。在
- 项目
标签: