summaryrefslogtreecommitdiff
path: root/README
blob: 1d3093986e601c7d167a4bbf5f9654ebeed80298 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

SNMP engine for Python, version 3.0.0
-------------------------------------

This is a Python implementation of SNMP v.1/v.2c engine. Its general
functionality is to assemble/disassemble SNMP messages from/into
given SNMP Object IDs along with associated values. PySNMP also provides
a few transport methods specific to TCP/IP networking.

PySNMP is written entirely in Python and is self-sufficient in terms
that it does not rely on any third party tool (it is not a wrapper!).

This code is compatible with Python interpreter versions 1.x and 2.x.

The PySNMP package is distributed under terms and conditions of BSD-style
license. See the LICENSE file for details.

PRECAUTIONS
-----------

In its 3.x revision, the PySNMP software underwent a major re-write for
a more accurate, standards compliant and extensible implementation,
although [hopefully] complete compatibility with all previous PySNMP
implementations is preserved by means of compatibility sub-packages.
Please, refer to package documentation for more information.

Since MIB support is not integrated into PySNMP package at the moment, this
software accept and report Object IDs only in a non-symbolic (dotted) notation.

INSTALLATION
------------

You might try distutils to install PySNMP by just typing:

$ python setup.py install

This should work on Unix and Microsoft Windows. Alternatively you can
install PySNMP by hand:

On UNIX, the pysnmp package can be put into the python/site-packages/
directory in the following way (assuming your Python distribution
resides under /usr/local/lib/python):

$ cd /usr/local/lib/python/site-packages
$ tar xvf /tmp/pysnmp-3.0.0.tar
$ echo pysnmp-3.0.0 > pysnmp.pth

Alternatively, the $PYTHONPATH environment variable can be updated to
point to your PySNMP package location (assuming your UNIX shell is bash):

export PYTHONPATH=/home/ilya/src/py/pysnmp-3.0.0:$PYTHONPATH

The latter trick is also known to work on Windows.

I've been told, that on Windows 2000, one needs to go to "Control panel"
-> "System" -> "Advanced" -> "Environment variables" and add/update the
PYTHONPATH environment variable there.

OPERATION
---------

Here is an example of using pysnmp package for querying SNMP agent
(cisco router) for arbitrary value.

8X---------------- cut here --------------------

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.mapping.udp import role
>>> req = v1.GetRequest()
>>> req['pdu']['get_request']['variable_bindings'].append(v1.VarBind(name=v1.ObjectName('1.3.6.1.2.1.1.1.0')))
>>> tr = role.manager(('router-1.glas.net', 161))
>>> (answer, src) = tr.send_and_receive(req.encode())
>>> rsp = v1.GetResponse()
>>> rsp.decode(answer)
>>> oids = map(lambda x: x['name'].get(), rsp['pdu']['get_response']['variable_bindings'])
>>> print oids
['.1.3.6.1.2.1.1.1.0']
>>> vals = map(lambda x: x['value'], rsp['pdu']['get_response']['variable_bindings'])
>>> print vals
[ObjectSyntax(simple=SimpleSyntax(string=OctetString('Cisco Internetwork Operating System Software \015\012IOS (tm) 5400 Software (C5400-JS-M), Version 12.2(11.8b), MAINTENANCE INTERIM SOFTWARE\015\012Copyright (c) 1986-2002 by cisco Systems, Inc.\015\012Compiled Tue 30-Jul-02 19:02 by pwade')))]
>>>

8X---------------- cut here --------------------

See package documentation and examples/ directory for more information
on PySNMP services.

AVAILABILITY
------------

The PySNMP software is available for download from project's homepage:
http://sourceforge.net/projects/pysnmp/

GETTING HELP
------------

Once anything does not work as expected, please, try browsing PySNMP
mailing list archives at http://sourceforge.net/mail/?group_id=14735
or post your question there.

FEEDBACK
--------

I'm interested in bug reports and fixes, suggestions and improvements.
I'd be happy knowning whenever you used the PySNMP software for whatever
purpose. Please, send me a note then. Thanks!

=-=-=
mailto: ilya@glas.net