这里填写标题
1. snmp-cmds 系列工具命令
snmp cmds 是一组 SNMP 命令, 也是一个 python 库, 用于通过 snmp 与目标设备通信。
1.1. 安装
1.1.1. 命令
- MacOS 下自带
- RedHat 系 Linux 安装方法:
sudo yum install net–snmp–utils - Debian 系 Linux 安装方法:
sudo apt–get install snmp
1.1.2. python
From: https://www.cnpython.com/pypi/snmp-cmds
简单的方法:
pip3 install snmp-cmds
艰难的道路:
git clone https://github.com/alextremblay/snmp-cmds.git
cd snmp-cmds
pip install .
1.2. snmpget
Wrapper around Net-SNMP's ``snmpget`` command
Runs the equivalent of
'``snmpget -Oqv -Pe -t {timeout} -r 0 -v 2c -c {community} {host} {oid}``'
and parses the result. if the response from the server is a
``No Such Object`` or a ``No Such Instance`` error, this function returns
:obj:`None`. Otherwise, it returns the value retrieved from the server
1.3. snmpgetsome: 这里我们可以传入一个 list 的 oids
Warpper around Net-SNMP's
Runs Net-SNMP's 'snmpget' command on a list of OIDs, and returns a list
of tuples of the form (oid, result).
1.4. snmpwalk
Runs Net-SNMP's 'snmpget' command on a list of OIDs, and returns a list
of tuples of the form (oid, result).
1.4.1. 概述
SNMPWALK 是一个通过 SNMP GET-NEXT 类型 PDU, 实现对目标 AGENT 的某指定 MIB 分支信息进行完整提取输出的命令工作。
1.4.2. 命令⾏
snmpwalk [选项] agent [oid]
1.4.3. 选项参数
由于 SNMP 协议中, 不不同的协议版本存在不不同的参数选项, 以下参数按协议分开说明。
- 普通选项
- a) –h 显示帮助
- b) –v 1 | 2c | 3 指定 SNMP 协议版本
- c) –V 显示当前 SNMPWALK 命令⾏行行版本
- d) –r RETRIES 指定重试次数, 默认为 0 次。
- e) –t TIMEOUT 指定每次请求的等待超时时间, 单为秒, 默认为 3 秒。
- f) –Cc 指定当在 WALK 时, 如果发现 OID 负增⻓长将是否继续 WALK。
- V1、V2C 选项
- a) –c COMMUNITY 指定共同体字符串串
- V3 选项
- a) –l LEVEL 指定安全级别: noAuthNoPriv | authNoPriv | authPriv
- b) –u USER-NAME 安全名字
- c) –a PROTOCOL 验证协议: MD5 | SHA。如果-l 指定为 authNoPriv 或 authPriv 时才需要。
- d) –A PASSPHRASE 验证字符串串。如果-l 指定为 authNoPriv 或 authPriv 时才需要。
- e) –x PROTOCOL 加密协议: DES。如果-l 指定为 authPriv 时才需要。
- f) –X PASSPHRASE 加密字符串串: 如果-l 指定为 authPriv 时才需要。
1.5. snmptable
Runs Net-SNMP's 'snmptable' command on a given OID, converts the results
into a list of dictionaries, and optionally sorts the list by a given key.
1.6. snmpset
Runs Net-SNMP's 'snmpset' command on a given OID, and returns the result
if successful.
版权声明:本文为wan212000原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。