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