PySNMP学习笔记(二)

来源:互联网 发布:继电器仿真软件 编辑:程序博客网 时间:2024/06/06 04:13
原文地址:PySNMP学习笔记(二)作者:MichaelLing83
关于getCmd的返回值。

ThevarBinds is a tuple of Managed Objects. ManagedObjects found in response are position-bound to Managed Objectnames passed in request. Each Managed Object is a tuple ofObject Name and ObjectValue.

如果只有一个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相关派生类的实例,这些类有:
classInteger( value )

Create a SMIv2 Integer object. Thevalue parameter should be an integer value.Instances of this class mimic basic properties of a Pythoninteger.

class Integer32( value )

Create a SMIv2 Integer32 object. This object issimilar to Integerclass instance.

class OctetString( value)

Create a SMIv2 OctetString object. Thevalue parameter should be a string value.Instances of this class mimic basic properties of a Pythonstring.

class IpAddress( value )

Create a SMIv2 IpAddress object. Thevalue parameter should be an IP address expressedin quad-dotted notation (e.g. "127.0.0.1").

class Counter32( value )

Create a SMIv2 Counter32 object. Besidesdifferent value constraints, this object is similar to Integerclass instance.

class Gauge32( value )

Create a SMIv2 Gauge32 object. Besidesdifferent value constraints, this object is similar to Integerclass instance.

class Unsigned32( value)

Create a SMIv2 Unsigned32 object. Besidesdifferent value constraints, this object is similar to Integerclass instance.

class TimeTicks( value )

Create a SMIv2 TimeTicks object. Besidesdifferent value constraints, this object is similar to Integerclass instance.

class Opaque( value )

Create a SMIv2 Opaque object. This object issimilar to OctetString class instance.

class Counter64( value )

Create a SMIv2 Counter64 object. Besidesdifferent value constraints, this object is similar to Integerclass instance.

class Bits( value )

Create a SMIv2 Bits object. Thevalue parameter should be sequence of names ofbits raised to one. Unmentioned bits default to zero.



0 0