File: v1.html

package info (click to toggle)
python-pysnmp2 2.0.9-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 476 kB
  • ctags: 471
  • sloc: python: 2,091; makefile: 8
file content (203 lines) | stat: -rw-r--r-- 5,715 bytes parent folder | download | duplicates (2)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<HTML>
<HEAD>
<TITLE>PySNMP: SNMP message: Version 1</TITLE>
</HEAD>

<BODY BGCOLOR="#ffffff" TEXT="#000000"
      LINK="#0000bb"  VLINK="#551a8b" ALINK="#ff0000">
<H3>
SNMP message, version 1
</H3>
<P>
The pysnmp.v1 module implements a set of tools aimed at handling SNMP
messages of various types, as introduced by version 1 of SNMP protocol.
</P>
<P>
<DL>
<DT>class <STRONG>GETREQUEST</STRONG>([<STRONG>kwargs</STRONG>])</DT>
<DT>class <STRONG>SETREQUEST</STRONG>([<STRONG>kwargs</STRONG>])</DT>
<DT>class <STRONG>GETNEXTREQUEST</STRONG>([<STRONG>kwargs</STRONG>])</DT>
<DT>class <STRONG>GETRESPONSE</STRONG>([<STRONG>kwargs</STRONG>])</DT>
<DT>class <STRONG>TRAPREQUEST</STRONG>([<STRONG>kwargs</STRONG>])</DT>
<DD>
<P>
Instances of these classes represent SNMP message of corresponding type
of SNMP protocol version 1. The optional <STRONG>kwargs</STRONG> keyword
arguments may be used to initialize arbitrary SNMP message components
(read on).
</P>
<P>
Alternatively, a standard dictionary interface can be used against these
objects for accessing particular message item, though only a fixed set of
keys are allowed. Here is a brief illustration of this concept:
</P>
</DD>
<P>
<PRE>
>>> from pysnmp import v1
>>> req = v1.GETREQUEST()
>>> req.keys()
['encoded_oids', 'encoded_vals', 'request_id', 'error_status', 'tag', 
'error_index', 'version', 'community']
>>> req['community'] = 'mycommunity'
>>> repr(req)
"GETREQUEST(encoded_oids=[], encoded_vals=[], request_id=0, error_status=0, tag='GETREQUEST', error_index=0, version=0, community='mycommunity')"
>>>
</PRE>
</P>
<P>
As it can be seen from the above example, the following key/keyword values
are allowed to instances of the <STRONG>GETREQUEST</STRONG>,
<STRONG>SETREQUEST</STRONG>, <STRONG>GETNEXTREQUEST</STRONG> and
<STRONG>GETRESPONSE</STRONG> classes:
</P>
<P>
<UL>
<LI><STRONG>version</STRONG> - SNMP protocol version being used (default 0)
<LI><STRONG>comminuty</STRONG> - SNMP community name (default 'public')
<LI><STRONG>request_id</STRONG> - SNMP request ID (default 0)
<LI><STRONG>error_status</STRONG> - SNMP error ID (default 0)
<LI><STRONG>error_index</STRONG> - position of errornous OID-value pair (default 0)
<LI><STRONG>encoded_oids</STRONG> - a list of BER encoded ASN.1 Object ID's (default [])
<LI><STRONG>encoded_vals</STRONG> - a list of BER encoded values (default [])
</UL>
</P>
<P>
Instances of TRAPREQUEST() class accept the following key/keyword arguments:
</P>
<P>
<UL>
<LI><STRONG>version</STRONG> - SNMP protocol version being used (default 0)
<LI><STRONG>comminuty</STRONG> - SNMP community name (default 'public')
<LI><STRONG>generic_trap</STRONG> - generic trap ID (default 0)
<LI><STRONG>specific_trap</STRONG> - specific trap ID (default 0)
<LI><STRONG>agent_address</STRONG> - IP address of the agent (default '0.0.0.0')
<LI><STRONG>time_stamp</STRONG> - time stamp (default time.time())
<LI><STRONG>encoded_oids</STRONG> - a list of BER encoded ASN.1 Object ID's (default [])
<LI><STRONG>encoded_vals</STRONG> - a list of BER encoded values (default [])
</UL>
</P>
<P>
The <STRONG>encoded_oids</STRONG> and <STRONG>encoded_vals</STRONG> parameters
can be handled by the instances of corresponding classes from
<A HREF="asn1.html"> SNMP subset of ASN.1 data types</A> module. Here is an
example of how this could be done:
</P>
<P>
<PRE>
>>> from pysnmp import asn1
>>> map(asn1.OBJECTID().encode, ['1.3.6.1.2.1.1.1.0'])
['\006\010+\006\001\002\001\001\001\000']
>>>
</PRE>
</P>
<P>
The Object IDs and their respective values are matched against each other
by their positions in the <STRONG>encoded_oids</STRONG> and
<STRONG>encoded_vals</STRONG> lists.
</P>
</DL>

<DL>
<DT>def <STRONG>decode</STRONG>(<STRONG>data</STRONG>)</DT>
<DD>
<P>
The <STRONG>decode</STRONG> function takes SNMP message carried in a
BER-encoded octet-stream <STRONG>data</STRONG>, and decodes it into a SNMP
message object of matching type.
</P>
<P>
A tuple of (<STRONG>snmp_message_object</STRONG>, <STRONG>rest</STRONG>) is
returned where <STRONG>snmp_message_object</STRONG> is an instance of a SNMP
message class, matching SNMP message type, and the <STRONG>rest</STRONG> is
the unprocessed part of input.
</P>
</DD>
</DL>

<DL>
<DT>exception <STRONG>Error</STRONG></DT>
<DD>
<P>
Exception raised on any error in the <STRONG>pysnmp.v1</STRONG> module,
as well as in its base (<STRONG>pysnmp.asn1</STRONG>) and derivative modules.
This exception class is a subclass of the <STRONG>asn1.Error</STRONG> class.
</P>
<P>
See documentation on the <A HREF="error.html">error.General</A> base class for
usage details.
</P>
</DD>
</DL>

<P>
The following exceptions are derived from this class:
</P>

<DL>
<DT>exception <STRONG>BadPDUType</STRONG></DT>
<DD>
<P>
Unknown BER tag for in SNMP PDU.
</P>
</DD>
</DL>

<DL>
<DT>exception <STRONG>TypeError</STRONG></DT>
<DD>
<P>
Inappropriate type for an v1.* object value.
</P>
</DD>
</DL>

<DL>
<DT>exception <STRONG>BadArgument</STRONG></DT>
<DD>
<P>
Inappropriate argument given.
</P>
</DD>
</DL>

<DL>
<DT>exception <STRONG>BadVersion</STRONG></DT>
<DD>
<P>
Unsupported SNMP version.
</P>
</DD>
</DL>

<DL>
<DT>exception <STRONG>BadEncoding</STRONG></DT>
<DD>
<P>
Malformed BER octet-stream.
</P>
</DD>
</DL>

<HR><STRONG>Subsections</STRONG>

<P>
<UL>
<LI>Objects of the <A HREF="v1-getrequest-objects.html">
<STRONG>v1.GETREQUEST</STRONG>, <STRONG>v1.SETREQUEST</STRONG>,
<STRONG>v1.GETNEXTREQUEST</STRONG></A> classes
<LI>Objects of the <A HREF="v1-getresponse-objects.html">
<STRONG>v1.GETRESPONSE</STRONG></A> class
<LI>Objects of the <A HREF="v1-traprequest-objects.html">
<STRONG>v1.TRAPREQUEST</STRONG></A> class
</UL>
</P>

<HR>

<ADDRESS>
ilya@glas.net
</ADDRESS>

</BODY>
</HTML>