On 17 May 2012 03:16, 胡小根 <[email protected]> wrote:
> I am now using net-snmp python bindings. There comes a problem that the
> function netsnmp.snmpwalk() returns only oid values, but do not return index.
No - the function snmpwalk returns a set of 4-tuples:
var.tag (the object OID)
var.iid (the index)
var.val (the value)
var.type (the type)
Have a look at 'python/netsnmp/tests/test.py' for examples.
> For example, if I want to poll ifDescr(1.3.6.1.2.1.2.2.1.2),
> netsnmp.snmpwalk() only return a tuple containing values but not ifIndex.
Try the following:
import netsnmp
vars = netsnmp.VarList( netsnmp.Varbind('ifDescr'))
res = netsnmp.snmpwalk( vars, Version = 1, DestHost =
'localhost', Community = 'public' )
for var in vars:
print "ifIndex value = ", var.iid, "\tifDescr value =", var.val
> I'm wondering whether I didn't get netsnmp work well or it's the bindings'
> problem.
It's not the bindings' problem.
Dave
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users