I have recently installed pySNMP 3.3.2 and use Python 2.2.2. Thanks to
Peter Hansen, I succeeded to install pySNMP properly. I'm not
completely new to SNMP (I know the basics), but I'm new to Python and
pysnmp. While experimenting, I find some strange things. When using
pySNMP:
1) I can type: 'import pysnmp' or 'from pysnmp import *'
2) when using: 'from pysnmp import role' (found on http://pysnmp.sourceforge
..net/examples/2.x/snmpget.html), I get the message 'ImportError:
cannot
import name role'. The same applies for 'from pysnmp import session'
or 'from pysnmp import v1' , but 'from pysnmp import proto' seems to
work.
3) A general question: how can I get a list of what I can type after
the 'from
pysnmp import ...'
4) How can I use: 'from snmpget import snmpget'. It does not accept
this.
5) Anyone has a simple example for the following application: I have a
cable
modem (which has an SNMP agent inside). I want to make a script where
I can
do SNMPgets (and later SNMPSet and SNMPwalk).
6) Where can I find a simple description on how to use 'snmpget'. I
cannot find
anything. I would like to write sth like snmpget(IP, OID)
7) What is the difference between snmpget and getrequest in pysnmp?
Any input is appreciated...
Thanks in advance,
Wim 3 21418
> 2) when using: 'from pysnmp import role' (found on http://pysnmp.sourceforge .net/examples/2.x/snmpget.html), I get the message 'ImportError:
You seems to use pysnmp 2.x API which differs from the latest 3.x branch
(though, a compatibility layer exists in 3.x distribution). That's why
I suggest you looking at the 3.x docs and examples at: http://pysnmp.sourceforge.net/docs/3.x/index.html
3) A general question: how can I get a list of what I can type after the 'from pysnmp import ...'
dir(<module>) may help but in this case I'd better see an example.
4) How can I use: 'from snmpget import snmpget'. It does not accept this.
There is no such module as snmpget in pysnmp.
5) Anyone has a simple example for the following application: I have a cable modem (which has an SNMP agent inside). I want to make a script where I can do SNMPgets (and later SNMPSet and SNMPwalk).
Python 1.5.2 (#3, Aug 25 1999, 19:14:24) [GCC 2.8.1] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam from pysnmp.proto import v1 from pysnmp.proto.ap i import generic from pysnmp.mapping. udp import role req = v1.GetRequest() req.apiGetPdu() .apiSetVarBind([('1.3.6.1.2.1.1 .1.0', None)]) tr = role.manager((' router-1.glas.net', 161)) (answer, src) = tr.send_and_rec eive(req.encode ()) rsp = v1.GetResponse( ) rsp.decode(answ er) vars = rsp.apiGetPdu() .apiGetVarBind( ) print vars
[('.1.3.6.1.2.1. 1.1.0', OctetString('Ci sco Internetwork Operating System
Software\015\01 2IOS (tm) 5400 Software(C5400-JS-M), Version 12.2(11.8b),
MAINTENANCE INTERIM SOFTWARE\015\01 2 Copyright (c) 1986-2002 by cisco
Systems, Inc.\015\012 Compiled Tue 30-Jul-02 19:02 by pwade'))]
7) What is the difference between snmpget and getrequest in pysnmp?
The only difference is the SNMP request object (GetRequest vs GetNextRequest)
you create when building SNMP message.
-ilya
I'd suggest you to refer to "high-level" API documentation at http://pysnmp.sourceforge.net/docs/3.x/ for getting used to
basic operations on SNMP objects (such as apiGetPdu(), apiSetVarBind() ).
Also, note, that pysnmp s/w (the third branch) has been closely aligned
with the APIs introduced by SNMP RFCs, so reading these RFCs may be
helpful too.
If you got more specific questions, please, let me know.
-ilya
WIWA <wi*********@sk ynet.be> wrote: Thanks Ilya,
This has been very helpful. I'm able to get data out of my 'device under test'.
I must be honnest and say that I understand the sample code, but could not write or produce it myself.
How do you know e.g that req.apiGetPdu() .apiSetVarBind([('1.3.6.1.2.1.1 .1.0', None)]) can be written? I've read through the documentation and could not find anything similar. Of course, I could overlook it.
Isn't there a tutorial out there that summarizes pysnmpv3 and gives examples of snmpget, snmpset, snmpwalk, etc...
Thanks in advance for helping me out.
Regards,
Wim
Ilya Etingof <il**@cray.glas .net> wrote in message news:<be******* ***@news.rol.ru >... > 2) when using: 'from pysnmp import role' (found on > http://pysnmp.sourceforge > .net/examples/2.x/snmpget.html), I get the message 'ImportError:
You seems to use pysnmp 2.x API which differs from the latest 3.x branch (though, a compatibility layer exists in 3.x distribution). That's why I suggest you looking at the 3.x docs and examples at:
http://pysnmp.sourceforge.net/docs/3.x/index.html
> 3) A general question: how can I get a list of what I can type after > the 'from > pysnmp import ...'
dir(<module>) may help but in this case I'd better see an example.
> 4) How can I use: 'from snmpget import snmpget'. It does not accept > this.
There is no such module as snmpget in pysnmp.
> 5) Anyone has a simple example for the following application: I have a > cable > modem (which has an SNMP agent inside). I want to make a script where > I can > do SNMPgets (and later SNMPSet and SNMPwalk).
Python 1.5.2 (#3, Aug 25 1999, 19:14:24) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from pysnmp.proto import v1 >>> from pysnmp.proto.ap i import generic >>> from pysnmp.mapping. udp import role >>> req = v1.GetRequest() >>> req.apiGetPdu() .apiSetVarBind([('1.3.6.1.2.1.1 .1.0', None)]) >>> tr = role.manager((' router-1.glas.net', 161)) >>> (answer, src) = tr.send_and_rec eive(req.encode ()) >>> rsp = v1.GetResponse( ) >>> rsp.decode(answ er) >>> vars = rsp.apiGetPdu() .apiGetVarBind( ) >>> print vars [('.1.3.6.1.2.1. 1.1.0', OctetString('Ci sco Internetwork Operating System Software\015\01 2IOS (tm) 5400 Software(C5400-JS-M), Version 12.2(11.8b), MAINTENANCE INTERIM SOFTWARE\015\01 2 Copyright (c) 1986-2002 by cisco Systems, Inc.\015\012 Compiled Tue 30-Jul-02 19:02 by pwade'))] >>>
> 7) What is the difference between snmpget and getrequest in pysnmp?
The only difference is the SNMP request object (GetRequest vs GetNextRequest) you create when building SNMP message.
-ilya
> 1) Instead of writing '1.3.6.1.2.1.69 .1.3.1', I would also like to be able to write 'docsDevSwServe r'. Any idea how I can do that?
The right way is to use a MIB parser (for labels-to-oids translation) which
is not a part of pysnmp. Try looking at Python backend to libsmi. If you
expect to query just a small and definite set of OIDs, an alternative would be
to hardcode labels-to-oid mapping somewhere in your script.
-ilya This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Krzysztof |
last post by:
Hello,
I noteced a weird problem with php snmpget. When I get two different consecutive
queries from Cisco box (actualy, any box) and if the first returned value is not
empty, but the second one is empty, then php shows exactly the same value for
second snmpget as for the first one. If I perform snmpget from linux shell,
everything is OK:
from shell:
|
by: Krzysztof |
last post by:
No one could answer my question lately, so maybe today I will have some luck :-)
Here we go again:
I noteced a weird problem with php snmpget. When I get two different consecutive
queries from Cisco box (actualy, any box) and if the first returned value is not
empty, but the second one is empty, then php shows exactly the same value for
second snmpget as for the first one. If I perform snmpget from linux shell,
everything is OK:
|
by: WIWA |
last post by:
Hi,
I have installed pySNMP. I want to make an application where I read
out all the OIDs of a MIB of a particular device. In other words, I
want to do an SNMPwalk for a certain MIB.
I can do an SNMPget using pySNMP, because that's one of the examples
on the pySNMP website. There is a lot of information, but to be
honnest - I cannot find my way in these docs. It doesn't give me a
good view on what I have to program.
|
by: Axel Scheepers |
last post by:
Hi All,
Python is so great. I've been creating a small set of objects to get some
stats from our adsl routers. So far it works great and fast. However, in the
shell script I created over a year ago to gather stats I do:
mib_lp=`$snmpwalk $ip_address public
ip.ipAddrTable.ipAddrEntry.ipAdEntIf
Index 2>/dev/null | $grep " = $lan_iface" | $head -1 | $sed -E
's/^ip.ipAddrTabl
|
by: Roy Smith |
last post by:
There's been some talk recently about the relative speeds of the various
python SNMP libraries. I just did a little benchmarking, and got some
surprising results.
I downloaded pysnmp-3.4.2 and build a little mib walk application around
it. I used it to walk ifDescr on an Extreme Summit 48i (48 port
ethernet switch). I did the same thing using snmpwalk from net-snmp
5.0.8.
The switch is back in my office; I'm sitting at home running...
| |
by: Michael Foord |
last post by:
#!/usr/bin/python -u
# 15-09-04
# v1.0.0
# auth_example.py
# A simple script manually demonstrating basic authentication.
# Copyright Michael Foord
# Free to use, modify and relicense.
# No warranty express or implied for the accuracy, fitness to purpose
|
by: relaxedrob |
last post by:
Hi All!
I ran the following w3c example through my WSDL parser (SOA Editor
from Cape Clear):
http://www.w3.org/TR/wsdl#_rpcexample
It told me that there were a bunch of erros about no timeInstant or
float defined in the xsd namespace:
"http://www.w3.org/2000/10/XMLSchema".
|
by: ajikoe |
last post by:
Hello,
I used Visual C# Standard Edition.
I want to comment my program using xml commentary method,
I don't know why if I use value and example tag, it is not working / showed in the html result.
for example I have Property
///<value>this is in description</value>
///<example>this is in Example</example>
public int A{
|
by: rob.audenaerde |
last post by:
I'm trying to monitor about 250 devices with SNMP, using PySNMP version
4. I use the threading.Thread to create a threadpool of 10 threads, so
devices not responding won't slow down the monitoring process too much.
Here comes my problem. When using PySNMP single threaded, every this
goes well; but if I create 10 threads, it all goes awry... It seems
PySNMP is not thread safe? Can anyone elaborate on this?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |