pysnmp使用

install

yum install python-pysnmp
yum install python-pyasn1

or

pip install pysnmp
pip install pyasn1

document

http://ports.gnu-darwin.org/net-mgmt/py-snmp4/work/pysnmp-4.1.7a/docs/pysnmp-tutorial.html
https://github.com/mfs/snmp-switch/blob/master/snmp-switch
https://github.com/oriordan/pysnmp_mibs

FAQ

cmdgen.MibVariable('SNMPv2-MIB', 'sysName', 0)
AttributeError: 'module' object has no attribute 'MibVariable'

python-pysnmp版本过低,4.2.3之后版本。

针对普通网络设备的端口,MIB的相关定义是Interface组,主要管理如下信息:
ifIndex                 端口索引号
ifDescr                 端口描述
ifType                  端口类型
ifMtu                   最大传输包字节数
ifSpeed                 端口速度
ifPhysAddress           物理地址
ifOperStatus            操作状态
ifLastChange            上次状态更新时间

*ifInOctets             输入字节数
*ifInUcastPkts          输入非广播包数
*ifInNUcastPkts         输入广播包数
*ifInDiscards           输入包丢弃数
*ifInErrors             输入包错误数
*ifInUnknownProtos      输入未知协议包数
*ifOutOctets            输出字节数
*ifOutUcastPkts         输出非广播包数
*ifOutNUcastPkts        输出广播包数
*ifOutDiscards          输出包丢弃数
*ifOutErrors            输出包错误数
ifOutQLen               输出队长
# *号标识的是与网络流量有关的信息。
原文地址:https://www.cnblogs.com/liujitao79/p/4663925.html