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