16 Star 44 Fork 45

现任明教教主-乾颐堂 / qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.03.28 snmp get 688 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-03-28 15:24 . new file
#!/usr/bin/python3.4
from pysnmp.hlapi import *
#varBinds是列表,列表中的每个元素的类型是ObjectType(该类型的对象表示MIB variable)
errorIndication, errorStatus, errorindex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData('public'),
UdpTransportTarget(('192.168.1.3',161)),
ContextData(),
ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')),
ObjectType(ObjectIdentity('1.3.6.1.2.1.1.2.0')))
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorindex and varBinds[int(errorindex)-1][0] or '?'
)
)
for varBind in varBinds:
print(varBind)
Python
1
https://gitee.com/qytang/qytang_Python.git
git@gitee.com:qytang/qytang_Python.git
qytang
qytang_Python
qytang_Python
master

搜索帮助