PySNMP学习笔记(二)

6 篇文章 0 订阅

原文地址: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.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值