<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>libsnmp-python: I get errors when using snmpgetnext or snmpwalk</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial CE">Package: libsnmp-python</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Version: 5.4.2.1~dfsg-5+b1</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Severity: important</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Tags: squeeze</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">When using the python bindings for net-snmp, I get errors when using snmpgetnext or snmpwalk. All installed software is from standard Debian distribution</FONT></P>

<P><FONT SIZE=2 FACE="Arial CE">Detailed description:</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">I try to communicate with a network device via SNMP. I send the same commands using command line tools and then using Python module libsnmp. The system is configured in such a way that I don't need to enter information about MIBS and paths on the commandline.</FONT></P>

<P><FONT SIZE=2 FACE="Arial CE">The following command are taken form tutorial on </FONT><A HREF="http://www.net-snmp.org/wiki/index.php/TUT:snmpwalk"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial CE">http://www.net-snmp.org/wiki/index.php/TUT:snmpwalk</FONT></U></A>
</P>

<P><FONT SIZE=2 FACE="Arial CE">##############################################</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">On Debian Squeeze:</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">==============================================</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Scenario 1: command line</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">~$ snmpget --version</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">NET-SNMP version: 5.4.2.1</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">~$ ip=&quot;192.168.52.221:160&quot;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">~$ com=&quot;public&quot;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">~$ snmpwalk -v 2c -c $com $ip sysDescr</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">RFC1213-MIB::sysDescr.0 = STRING: &quot;Some description&quot;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">~$ snmpgetnext -v 2c -c $com $ip sysDescr</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">RFC1213-MIB::sysDescr.0 = STRING: &quot;Some description&quot;</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2 FACE="Arial CE">Everything works as expected</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial CE">==============================================</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Scenario 2: libsnmp in Python, snmpgetnext</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">~$ python</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Python 2.5.5 (r255:77872, Apr 21 2010, 08:44:16) </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">[GCC 4.4.3] on linux2</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; import netsnmp</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; oid = netsnmp.Varbind('sysDescr')</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; ip=&quot;192.168.52.221:160&quot;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; com=&quot;tester&quot;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; res = netsnmp.snmpwalk(oid, Version = 2, DestHost = ip, Community = com); res</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">error: walk: unknown python error (varlist)&gt;&gt;&gt; </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; res = netsnmp.snmpwalk(oid, Version = 2, DestHost = ip, Community = com); res</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Traceback (most recent call last):</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">TypeError: expected string or Unicode object, NoneType found</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; </FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">An error occurs. Notice that I get a different error after the second try.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">==============================================</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Scenario 3: libsnmp in Python, snmpwalk</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">~$ python</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Python 2.5.5 (r255:77872, Apr 21 2010, 08:44:16) </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">[GCC 4.4.3] on linux2</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; import netsnmp</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; oid = netsnmp.Varbind('sysDescr')</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; ip=&quot;192.168.52.221:160&quot;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; com=&quot;tester&quot;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; res = netsnmp.snmpgetnext(oid, Version = 2, DestHost = ip, Community = com); res</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">error: get: unknown python error&gt;&gt;&gt; </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&gt;&gt;&gt; res = netsnmp.snmpgetnext(oid, Version = 2, DestHost = ip, Community = com); res</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Traceback (most recent call last):</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">TypeError: expected string or Unicode object, NoneType found</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">The same problem as in Scenario 2</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">##############################################</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">On Debian Lenny</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">It works as expected (the same results as from commandline). Below is a version of SNMP and python</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">~$ snmpget --version</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">NET-SNMP version: 5.4.1</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">~$ python</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) </FONT>

<BR><FONT SIZE=2 FACE="Arial CE">[GCC 4.3.2] on linux2</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">-- System Information:</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Debian Release: squeeze/sid</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&nbsp; APT prefers testing</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">&nbsp; APT policy: (500, 'testing')</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Architecture: i386 (i686)</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">Kernel: Linux 2.6.32-trunk-686 (SMP w/1 CPU core)</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">Shell: /bin/sh linked to /bin/dash</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">Versions of packages libsnmp-python depends on:</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">ii&nbsp; libc6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.10.2-6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Embedded GNU C Library: Shared lib</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">ii&nbsp; libsnmp15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.4.2.1~dfsg-5+b1 SNMP (Simple Network Management Pr</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">ii&nbsp; python&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.5.4-9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; An interactive high-level object-o</FONT>

<BR><FONT SIZE=2 FACE="Arial CE">ii&nbsp; python-central&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.6.14+nmu2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; register and build utility for Pyt</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">libsnmp-python recommends no packages.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">libsnmp-python suggests no packages.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial CE">-- no debconf information</FONT>
</P>

Legal Disclaimer:
The information contained in this message may be privileged and confidential. It is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete or destroy any copy of this message
</BODY>
</HTML>