]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / usr.sbin / bsnmpd / tools / bsnmptools / bsnmpget.1
1 .\"
2 .\" Copyright (c) 2010 The FreeBSD Foundation
3 .\" All rights reserved.
4 .\"
5 .\" Portions of this documentation were written by Shteryana Sotirova Shopova
6 .\" under sponsorship from the FreeBSD Foundation.
7 .\"
8 .\" Copyright (c) 2005-2007 The FreeBSD Project.
9 .\"     All rights reserved.
10 .\"
11 .\" Author: Shteryana Shopova <syrinx@FreeBSD.org>
12 .\"
13 .\" Redistribution and use in source and binary forms, with or without
14 .\" modification, are permitted provided that the following conditions
15 .\" are met:
16 .\" 1. Redistributions of source code must retain the above copyright
17 .\"    notice, this list of conditions and the following disclaimer.
18 .\" 2. Redistributions in binary form must reproduce the above copyright
19 .\"    notice, this list of conditions and the following disclaimer in the
20 .\"    documentation and/or other materials provided with the distribution.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\" $FreeBSD$
35 .\"
36 .Dd January 10, 2012
37 .Dt BSNMPGET 1
38 .Os
39 .Sh NAME
40 .Nm bsnmpget ,
41 .Nm bsnmpwalk ,
42 .Nm bsnmpset
43 .Nd "simple tools for querying SNMP agents"
44 .Sh SYNOPSIS
45 .Nm
46 .Op Fl aDdehnK
47 .Op Fl A Ar options
48 .Op Fl b Ar buffersize
49 .Op Fl C Ar options
50 .Op Fl I Ar options
51 .Op Fl i Ar filelist
52 .Op Fl l Ar filename
53 .Op Fl M Ar max-repetitions
54 .Op Fl N Ar non-repeaters
55 .Op Fl o Ar output
56 .Op Fl P Ar options
57 .Op Fl p Ar pdu
58 .Op Fl r Ar retries
59 .Op Fl s Ar [trans::][community@][server][:port]
60 .Op Fl t Ar timeout
61 .Op Fl U Ar options
62 .Op Fl v Ar version
63 .Op Ar OID ...
64 .Pp
65 .Nm bsnmpwalk
66 .Op Fl dhnK
67 .Op Fl A Ar options
68 .Op Fl b Ar buffersize
69 .Op Fl C Ar options
70 .Op Fl I Ar options
71 .Op Fl i Ar filelist
72 .Op Fl l Ar filename
73 .Op Fl o Ar output
74 .Op Fl P Ar options
75 .Op Fl r Ar retries
76 .Op Fl s Ar [trans::][community@][server][:port]
77 .Op Fl t Ar timeout
78 .Op Fl U Ar options
79 .Op Fl v Ar version
80 .Op Ar OID ...
81 .Pp
82 .Nm bsnmpset
83 .Op Fl adehnK
84 .Op Fl A Ar options
85 .Op Fl b Ar buffersize
86 .Op Fl C Ar options
87 .Op Fl I Ar options
88 .Op Fl i Ar filelist
89 .Op Fl l Ar filename
90 .Op Fl o Ar output
91 .Op Fl P Ar options
92 .Op Fl r Ar retries
93 .Op Fl s Ar [trans::][community@][server][:port]
94 .Op Fl t Ar timeout
95 .Op Fl U Ar options
96 .Op Fl v Ar version
97 .Ar OID Ns = Ar syntax Ns : Ns Ar value
98 .Op Ar OID Ns = Ar syntax Ns : Ns Ar value ...
99 .Sh DESCRIPTION
100 .Nm ,
101 .Nm bsnmpwalk
102 and
103 .Nm bsnmpset
104 are simple tools for retrieving management information from and setting
105 management information to a Simple Network Management Protocol (SNMP) agent.
106 .Pp
107 Depending on the options
108 .Nm bsnmpget
109 constructs either a SNMP GetRequest, GetNextRequest
110 or a GetBulkRequest packet, fills in the object identifiers (OIDs) of the
111 objects whose values will be retrieved, waits for a response and prints it if
112 received successfully.
113 .Pp
114 .Nm Bsnmpwalk
115 queries an agent with ether SNMP GetNextRequest or GetBulkRequest packets,
116 asking for values of OID instances that are a part of the object subtree
117 rooted at the provided OIDs.
118 .Pp
119 .Nm Bsnmpset
120 constructs a SNMP SetRequest packet, fills in the OIDs (object identifiers),
121 syntaxes and values of the objects whose values are to be set and waits for a
122 response from server.
123 .Sh OPTIONS
124 The options are as follows (not all apply to all three programs):
125 .Bl -tag -width ".It Fl D Ar options"
126 .It Fl A Ar options
127 Authentication options to use with SNMPv3 PDUs
128 .Bl -tag -width \&
129 .It Cm proto=[md5|sha]
130 The protocol to use when calculating the PDU message digest.
131 .It Cm key=authkey
132 A binary localized authentication key to use when calculating the PDU message
133 digest.
134 .El
135 .Pp
136 By default SNMPv3 PDUs are sent unauthenticated.
137 .It Fl a
138 Skip any sanity checks when adding OIDs to a Protocol Data Unit (PDU):
139 ingore syntax/access type, allow adding of non-leaf objects for GetPdu and
140 read-only objects to a SetPDU.
141 .It Fl b Ar buffersize
142 Tune the size of buffers used to send and receive packets.
143 The default size is 10000 bytes which should be enough unless an agent sends
144 a really large octetstring.
145 The maximum allowed length is 65535 according to the Structure of Management
146 Information (SMIv2).
147 .It Fl C Ar options
148 The context to query with SNMPv3 PDUs.
149 .Bl -tag -width \&
150 .It Cm context=name
151 The context name. Default is "" (empty).
152 .It Cm context-engine=engine-id
153 The SNMP Engine ID of the context to query with SNMPv3 PDUs, represented as
154 binary octet string.
155 By default, this is set to the Engine ID of the SNMP agent.
156 .El
157 .It Fl D
158 Perform SNMP USM Engine Discovery, rather than sending a request for the value
159 of a specific object.
160 .It Fl d
161 Turn on debugging.
162 This option will cause the packets sent and received to be dumped to the
163 terminal.
164 .It Fl e
165 Retry on error.
166 If an error is returned in the response PDU, resend the request removing the
167 variable that caused the error until a valid response is received.
168 This is only useful for a GetRequest- and a GetNextRequest-PDU.
169 .It Fl h
170 Print a short help text with default values for various options.
171 .It Fl I Ar options
172 Load each MIB description file from the given list to translate symbolic
173 object names to their numerical representation and vice versa.
174 Use the other options to obtain a non-default behaviour:
175 .Bl -tag -width \&
176 .It Cm cut=OID
177 Specifies the initial OID that was cut by
178 .Xr gensnmpdef 1
179 when producing the MIB description file.
180 The default value is .iso(1).org(3).dod(6) which is what should have been
181 used for all the files installed under
182 .Pa /usr/share/snmp/defs .
183 Use this only if you generated your own files, providing a
184 .Fl c
185 option to
186 .Xr gensnmpdef 1 .
187 .It Cm path=filedir
188 The directory where files in the list will be searched.
189 The default is
190 .Pa /usr/share/snmp/defs Ns .
191 .It Cm file=filelist
192 A comma separated list of files to which the two options above will apply.
193 .El
194 .Pp
195 The file suboption has to come after the other suboptions so that their
196 non-default values will be applied to the list of files.
197 The order of the other suboptions before each file suboption can be random.
198 Suboptions may be separated either by commas or by spaces.
199 If using spaces make sure the entire option string is one argument, for
200 example using quotes.
201 .It Fl i Ar filelist
202 List of MIB description files produced by
203 .Xr gensnmpdef 1
204 which
205 .Nm bsnmpget ,
206 .Nm bsnmpwalk
207 or
208 .Nm bsnmpset
209 will search to translate numerical OIDs to their symbolic object names.
210 Multiple files can be provided either giving this option multiple times
211 or a comma separated list of file names.
212 If a filename begins with a letter the default directory,
213 .Pa /usr/share/snmp/defs ,
214 will be searched.
215 .It Fl K
216 Calculate and display the localized authentication and privacy keys
217 corresponding to a plain text password.
218 The password is obtained via the environment.
219 Additionally, if one or more OIDs are specified, the calculated
220 keys are used when processing the SNMPv3 requests.
221 .It Fl l Ar filename
222 The path of the posix local (unix domain) socket if local
223 transport is used.
224 .It Fl M Ar max-repetitions
225 The value for the max-repetitions field in a GetBulk PDU.
226 Default is 10.
227 .It Fl N Ar non-repeaters
228 The value for the non-repeaters field in a GetBulk PDU.
229 Default is 0.
230 .It Fl n
231 Only use numerical representations for input and output OIDs and do not
232 try to resolve symbolic object names.
233 Note that
234 .Nm bsnmpget ,
235 .Nm bsnmpwalk
236 and
237 .Nm bsnmpset
238 will print numerical OIDs anyway if the corresponding string representation
239 is not found in the MIB description files.
240 .It Fl o Ar [quiet|short|verbose]
241 The format used to print the received response.
242 Quiet only prints values, short (default) prints an abbreviated OID
243 representation and the value.
244 In addition to the short output verbose prints the type before the value.
245 .It Fl P Ar options
246 Privacy options to use with SNMPv3 PDUs
247 .Bl -tag -width \&
248 .It Cm proto=[aes|des]
249 The protocol to use when encrypting/decrypting SNMPv3 PDU data.
250 .It Cm key=privkey
251 A binary localized privacy key to use when encrypting/decrypting SNMPv3 PDU data.
252 .El
253 .Pp
254 By default plain text SNMPv3 PDUs are sent.
255 .It Fl p Ar [get|getnext|getbulk]
256 The PDU type to send by
257 .Nm bsmpget
258 and
259 .Nm bsnmpwalk .
260 Default is get
261 for
262 .Nm bsmpget
263 and getnext for
264 .Nm bsnmpwalk .
265 Getbulk allows executing the so called SNMP "bulkwalks" allowing the values of
266 multiple columns to be retrieved in a single PDU by
267 .Nm bsnmpwalk .
268 .It Fl r Ar retries
269 Number of resends of request packets before giving up if the agent does
270 not respond after the first try.
271 Default is 3.
272 .It Fl s Ar [trans::] Ns Ar [community@] Ns Ar [server] Ns Ar [:port]
273 Each of the server specification components is optional but at least one
274 has to be provided if the
275 .Ar s
276 option is used.
277 The server specification is constructed in the following manner:
278 .Bl -tag -width \&
279 .It Cm trans::
280 Transport type may be one of udp, stream or dgram.
281 If this option is not provided an UDP inet/inet6 socket will be used, which
282 is the most common.
283 Stream stands for a posix local stream socket and a posix local datagram
284 socket will be used if dgram is specified.
285 .It Cm community@
286 Specify an SNMP community string to be used when sending packets.
287 If the option is skipped the default "public" will be used for
288 .Nm
289 and
290 .Nm bsnmpwalk
291 and the default "private" community string will be used for
292 .Nm bsnmpset .
293 .It Cm server
294 This might be either the IP address or the hostname where the agent is
295 listening.
296 The default is
297 .Qq localhost .
298 .It Cm port
299 The destination port to send the requests to.
300 This is useful if the SNMP agent listens on a non-default port.
301 Default is given by the
302 .Qq snmp
303 entry in
304 .Pa /etc/services ,
305 port 161.
306 .El
307 .It Fl t Ar timeout
308 Number of seconds before resending a request packet if the agent does
309 not respond.
310 The default value is 3 seconds.
311 .It Fl U Ar options
312 User credentials when sending SNMPv3 PDUs.
313 .Bl -tag -width \&
314 .It Cm engine=id
315 The Engine ID of the SNMP agent represented as a binary octet string.
316 .It Cm engine-boots=value
317 The value of the snmpEngineBoots of the SNMP agent.
318 .It Cm engine-time=value
319 The value of the snmpEngineTime of the SNMP agent.
320 .Pp
321 If any of the above is not specified, SNMP USM Engine Discovery is attempted.
322 This is also the default behavior.
323 .It Cm name=username
324 The USM user name to include in the SNMPv3 PDUs.
325 By default, the user name is
326 obtained via the environment.
327 .El
328 .It Fl v Ar version
329 The SNMP protocol version to use when sending requests.
330 SNMP versions 1, 2 and
331 3 are supported.
332 If no version option is provided
333 .Nm bsnmpget ,
334 .Nm bsnmpwalk
335 and
336 .Nm bsnmpset
337 will use version 2.
338 Note that GetBulkRequest-PDUs were introduced in SNMPv2 thus setting the
339 version to 1 is incompatible with sending a GetBulk PDU.
340 .It OID
341 The object identifier whose value to retrieve.
342 At least one OID should be provided for
343 .Nm bsnmpget
344 to be able to send a request.
345 .Pp
346 For
347 .Nm bsnmpwalk
348 this is the root object identifier of the subtree whose values are to be
349 retrieved.
350 If no OID is provided
351 .Nm bsnmpwalk
352 will walk the mib2 subtree rooted
353 at .iso(1).org(3).dod(6).internet(1).mgmt(2).mib2(1) .
354 .Pp
355 Any of the formats used to print a single variable
356 is valid as input OID:
357 .Bl -tag -width \&
358 .It 1.3.6.1.2.1.25.1.1.0
359 .It sysDescr
360 .It ifPhysAddress.1
361 .It ifRcvAddressStatus.2.6.255.255.255.255.255.255
362 .It ifRcvAddressType[2,ff:ff:ff:ff:ff:ff]
363 .It ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]
364 (requires the
365 .Fl o Ar verbose
366 option)
367 .El
368 .Pp
369 Square brackets are used to denote an entry's indexes.
370 When used in an input OID, the square brackets may have to be
371 escaped or the OID has to be quoted to protect it from the shell.
372 Note there is no difference between ifName.1 and "ifName[1]".
373 .It OID Ns = Ns Ar [syntax Ns :] Ns Ar value
374 The object identifier with its syntax type and value that is to be set.
375 At least one such string OID=[syntax:]value should be provided to
376 .Nm bsnmpset
377 to be able to send a request.
378 .Bl -tag -width \&
379 .It Cm OID
380 OID may be input as a string, a string followed by a random number of integers
381 (suboids) separated by dots, a sequence of integers separated by dots - that is
382 if the
383 .Ar n
384 option is used - and in such case a syntax is required for every value,
385 or a string followed by square brackets (used to denote an entry's indexes) and
386 corresponding indexes.
387 Any of the formats used to print a single variable by
388 .Nm bsnmpset
389 is valid as input OID as well:
390 .Bl -tag -width \&
391 .It 1.3.6.1.2.1.25.1.1.0=TimeTicks:537615486
392 .It sysLocation=OctetString:"@ Home" (with Fl o Ar verbose No option)
393 .It sysLocation.0="@ Home"
394 .It 1.3.6.1.2.1.2.2.1.6.1=OctetString:ffffffffffff
395 .It ifPhysAddress.1="00:02:b3:1d:1c:a3"
396 .It ifRcvAddressStatus.1.6.255.255.255.255.255.255=1
397 .It "ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]=Integer:1"
398 (with the
399 .Fl o Ar verbose
400 option)
401 .El
402 .It Cm syntax
403 where the syntax string is one of:
404 Integer, OctetString, OID, IpAddress, Counter32, Gauge, TimeTicks, Counter64.
405 .It Cm value
406 The value to be set - IP address in form of u.u.u.u - for example
407 1.3.1.6.1.2.0=IpAddress:192.168.0.1, strings require inverted-commas if they
408 contain any special characters or spaces, all other numeric types do not.
409 .El
410 .El
411 .Sh ENVIRONMENT
412 .Nm ,
413 .Nm bsnmpwalk
414 and
415 .Nm bsnmpset
416 use the following environment variables:
417 .Bl -tag -width SNMPAUTH
418 .It Ev SNMPAUTH
419 Specifies a default SNMP USM authentication protocol.
420 .It Ev SNMPPRIV
421 Specifies a default SNMP USM privacy protocol.
422 .It Ev SNMPUSER
423 Specifies a default SNMP USM user name.
424 .It Ev SNMPPASSWD
425 Specifies the SNMP USM plain text password to use when calculating localized
426 authentication and privacy keys.
427 If this variable exists in the environment,
428 SNMPv3 is the default version to use for outgoing requests.
429 .El
430 .Sh SEE ALSO
431 .Xr gensnmpdef 1
432 .Sh AUTHORS
433 .An Shteryana Shopova Aq syrinx@FreeBSD.org