Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How get OIDs from returned values in python net-snmp-5.4.2 module

1,686 views
Skip to first unread message

Alexey Kostyuk

unread,
Mar 25, 2010, 2:34:10 AM3/25/10
to
Hi!
I use python net-snmp module for retrieve some info via snmp.
When I use snmpwalk from net-snmp-utils output will be contain values
and his OIDs, like in this example:

[unit@unit mibs]$ snmpwalk -Cc -c public -v1 10.50.252.1
1.3.6.1.2.1.10.94.1.1.14
SNMPv2-SMI::transmission.94.1.1.14.1.2.68.69.70.86.65.76 = INTEGER: 2
SNMPv2-SMI::transmission.94.1.1.14.1.2.52.48.57.54 = INTEGER: 3
SNMPv2-SMI::transmission.94.1.1.14.1.2.50.48.52.56 = INTEGER: 3
....

When I try to get it via python using this code:

Python 2.6.2 (r262:71600, Jan 25 2010, 18:46:45)
[GCC 4.4.2 20091222 (Red Hat 4.4.2-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
>>> sess = netsnmp.Session(Version=2, DestHost='10.50.252.1',
Community='public')
>>> sess.UseLongNames = 1
>>> sess.UseEnums = 1
>>> vars = netsnmp.VarList(netsnmp.Varbind('1.3.6.1.2.1.10.94.1.1.14',
''))
>>> vals = sess.walk(vars)
>>> print vals[0:3]
('2', '3', '3')

the output output contains only returned values

How it's possible to get OIDs of this values?

I use Fedora 12 Linux.
versions of net-snmp libs\utils:
net-snmp-utils-5.4.2.1-19.fc12.i686
net-snmp-python-5.4.2.1-19.fc12.i686
net-snmp-5.4.2.1-19.fc12.i686
net-snmp-libs-5.4.2.1-19.fc12.i686

----
Alexey Kostyuk


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-users mailing list
Net-snm...@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Dave Shield

unread,
Mar 25, 2010, 4:45:34 AM3/25/10
to
On 25 March 2010 06:34, Alexey Kostyuk <akos...@kaluga.ru> wrote:

> When I try to get it via python using this code:

>>>> vals = sess.walk(vars)
>>>> print vals[0:3]
> ('2', '3', '3')
>
> the output output contains only returned values
>
> How it's possible to get OIDs of this values?


I've no real experience with the Python interface,
but try looking at the 'vars' variable following the walk,
rather than 'vals'.
A brief look at the documentation (python/README)
includes the following:

snmpwalk(<Varbind/VarList>, <Session args>))
- .....
Returns a tuple of values retrieved from the MIB below
the Varbind passed in. ==> If a VarList is passed in it
will be updated to contain a complete set of VarBinds
created for the results of the walk. <==


Dave

0 new messages