原文地址:PySNMP学习笔记(二)作者:MichaelLing83
关于getCmd的返回值。
The varBinds is a tuple of Managed Objects. Managed Objects found in response are position-bound to Managed Object names passed in request. Each Managed Object is a tuple of Object Name and Object Value.
如果只有一个oid参数,并且oid对应的信息只有一个(叶子节点?),则形如:
[ (ObjectName('1.3.6.1.2.1.1.1.0'),
OctetString("'Linux my.domain.com 2.6.21 #2 Mon Mar 19 17:07:18 MSD 2006 i686'")) ]
如果oid对应的是一系列值(表?),则形如:
[
[(ObjectName('1.3.6.1.2.1.2.2.1.5.1'), Gauge32('1000000000'))],
[(ObjectName('1.3.6.1.2.1.2.2.1.5.2'), Gauge32('1000000000'))],
[(ObjectName('1.3.6.1.2.1.2.2.1.5.9'), Gauge32('1000000000'))],
[(ObjectName('1.3.6.1.2.1.2.2.1.5.89'), Gauge32('0'))]
]
可以看到,是由上面那种单独信息组成的list。
Object Value是类PyASN1或者其SNMP相关派生类的实例,这些类有:
class Integer( value )
Create a SMIv2 Integer object. The value parameter should be an integer value. Instances of this class mimic basic properties of a Python integer.
class Integer32( value )
Create a SMIv2 Integer32 object. This object is similar to Integer class instance.
class OctetString( value )
Create a SMIv2 OctetString object. The value parameter should be a string value. Instances of this class mimic basic properties of a Python string.
class IpAddress( value )
Create a SMIv2 IpAddress object. The value parameter should be an IP address expressed in quad-dotted notation (e.g. "127.0.0.1").
class Counter32( value )
Create a SMIv2 Counter32 object. Besides different value constraints, this object is similar to Integer class instance.
class Gauge32( value )
Create a SMIv2 Gauge32 object. Besides different value constraints, this object is similar to Integer class instance.
class Unsigned32( value )
Create a SMIv2 Unsigned32 object. Besides different value constraints, this object is similar to Integer class instance.
class TimeTicks( value )
Create a SMIv2 TimeTicks object. Besides different value constraints, this object is similar to Integer class instance.
class Opaque( value )
Create a SMIv2 Opaque object. This object is similar to OctetString class instance.
class Counter64( value )
Create a SMIv2 Counter64 object. Besides different value constraints, this object is similar to Integer class instance.
class Bits( value )
Create a SMIv2 Bits object. The value parameter should be sequence of names of bits raised to one. Unmentioned bits default to zero.