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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
.\" $OpenBSD: snmp.1,v 1.13 2020/04/23 21:28:09 jmc Exp $
.\"
.\" Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: April 23 2020 $
.Dt SNMP 1
.Os
.Sh NAME
.Nm snmp
.Nd simple SNMP client
.Sh SYNOPSIS
.Nm
.Cm get | getnext | bulkget
.Op Ar options
.Ar agent
.Ar oid ...
.Nm
.Cm walk | bulkwalk
.Op Ar options
.Ar agent
.Op Ar oid
.Nm
.Cm set
.Op Ar options
.Ar agent
.Ar varoid type value
.Oo Ar varoid type value Oc ...
.Nm
.Cm trap
.Op Ar options
.Ar agent uptime trapoid
.Oo Ar varoid type value Oc ...
.Nm
.Cm df
.Op Ar options
.Ar agent
.Nm
.Cm mibtree
.Op Fl O Ar fns
.Sh DESCRIPTION
The
.Nm
utility is a simple SNMP client.
.Pp
The subcommands are as follows:
.Bl -tag -width Ds
.It Xo
.Nm snmp
.Cm get
.Op Ar options
.Ar agent oid ...
.Xc
Retrieve the varbind for
.Ar oid
from the
.Ar agent .
If more than one
.Ar oid
is specified, retrieve the varbind for each one.
.It Xo
.Nm snmp
.Cm getnext
.Op Ar options
.Ar agent oid ...
.Xc
Retrieve the varbind that follows
.Ar oid
from the
.Ar agent .
If more than one
.Ar oid
is specified, retrieve the varbind following each one of them.
.It Nm snmp Cm walk Oo Ar options Oc Ar agent Op Ar oid
Retrieve all the varbinds that are branches of
.Ar oid
from the
.Ar agent .
This uses the
.Cm getnext
subcommand internally and requests a single varbind at a time.
If no
.Ar oid
is specified it defaults to mib-2
.Pq .1.3.6.1.2.1 .
.It Xo
.Nm snmp
.Cm bulkget
.Op Ar options
.Ar agent oid ...
.Xc
Retrieve the next 10 varbinds following each
.Ar oid
from the
.Ar agent .
This command is not available for
.Fl v Cm 1 .
.It Xo
.Nm snmp
.Cm bulkwalk
.Op Ar options
.Ar agent
.Op Ar oid
.Xc
Retrieve all the varbinds from the
.Ar agent
that are branches of
.Ar oid .
This uses the
.Cm bulkget
subcommand internally to retrieve multiple varbinds at a time.
This command is not available for
.Fl v Cm 1 .
.It Xo
.Nm snmp
.Cm set
.Op Ar options
.Ar agent varoid type value ...
.Xc
Set one or more
.Ar varoid to a new
.Ar value .
The format of the
.Ar varoid type value
triple is described in
.Sx Data types ,
below.
.It Xo
.Nm snmp
.Cm trap
.Op Ar options
.Ar agent uptime trapoid
.Op Ar varoid type value ...
.Xc
Send a trap message to the
.Ar agent .
The
.Ar uptime
is specified in timeticks
.Pq centiseconds
or defaults to the system uptime if an empty string is given.
The
.Ar trapoid
is the identification OID used by the trap handler to determine its action.
This command is not available for
.Fl v Cm 1 .
.It Xo
.Nm
.Cm df
.Op Ar options
.Ar agent
.Xc
An SNMP based version of the
.Xr df 1
command.
If no size suffix is shown the sizes are in kilobytes.
.It Nm Cm mibtree Op Fl O Ar fnS
Dump the tree of compiled-in MIB objects.
.El
.Pp
The
.Ar options
are as follows:
.Bl -tag -width Ds
.It Fl A Ar authpass
The authentication password for the user.
This will be transformed to
.Ar localauth .
This option is only used by
.Fl v Cm 3 .
.It Fl a Ar digest
Set the digest
.Pq authentication
protocol.
Options are
.Cm MD5 ,
.Cm SHA ,
.Cm SHA-224 ,
.Cm SHA-256 ,
.Cm SHA-384
or
.Cm SHA-512 .
This option defaults to
.Cm MD5 .
This option is only used by
.Fl v Cm 3 .
.It Fl C Ar appopt
For the
.Cm bulkget ,
.Cm bulkwalk ,
.Cm df ,
and
.Cm walk
subcommands, set the application specific
.Ar appopt
options by supplying a string of one or more
of the following modifier letters:
.Bl -tag -width Ds
.It Cm c
For
.Cm walk
and
.Cm bulkwalk ,
disable checking the order of MIBs.
On some devices that return MIBs out of order,
this may cause an infinite loop.
.It Cm E Ar endoid
For
.Cm walk ,
walk the tree up to but excluding
.Ar endoid .
The blank before
.Ar endoid
is mandatory.
.It Cm h
For
.Cm df
print the output in
.Dq human-readable
format.
.It Cm I
For
.Cm walk ,
do not fall back to returning the original MIB via a
.Cm get
request.
.It Cm i
For
.Cm walk
and
.Cm bulkwalk ,
always do a
.Cm get
request on the specified
.Ar oid
first.
.It Cm n Ns Ar nonrep
For
.Cm bulkget
and
.Cm bulkwalk ,
Set the non-repeaters field in the request to the non-negative integer
.Ar nonrep .
This causes the first
.Ar nonrep
.Ar oid
arguments to only return a single MIB instead of
.Ar maxrep .
This value defaults to 0.
No blank is allowed before
.Ar nonrep .
.It Cm p
For
.Cm walk
or
.Cm bulkwalk ,
also show a summary of the total variables received.
.It Cm r Ns Ar maxrep
For
.Cm bulkget ,
.Cm bulkwalk
and
.Cm df ,
set the max-repetitions field in the request to the positive integer
.Ar maxrep .
This determines the amount of MIBs to return for each specified OID.
This value defaults to 10.
No blank is allowed before
.Ar maxrep .
.It Cm s Ar skipoid
For
.Cm walk
or
.Cm bulkwalk
don't include
.Ar skipoid
or its children in the walk output.
The blank before
.Ar skipoid
is mandatory.
.It Cm t
For
.Cm walk ,
Show how long it took to walk the entire tree.
.El
.It Fl c Ar community
Set the
.Ar community
string.
Defaults to
.Cm public .
This option is only used by
.Fl v Cm 1
and
.Fl v Cm 2c .
.It Fl e Ar secengineid
The USM security engine id.
Under normal circumstances this value is discovered via snmpv3 discovery and
does not need to be specified.
This option is only used by
.Fl v Cm 3 .
.It Fl E Ar ctxengineid
The snmpv3 context engine id.
Most of the time this value can be safely ignored.
This option is only used by
.Fl v Cm 3 .
.It Fl K Ar localpriv
The localized privacy password for the user in hexadecimal format
.Po
optionally prefixed with a
.Cm 0x
.Pc .
This option is only used by
.Fl v Cm 3 .
.It Fl k Ar localauth
The localized authentication password for the user in hexadecimal format
.Po
optionally prefixed with a
.Cm 0x
.Pc .
This option is only used by
.Fl v Cm 3 .
.It Fl l Ar seclevel
The security level.
Values can be
.Cm noAuthNoPriv Pq default ,
.Cm authNoPriv
.Po
requires either
.Fl A
or
.Fl k
.Pc
or
.Cm authPriv
.Po
requires either
.Fl X
or
.Fl K
in addition to the
.Cm authNoPriv
requirements
.Pc .
This option is only used by
.Fl v Cm 3 .
.It Fl n Ar ctxname
Sets the context name.
Defaults to an empty string.
This option is only used by
.Fl v Cm 3 .
.It Fl O Ar output
Set the
.Ar output
options by supplying a string of one or more
of the following modifier letters:
.Bl -tag -width 1n
.It Cm a
Print the varbind string unchanged
rather than replacing non-printable bytes with dots.
.It Cm f
When displaying an OID, include the full list of MIB objects.
By default only the last textual MIB object is shown.
.It Cm n
Display the OID numerically.
.It Cm Q
Remove the type information.
.It Cm q
Remove the type information and the equal sign.
.It Cm S
Display the MIB name and the type information.
This is the default behaviour.
.It Cm v
Only display the varbind value, removing the OID.
.It Cm x
Display the varbind string values as hexadecimal strings.
.El
.Pp
The
.Cm mibtree
subcommand may only use the
.Op Fl fnS
output options;
no output options are available for
.Cm trap .
.It Fl r Ar retries
Set the number of
.Ar retries
in case of packet loss.
Defaults to 5.
.It Fl t Ar timeout
Set the
.Ar timeout
to wait for a reply, in seconds.
Defaults to 1.
.It Fl u Ar user
Sets the username.
If
.Fl v Cm 3
is used this option is required.
This option is only used by
.Fl v Cm 3 .
.It Fl v Ar version
Set the snmp protocol
.Ar version
to either
.Cm 1 ,
.Cm 2c
or
.Cm 3 .
Currently defaults to
.Cm 2c .
.It Fl X Ar privpass
The privacy password for the user.
This will be tansformed to
.Ar localpriv .
This option is only used by
.Fl v Cm 3 .
.It Fl x Ar cipher
Sets the cipher
.Pq privacy
protocol.
Options are
.Cm DES
and
.Cm AES .
This option is only used by
.Fl v Cm 3 .
.It Fl Z Ar boots , Ns Ar time
Set the engine boots and engine time.
Under normal circumstances this value is discovered via snmpv3 discovery and
does not need to be specified.
This option is only used by
.Fl v Cm 3 .
.El
.Pp
The syntax for the
.Ar agent
argument is
.Oo Ar protocol : Oc Ns Ar address ,
with the following format:
.Bl -column udp6XXXtcp6X address -offset indent
.It Ar protocol Ta Ar address
.It Cm udp | tcp Ta Ar hostname Ns Oo Pf : Ar port Oc |
.Ar IPv4-address Ns Op Pf : Ar port
.It Cm udp6 | tcp6 Ta Ar hostname Ns Oo Pf : Ar port Oc |
.Cm \&[ Ns Ar IPv6-address Ns Cm \&] Ns Oo Pf : Ar port Oc |
.Ar IPv6-address Ns Pf : Ar port
.It Cm unix Ta Ar pathname
.El
.Pp
The default
.Ar protocol
is
.Cm udp
and the default
.Ar port
is 161, except for the
.Cm trap
subcommand, which uses 162.
.Cm udpv6
and
.Cm udpipv6
are aliases for
.Cm udp6 ;
.Cm tcpv6
and
.Cm tcpipv6
for
.Cm tcp6 .
To specify an IPv6-address without a
.Ar port ,
the
.Ar IPv6-address
must be enclosed in square brackets.
If the square brackets are omitted,
the value after the last colon is always interpreted as a
.Ar port .
.Ss Data types
Additional data sent to the server is formatted by specifying one or more
triples of
.Ar varoid ,
.Ar type ,
and
.Ar value .
Supported types are:
.Bl -tag -width 1n -offset indent
.It Cm a
An IPv4 Address.
.It Cm b
A bitstring.
A list of individual bit offsets separated by comma, space or tab.
Must be supplied as a single argument.
.It Cm c
A counter32.
.It Cm d
A decimal string.
A list of individual bytes in decimal form separated by space or tab.
.It Cm i
An integer.
.It Cm n
A null object.
.It Cm o
An OID.
.It Cm s
A regular string.
.It Cm t
Timeticks in centiseconds.
.It Cm u
Unsigned integer.
Actually a normal integer for compatibility with netsnmp.
.It Cm x
A hex string.
Similar to a decimal string, but in hexadecimal format.
.El
.Sh SEE ALSO
.Xr snmpd 8
.Sh HISTORY
The
.Nm
program first appeared in
.Ox 6.6 .
.Sh AUTHORS
The
.Nm
program was written by
.An Martijn van Duren Aq Mt martijn@openbsd.org .
|