Discussion:
python module for netsnmp
Andreea Bogdana Botez
2007-04-16 08:40:16 UTC
Permalink
Hi.
I'm trying to use the python module for netsnmp with a new MIB (not one the
standard ones) and a new snmp agent that knows how to interact with it.
Standard tests work ok, for example:

snmpset -v 2c -c private 127.1:8333 SOME-MIB::<oid>.0 i 5
SOME-MIB::<oid>.0 = INTEGER: 5

Also, the standard snmp module tests (test.py) against snmpd with the given
conf file are ok.

But, when I try to do the same think using the python module:

sess = netsnmp.Session(Version=2, DestHost='localhost',
Community='public')
sess.UseEnums = 1
sess.UseLongNames = 1
vars = netsnmp.VarList(netsnmp.Varbind(<oid>,'0'))
vals = sess.get(vars)

I get an "get: unknown object ID (<oid>)v2 sess.get result: None" error.

If I change vars = netsnmp.VarList(netsnmp.Varbind(<numeric_oid>,'0')) -
then I get a None object in vals.

Probably there's something that I didn't do right..

I'm using net-snmp version 5.4 on a Linux RH 2.6.16.7 platform.

Thanks for helping
Bogdana
Dave Shield
2007-04-16 11:26:24 UTC
Permalink
Post by Andreea Bogdana Botez
sess = netsnmp.Session(Version=2, DestHost='localhost',
Community='public')
sess.UseEnums = 1
sess.UseLongNames = 1
vars = netsnmp.VarList(netsnmp.Varbind(<oid>,'0'))
vals = sess.get(vars)
I get an "get: unknown object ID (<oid>)v2 sess.get result: None" error.
If I change vars = netsnmp.VarList(netsnmp.Varbind(<numeric_oid>,'0')) -
then I get a None object in vals.
What happens if you try a "snmpget" request with the same numeric OID?
Does that return a value or not?

What happens if you try the python code with a "standard" OID?
Does that work or not?

Dave
Bogdana Botez
2007-04-16 12:44:06 UTC
Permalink
Hi Dave,

See my answers below.

Q: > What happens if you try a "snmpget" request with the same numeric OID?
Post by Dave Shield
Does that return a value or not?
A: I've just checked - it returns None:
In [15]: oid = netsnmp.Varbind(<numeric_OID_here>,'0')
In [19]: netsnmp.snmpget(oid, Version=2, RemotePort=8333,
Community="private")
Out[19]: (None,)

Q: > What happens if you try the python code with a "standard" OID?
Post by Dave Shield
Does that work or not?
A: This works - for example the script below works fine:
sess = netsnmp.Session(Version=2, DestHost='localhost',
Community='public')

sess.UseEnums = 1
sess.UseLongNames = 1

vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
Post by Dave Shield
Post by Andreea Bogdana Botez
sess = netsnmp.Session(Version=2, DestHost='localhost',
Community='public')
sess.UseEnums = 1
sess.UseLongNames = 1
vars = netsnmp.VarList(netsnmp.Varbind(<oid>,'0'))
vals = sess.get(vars)
I get an "get: unknown object ID (<oid>)v2 sess.get result: None" error.
If I change vars = netsnmp.VarList(netsnmp.Varbind(<numeric_oid>,'0')) -
then I get a None object in vals.
What happens if you try a "snmpget" request with the same numeric OID?
Does that return a value or not?
What happens if you try the python code with a "standard" OID?
Does that work or not?
Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-users mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
Dave Shield
2007-04-16 12:55:05 UTC
Permalink
Post by Bogdana Botez
Q: > What happens if you try a "snmpget" request with the same numeric OID?
Post by Dave Shield
Does that return a value or not?
In [15]: oid = netsnmp.Varbind(<numeric_OID_here>,'0')
In [19]: netsnmp.snmpget(oid, Version=2, RemotePort=8333,
Community="private")
Out[19]: (None,)
Sorry - that's not quite what I meant.
What happens if you try the "snmpget" *command-line*
tool with the same OID?

Dave
Bogdana Botez
2007-04-16 13:01:16 UTC
Permalink
You meant this: snmpget -v 2c -c private 127.1:8333
MY-MIB::<numeric_or_string_oid>.0

This works.

The command line tools all work with MY-MIB and the agent (snmpset,
snmpget. snmpwalk etc). I also use a MIB browser and I'm able to manage
it just fine. Only the python library seems to get blocked somewhere.

Bogdana
Post by Dave Shield
Post by Bogdana Botez
Q: > What happens if you try a "snmpget" request with the same numeric OID?
Post by Dave Shield
Does that return a value or not?
In [15]: oid = netsnmp.Varbind(<numeric_OID_here>,'0')
In [19]: netsnmp.snmpget(oid, Version=2, RemotePort=8333,
Community="private")
Out[19]: (None,)
Sorry - that's not quite what I meant.
What happens if you try the "snmpget" *command-line*
tool with the same OID?
Dave
Bogdana Botez
2007-04-17 14:09:16 UTC
Permalink
Well, I tried another python snmp module and it worked from the first try.
Still I don't know what was the problem with netsnmp, tough..
Post by Bogdana Botez
You meant this: snmpget -v 2c -c private 127.1:8333
MY-MIB::<numeric_or_string_oid>.0
This works.
The command line tools all work with MY-MIB and the agent (snmpset,
snmpget. snmpwalk etc). I also use a MIB browser and I'm able to manage
it just fine. Only the python library seems to get blocked somewhere.
Bogdana
Post by Dave Shield
Post by Bogdana Botez
Q: > What happens if you try a "snmpget" request with the same numeric OID?
Post by Dave Shield
Does that return a value or not?
In [15]: oid = netsnmp.Varbind(<numeric_OID_here>,'0')
In [19]: netsnmp.snmpget(oid, Version=2, RemotePort=8333,
Community="private")
Out[19]: (None,)
Sorry - that's not quite what I meant.
What happens if you try the "snmpget" *command-line*
tool with the same OID?
Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-users mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
Andreea Bogdana Botez
2007-04-16 12:46:32 UTC
Permalink
Hi Dave,

See my answers below.

Q: > What happens if you try a "snmpget" request with the same numeric OID?
Post by Dave Shield
Does that return a value or not?
A: I've just checked - it returns None:
In [15]: oid = netsnmp.Varbind(<numeric_OID_here>,'0')
In [19]: netsnmp.snmpget(oid, Version=2, RemotePort=8333, Community="private")
Out[19]: (None,)

Q: > What happens if you try the python code with a "standard" OID?
Post by Dave Shield
Does that work or not?
A: This works - for example the script below works fine:
sess = netsnmp.Session(Version=2, DestHost='localhost',
Community='public')

sess.UseEnums = 1
sess.UseLongNames = 1

vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)


Bogdana
Post by Dave Shield
Post by Andreea Bogdana Botez
sess = netsnmp.Session(Version=2, DestHost='localhost',
Community='public')
sess.UseEnums = 1
sess.UseLongNames = 1
vars = netsnmp.VarList(netsnmp.Varbind(<oid>,'0'))
vals = sess.get(vars)
I get an "get: unknown object ID (<oid>)v2 sess.get result: None" error.
If I change vars = netsnmp.VarList(netsnmp.Varbind(<numeric_oid>,'0')) -
then I get a None object in vals.
What happens if you try a "snmpget" request with the same numeric OID?
Does that return a value or not?
What happens if you try the python code with a "standard" OID?
Does that work or not?
Dave
Loading...