You are not logged in.

#1 2014-03-12 07:09:03

hwa
Member
Registered: 2014-03-12
Posts: 10

[SOLVED] Import asn1 and other snmp related

I'm trying to adapt a debian-based nagios-script to arch. I'm having difficulties when the modules should be imported, basically because me being clueless.
The following is from the original script (http://oss.range-id.it/download/check_u … ps_socomec)

import sys, threading, StringIO
from optparse import OptionParser
from pysnmp import asn1, v1, v2c
from pysnmp import role
import pysnmp

The problem is that pysnmp related modules do not get imported. I think I can load asn1 with

import pyasn1.py

But importing v1 and v2c does not work the same way, even there is v1.py in python-pysnmp.

The question is how the import should be done?

Last edited by hwa (2014-03-14 06:50:48)

Offline

#2 2014-03-14 06:49:32

hwa
Member
Registered: 2014-03-12
Posts: 10

Re: [SOLVED] Import asn1 and other snmp related

Solved it myself.

For other newbies:
There are amongst other things packages included with modulkes, biut those are not automatically loaded with the module itself. You should load packages in dotted format. In my case the correct syntax is

from pysnmp.proto.api import v1,v2c

The clue to me was thinking what might the path mean here, as clearly the module itself was higher in the tree.

/usr/lib/python2.7/site-packages/pysnmp/proto/api/v1.py

Offline

Board footer

Powered by FluxBB