xref: /freebsd/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1 (revision 50d675f7a9fca2f3fba3a23ac41a8ae2c0162e4e)
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
102and
103.Nm bsnmpset
104are simple tools for retrieving management information from and setting
105management information to a Simple Network Management Protocol (SNMP) agent.
106.Pp
107Depending on the options
108.Nm bsnmpget
109constructs either a SMNP GetRequest, GetNextRequest
110or a GetBulkRequest packet, fills in the object identifiers (OIDs) of the
111objects whose values will be retrived, waits for a response and prints it if
112received successfully.
113.Pp
114.Nm Bsnmpwalk
115queries an agent with ether SMNP GetNextRequest or GetBulkRequest packets,
116asking for values of OID instances that are a part of the object subtree
117rooted at the provided OIDs.
118.Pp
119.Nm Bsnmpset
120constructs a SMNP SetRequest packet, fills in the OIDs (object identifiers),
121syntaxes and values of the objects whose values are to be set and waits for a
122response from server.
123.Sh OPTIONS
124The 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
127Authentication options to use with SNMPv3 PDUs
128.Bl -tag -width \&
129.It Cm proto=[md5|sha]
130The protocol to use when calculating the PDU message digest.
131.It Cm key=authkey
132A binary localized authentication key to use when calculating the PDU message
133digest.
134.El
135.Pp
136By default SNMPv3 PDUs are sent unauthenticated.
137.It Fl a
138Skip any sanity checks when adding OIDs to a Protocol Data Unit (PDU):
139ingore syntax/access type, allow adding of non-leaf objects for GetPdu and
140read-only objects to a SetPDU.
141.It Fl b Ar buffersize
142Tune the size of buffers used to send and receive packets.
143The default size is 10000 bytes which should be enough unless an agent sends
144a really large octetstring.
145The maximum allowed length is 65535 according to the Structure of Management
146Information (SMIv2).
147.It Fl C Ar options
148The context to query with SNMPv3 PDUs.
149.Bl -tag -width \&
150.It Cm context=name
151The context name. Default is "" (empty).
152.It Cm context-engine=engine-id
153The SNMP Engine ID of the context to query with SNMPv3 PDUs, represented as
154binary octet string. By default, this is set to the Engine ID of the SNMP agent.
155.El
156.It Fl D
157Perform SNMP USM Engine Discovery, rather than sending a request for the value
158of a specific object.
159.It Fl d
160Turn on debugging.
161This option will cause the packets sent and received to be dumped to the
162terminal.
163.It Fl e
164Retry on error.
165If an error is returned in the response PDU, resend the request removing the
166variable that caused the error until a valid response is received.
167This is only useful for a GetRequest- and a GetNextRequest-PDU.
168.It Fl h
169Print a short help text with default values for various options.
170.It Fl I Ar options
171Load each MIB description file from the given list to translate symbolic
172object names to their numerical representation and vice versa.
173Use the other options to obtain a non-default behaviour:
174.Bl -tag -width \&
175.It Cm cut=OID
176Specifies the initial OID that was cut by
177.Xr gensnmpdef 1
178when producing the MIB description file.
179The default value is .iso(1).org(3).dod(6) which is what should have been
180used for all the files installed under /usr/share/snmp/defs.
181Use this only if you generated your own files, providing a
182.Fl c
183option to
184.Xr gensnmpdef 1 .
185.It Cm path=filedir
186The directory where files in the list will be searched.
187The default is
188.Pa /usr/share/snmp/defs Ns .
189.It Cm file=filelist
190A comma separated list of files to which the two options above will apply.
191.El
192.Pp
193The file suboption has to come after the other suboptions so that their
194non-default values will be applied to the list of files.
195The order of the other suboptions before each file suboption can be random.
196Suboptions may be separated either by commas or by spaces.
197If using spaces make sure the entire option string is one argument, for
198example using quotes.
199.It Fl i Ar filelist
200List of MIB description files produced by
201.Xr gensnmpdef 1 which
202.Nm bsnmpget ,
203.Nm bsnmpwalk
204or
205.Nm bsnmpset
206will search to translate numerical OIDs to their symbolic object names.
207Multiple files can be provided either giving this option multiple times
208or a comma separated list of file names.
209If a filename begins with a letter the default directory,
210/usr/share/snmp/defs,
211will be searched.
212.It Fl K
213Calculate and display the localized authentication and privacy keys
214corresponding to a plain text password. The password is obtain via the
215environment. Additionally, if one or more OIDs are specified, the calculated
216keys are used when processing the SNMPv3 requests.
217.It Fl l Ar filename
218The path of the posix local (unix domain) socket if local
219transport is used.
220.It Fl M Ar max-repetitions
221The value for the max-repetitions field in a GetBulk PDU.
222Default is 10.
223.It Fl N Ar non-repeaters
224The value for the non-repeaters field in a GetBulk PDU.
225Default is 0.
226.It Fl n
227Only use numerical representations for input and output OIDs and do not
228try to resolve symbolic object names.
229Note that
230.Nm bsnmpget ,
231.Nm bsnmpwalk
232and
233.Nm bsnmpset
234will print numerical OIDs anyway if the corresponding string representation
235is not found in the MIB description files.
236.It Fl o Ar [quiet|short|verbose]
237The format used to print the received response.
238Quiet only prints values, short (default) prints an abbreviated OID
239representation and the value.
240In addition to the short output verbose prints the type before the value.
241.It Fl P Ar options
242Privacy options to use with SNMPv3 PDUs
243.Bl -tag -width \&
244.It Cm proto=[aes|des]
245The protocol to use when encypting/decrypting SNMPv3 PDU data.
246.It Cm key=privkey
247A binary localized privacy key to use when encypting/decrypting SNMPv3 PDU data.
248.El
249.Pp
250By default plain text SNMPv3 PDUs are sent.
251.It Fl p Ar [get|getnext|getbulk]
252The PDU type to send by
253.Nm bsmpget
254and
255.Nm bsnmpwalk .
256Default is get
257for
258.Nm bsmpget
259and getnext for
260.Nm bsnmpwalk .
261Getbulk allows executing the so called SNMP "bulkwalks" allowing the values of
262multiple columns to be retrived in a single PDU by
263.Nm bsnmpwalk .
264.It Fl r Ar retries
265Number of resends of request packets before giving up if the agent does
266not respond after the first try.
267Default is 3.
268.It Fl s Ar [trans::] Ns Ar [community@] Ns Ar [server] Ns Ar [:port]
269Each of the server specification components is optional but at least one
270has to be provided if
271.Ar s
272option is used.
273The server specification is constructed in the following manner:
274.Bl -tag -width \&
275.It Cm trans::
276Transport type may be one of udp, stream or dgram.
277If this option is not provided an udp inet/inet6 socket will be used, which
278is the most common.
279Stream stands for a posix local stream socket and a posix local datagram
280socket will be used if dgram is specified.
281.It Cm community@
282Specify an SNMP community string to be used when sending packets.
283If the option is skipped the default "public" will be used for
284.Nm
285and
286.Nm bsnmpwalk
287and the default "private" community string will be used for
288.Nm bsnmpset .
289.It Cm server
290This might be either the IP address or the hostname where the agent is
291listening.
292The default is
293.Qq localhost .
294.It Cm port
295The destination port to send the requests to.
296This is useful if the SNMP agent listens on a non-default port.
297Default is given by the
298.Qq snmp
299entry in
300.Pa /etc/services ,
301port 161.
302.El
303.It Fl t Ar timeout
304Number of seconds before resending a request packet if the agent does
305not respond.
306The default value is 3 seconds.
307.It Fl U Ar options
308User credentials when sending SNMPv3 PDUs.
309.Bl -tag -width \&
310.It Cm engine=id
311The Engine ID of the SNMP agent represented as a binary octet string.
312.It Cm engine-boots=value
313The value of the snmpEngineBoots of the SNMP agent.
314.It Cm engine-time=value
315The value of the snmpEngineTime of the SNMP agent.
316.Pp
317If any of the above is not specified, SNMP USM Engine Discovery is attempted.
318This is also the default behavior.
319.It Cm name=username
320The USM user name to include in the SNMPv3 PDUs. By default, the user name is
321obtain via the environment
322.El
323.It Fl v Ar version
324The SNMP protocol version to use when sending requests. SNMP versions 1, 2 and
3253 are supported.
326If no version option is provided
327.Nm bsnmpget ,
328.Nm bsnmpwalk
329and
330.Nm bsnmpset
331will use version 2.
332Note that GetBulkRequest-PDUs were introduced in SNMPv2 thus setting the
333version to 1 is incompatiable with sending a GetBulk PDU.
334.It OID
335The object identifier whose value to retrive.
336At least one OID should be provided for
337.Nm bsnmpget
338to be able to send a request.
339.Pp
340For
341.Nm bsnmpwalk
342this is the root object identifier of the subtree whose values are to be
343retrived.
344If no OID is provided
345.Nm bsnmpwalk
346will walk the mib2 subtree rooted
347at .iso(1).org(3).dod(6).internet(1).mgmt(2).mib2(1) .
348.Pp
349Any of the formats used to print a single variable
350is valid as input OID:
351.Bl -tag -width \&
352.It 1.3.6.1.2.1.25.1.1.0
353.It sysDescr
354.It ifPhysAddress.1
355.It ifRcvAddressStatus.2.6.255.255.255.255.255.255
356.It ifRcvAddressType[2,ff:ff:ff:ff:ff:ff]
357.It ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]
358(requires
359.Fl o Ar verbose
360option)
361.El
362.Pp
363Square brackets are used to denote an entry's indexes.
364When used in an input OID, the square brackets may have to be
365escaped or the OID has to be quoted to protect it from the shell.
366Note there is no difference between ifName.1 and "ifName[1]".
367.It OID Ns = Ns Ar [syntax Ns :] Ns Ar value
368The object identifier with its syntax type and value that is to be set.
369At least one such string OID=[syntax:]value should be provided to
370.Nm bsnmpset
371to be able to send a request.
372.Bl -tag -width \&
373.It Cm OID
374OID may be input as a string, a string followed by a random number of integers
375(suboids) separated by dots, a sequence of integers separated by dots - that is
376if
377.Ar n
378options is used - and in such case a syntax is required for every value,
379or a string followed by square brackets (used to denote an entry's indexes) and
380corresponding indexes.
381Any of formats used to print a single variable by
382.Nm bsnmpset is
383valid for inpit OID as well:
384.Bl -tag -width \&
385.It 1.3.6.1.2.1.25.1.1.0=TimeTicks:537615486
386.It sysLocation=OctetString:"@ Home" (with Fl o Ar verbose No option)
387.It sysLocation.0="@ Home"
388.It 1.3.6.1.2.1.2.2.1.6.1=OctetString:ffffffffffff
389.It ifPhysAddress.1="00:02:b3:1d:1c:a3"
390.It ifRcvAddressStatus.1.6.255.255.255.255.255.255=1
391.It "ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]=Integer:1"
392(with
393.Fl o Ar verbose
394option)
395.El
396.It Cm syntax
397where syntax string is one of:
398Integer, OctetString, OID, IpAddress, Counter32, Gauge, TimeTicks, Counter64.
399.It Cm value
400The value to be set - IP address in form of u.u.u.u - for example
4011.3.1.6.1.2.0=IpAddress:192.168.0.1, strings require inverted-commas if they
402contain any special characters or spaces, all other numeric types don't.
403.El
404.El
405.Sh ENVIRONMENT
406.Nm ,
407.Nm bsnmpwalk
408and
409.Nm bsnmpset
410use the following environment variables:
411.Bl -tag -width SNMPAUTH
412.It Ev SNMPAUTH
413Specifies a default SNMP USM authentication protocol.
414.It Ev SNMPPRIV
415Specifies a default SNMP USM privacy protocol.
416.It Ev SNMPUSER
417Specifies a default SNMP USM user name.
418.It Ev SNMPPASSWD
419Specifies the SNMP USM plain text password to use when calculating localized
420authentication and privacy keys. If this variable exists in the environment,
421SMNPv3 is the default version to use for outgoing requests.
422.El
423.Sh SEE ALSO
424.Xr gensnmpdef 1
425.Sh AUTHORS
426.An Shteryana Shopova Aq syrinx@FreeBSD.org
427