# Chapter 12

| # Developer Environment Tools

> This chapter describes the following SNMP commands:

- snmpset--page 233
- snmpget--page 237
- snmpnext--page 240
- snmptrap--page 243
- snmpwalk--page 246
- snmpwalktable--page 248

> The following sections present the information in the format of man pages.

## `snmpset`

### Name

> `snmpset`--Change information in manageable nodes with SNMP

### Synopsis

    /opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpset -h host \
    [-p port] [-t timeout] [-i requestID] [-c community] name1 type1 \
    value1 ... nameN typeN  valueN

### Description

> With `snmpset` you can change information on a manageable node if you have sufficient access privilege and the node is writable. You specify what information you want to change with the objectid. Then you specify the type of data.

### Options

`-h` host
host is the hostname of the machine on which the agent is running. The hostname can be either the domain hostname or the IP address in dot notation.
`-p` port
Normally the remote port 161/UDP is used. If you run your snmp agent on an another port you can specify which port here. The default value is taken from environment variable SNMP_PORT. If this variable is not set then the value is taken from services file's entry snmp/udp.
`-t` timeout
Change the timeout time for each retry. Time is given in seconds. The default timeout is 5 seconds.
`-i` requestID
This integer value is used to differentiate different requests. The default requestID is 0.
`-c` community
This string will be used as community name. The default community is public.
name
name specifies the name of the managed property whose value is to be set. More than one name can follow. The values of all the names are set. If one of the specified names is invalid, then the request for all of the names fails.
type
type is the type of the value in the value field. Types can be:

    None
    Integer
    OctetString
    IPAddr
    Opaque
    Counter
    Gauge
    TimeTicks
    ObjectId
    Null

value
This is the new value of the node. More than one name, type, and value combination can follow.

### Exit Status

> Exit status is 0 if successful, In all other cases it is nonzero.

### Examples of `snmpset`

> ``

>     CommandLine> snmpset -h ignite -p 161 -t 5 -i 100 -c foo "1.3.6.1.2.1.1.4.0"
>     "OctetString" "Administrators Name"

>     OutPut>Request Id: 100
>     	Error: noError
>     	Index: 0
>     	Count: 1

>     	Name: 1.3.6.1.2.1.1.4.0
>     	Kind: OctetString
>     	Value: "System Administrator"

>     CommandLine> snmpset -h ignite -p 161 -c foo 1.3.6.1.2.1.1.4.0 OctetString
>     "System Admin"

>     OutPut> Request Id: 0
>     	Error: noError
>     	Index: 0
>     	Count: 1

>     	Name: 1.3.6.1.2.1.1.4.0
>     	Kind: OctetString
>     	Value: "System Admin"

## `snmpget`

### Name

> `snmpget`--Get information from manageable nodes with SNMP

### Synopsis

    /opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpget -h host	 \
    [-p  port] [-t timeout] [-i requestID][-c community] [-q ] name1 ... nameN

### Description

> With `snmpget` you can get information from a manageable node. You specify what information you want with the `objectId`. After doing this, enter the hostname where the agent is running. If the host (or other network connected device) can be reached, then you will get an answer.

### Options

`-h` host
host is the hostname of the machine on which the agent is running. The hostname can be either the domain hostname or the IP address in dot notation.
`-p` port
Normally the remote port 161/UDP is used. If you run your snmp agent on another port you can specify which port here. The default value is taken from environment variable SNMP_PORT. If this variable is not set then the value is taken from services file's entry `snmp/udp`.
`-t` timeout
Change the timeout time for each retry. Time is given in seconds. The default timeout is 5 seconds.
`-i` requestID
This integer value is used to differentiate different requests. The default requestID is 0.
`-c` community
This string will be used as community name. The default community is public.
`-q` name
name specifies the name of the managed property whose value is returned. More than one name can follow. The values of all the names are returned. If one of the specified names is invalid, then the request for all of the names fails. If names are given without `-q` option then full detail output is listed and if `-q` option is specified then only value is listed.

### Exit Status

> Exit status is 0 if successful, In all other cases it is nonzero.

### Examples of `snmpget`

    CommandLine>snmpget -h symoncool -p 161 -t 5 -i 100 -c public \
    -q 1.3.6.1.2.1.1.1.0

    OutPut>    "Sun SNMP Agent, Ultra-1"

    CommandLine>    snmpget -h ignite 1.3.6.1.2.1.1.1.0

    OutPut>         Request Id: 0
                    Error: noError
                    Index: 0
                    Count: 1

                    Name: 1.3.6.1.2.1.1.1.0
                    Kind: OctetString
                    Value: "SUNW,Ultra-Enterprise"

    CommandLine>  snmpget -h symoncool -p 161 -t 5 -i 100 -c public \
    -q 1.3.6.1.2.1.1.2.0

    OutPut>     1.3.6.1.4.1.42.2.1.1

    CommandLine>  snmpget -h symoncool -q 1.3.6.1.2.1.1.1.0

    OutPut>     "Sun SNMP Agent, Ultra-1"

    CommandLine>  snmpget -h 129.146.53.224 -p 161 -t 5 -i 100 -c
    public -q 1.3.6.1.2.1.1.1.0

    OutPut>     "Sun SNMP Agent, Ultra-1"

    CommandLine>  snmpget -h symoncool -p 161 -t 5 -i 100 -c public \
    -q 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.2.0 1.3.6.1.2.1.1.3.0
    1.3.6.1.2.1.1.4.0 1.3.6.1.2.1.1.5.0

    OutPut>     "Sun SNMP Agent, Ultra-1"
                 1.3.6.1.4.1.42.2.1.1
                 9330516
                 "System administrator" "symoncool"

    CommandLine>  snmpget -h symoncool -p 161 -t 5 -i 100 -c public  \
    -q 1.3.6.1.2.1.1.10.0

    OutPut>     ""

    CommandLine>  snmpget -h symoncool -p 161 -t 5 -i 100 -c public  \
    -q 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.2.0 1.3.6.1.2.1.1.3.0
    1.3.6.1.2.1.1.4.0 1.3.6.1.2.1.1.10.0

    OutPut>     ""
                ""
                ""
                ""
                ""

## `snmpnext`

### Name

> `snmpnext`--Get information from manageable nodes with SNMP

### Synopsis

    /opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpnext -h host \
    [-p port] [-t timeout] [-i requestID] [-c community]  name1 ... nameN

### Description

> With `snmpnext` you can get information from a manageable node. You specify what information you want with the objectId. Then enter the name of the host on which the agent is running.

> If the host (or other network connected device) can be reached, you will get the information about the next object id.

### Options

-h host
host is the hostname of the machine on which the agent is running. The hostname can be a domain hostname or an IP address in dot notation.
-p port
Normally the remote port 161/UDP is used. If you run your snmp agent on another port you can specify the port here. The default value is taken from environment variable SNMP_PORT. If this variable is not set, then the value is taken from the services file entry snmp/udp.
-t timeout
Change the timeout time in seconds for each retry. The default timeout is 0 seconds, which means there is no timeout.
-i requestID
This integer value is used to differentiate different requests. The default requestID is 0.
-c community
This string is used as the community name. The default community is public.
name
name specifies the name of the previous managed property for which a value is returned. Multiple names can follow. The value of the next managed object of all the names is returned. If one of the names is invalid, the request fails for all of the names.

### Exit Status

> Exit status is 0 if successful. In all other cases it is nonzero.

### Examples of `snmpnext`

    CommandLine>snmpnext -h symoncool -p 161 -t 5 -i 1 -c \
    public 1.3.6.1.2.1.1.1.0

    OutPut>Request Id: 1
    Error: noError
    Index: 0
    Count: 1

    Name: 1.3.6.1.2.1.1.2.0
    Kind: ObjectId
    Value: 1.3.6.1.4.1.42.2.1.1

    CommandLine>snmpnext -h symoncool 1.3.6.1.2.1.1.0

    OutPut>Request Id: 0
        Error: noError
        Index: 0
        Count: 1

    Name: 1.3.6.1.2.1.1.1.0
         Kind: OctetString
         Value: "Sun SNMP Agent, Ultra-1"

    CommandLine>snmpnext -h symoncool -p 161 -t 5 -i 1 -c  public 1.

    OutPut>Request Id: 1
        Error: noError
        Index: 0
        Count: 1

        Name: 1.3.6.1.2.1.1.1.0
        Kind: OctetString
        Value: "Sun SNMP Agent, Ultra-1"

## `snmptrap`

### Name

> `snmptrap`--Send an SNMP TRAP message to a host

### Synopsis

    /opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmptrap -h fhost [-p fport]\
    [-c community] enterprise agent_addr generic_trap specific_ trap timestamp \
    [name1 type1 value1 ... nameN typeN valueN ] ...

### Options

-h host
host is the hostname of the machine to which TRAP is to be sent.
-p port
Port to which the TRAP is to be sent. The default value is taken from environment variable SNMP_PORT. If this variable is not set, then the value is taken from the services file entry `snmp-trap/udp`.
-c community
This string is used as the community name. The default community is public.
enterprise
This option can point to a mib sub tree or identify a product for which the TRAP has been defined.
agent_addr
Change the address from which the trap reports it is being sent. By default, `snmptrap` uses the address of the sending host.
`generic_trap`
An integer that specifies the type of trap message being sent. Trap types are defined below.
`specific_trap`
An integer that specifies the enterprise specific trap. For this the generic trap field must be 6.
`timestamp`
Time elapsed between the last (re)initialization of the network entity and the generation of the trap.
`name`
Object Id (OID) of the extra information to be sent with TRAP.
`type`
Type of the value in the value field. Types can be:

    None
    Integer
    OctetString
    IPAddr
    Opaque
    Counter
    Gauge
    TimeTicks
    ObjectId
    Null

`value`
Value for the OID given in the name field

### Exit Status

> Exit status is 0 if successful. In all other cases it is nonzero.

### Trap Type Information

> The following table presents trap types and what they signify. The meaning of the numbers is illustrated within parenthesis.

> TABLE 12-1 Trap Type and What it Signifies
> Trap Type | What the Sending Protocol Entity Signifies
> --- | ---
> 0 (coldStart) | Is reinitializing itself. The agent's configuration or the protocol entity implementation may be altered.
> 1 (warmStart) | Is reinitializing itself. Neither the agent's configuration nor the protocol entity implementation is altered.
> 2 (linkDown) | Recognizes a failure in one of the communication links represented in the agent's configuration.
> 3 (linkUp) | Recognizes that one of the communication links represented in the agent's configuration has come up.
> 4 (authenticationFailure) | Is the addressee of a protocol message that isn't properly authenticated.
> 5 (egpNeighborLoss) | Had an EGP neighbor as an EGP peer, and the neighbor has been marked down so that the peer relationship no longer exists.
> 6 (enterpriseSpecific) | Recognizes that some enterprise-specific event has occurred. The specific trap field identifies the particular trap that occurred.

### Examples of `snmptrap`

    CommandLine>snmptrap -h symoncool -p 2000 -c \
    public "1.3.6.1.4.1.42" 129.146.53.224 6 3 12345

> This example sends a trap on port 2000 on host symoncool with community = public, agent = 129.146.53.224, timestamp = 12345, enterprise = 1.3.6.1.4.1.42, generic trap = 6, and specific trap = 3.

>     CommandLine>snmptrap -h symoncool -p 2000 -c foo \
>     "1.3.6.1.4.1.42" 129.146.53.224 6 3 12345

> This example sends a trap on port 2000 on host symoncool with community = foo, agent = 129.146.53.224, timestamp = 12345, enterprise = 1.3.6.1.4.1.42, generic trap = 6, and specific trap = 3.

## `snmpwalk`

### Name

> `snmpwalk`--Query for a tree of information about a network entity

### Synopsis

    /opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpwalk -h fhost \
    [-p fport] [-t timeout] [-i requestId] [-c community]name1 ... nameN

### Description

> With `snmpwalk` you can get information from an manageable node. You specify what information you want with the objectId. Then, enter the name of the host on which the agent is running. If the host (or other network connected device) can be reached, then you will get information about all the entries in the subtree below the objectId specified in name. `snmpwalk` walks the subtree in lexicographical order.

### Options

-h host
host is the hostname of the machine on which the agent is running. The hostname can be a domain hostname or IP address in dot notation.
-p port
Normally the remote port 161/UDP is used. If you run your snmp agent on another port, you can specify which port here. The default value is taken from environment variable SNMP_PORT. If this variable is not set, then the value is taken from the services file entry `snmp/udp`.
-t timeout
Change the timeout time in seconds for each retry. The default timeout value is 10 seconds.
-i requestID
This integer value is used to differentiate different requests. The default requestID is 0.
-c community
This string is used as a community name. The default community is public.
name
The portion of the object identifier space that will be searched, using GET NEXT requests. The snmpwalk utility queries all variables in the subtree below the specified variable and displays their values.

### Exit Status

> Exit status is 0 if successful. In all other cases it is nonzero.

### Examples of `snmpwalk`

    CommandLine snmpwalk -h symoncool -p 161 -c public 1.3.6.1.2.1.1
    OutPut>       Sun SNMP Agent, Ultra-1
                  1.3.6.1.4.1.42.2.1.1
                   36472928

                   System administrators office
                   72

> > Note - If there is no subtree with the specified OID or if the OID is invalid, then `snmpwalk` returns without printing anything.

> >     CommandLine>snmpwalk -h symoncool -p 161 -t 1 -c foo  1.3.6.1.2.1.2

> >     OutPut>Request Timed Out: snmpwalk -h symoncool -p 161 -t 1 -c foo
> >     1.3.6.1.2.1.2

> > Note - If you do not have sufficient access privilege and there is no timeout, snmpw`alk` just returns without printing anything.

## `snmpwalktable`

### Name

> `snmpwalktable`--Query for a table of information about a network entity

### Synopsis

    /opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpwalktable\
    -h fhost [-p fport] [-t timeout] [-i requestId] [-c community]\
    [-n numcolumns] [-w width] name1 ... nameN

### Description

> With `snmpwalktable` you can get information from the table node. You specify which table which you want information about by specifying the objectId. Then enter the hostname where the agent is running. If the host (or other network connected device) can be reached, you will get an answer. This command walks from the start of the table to the end of the table in lexicographical order.

> -h host
> host is the hostname of the machine on which the agent is running. The hostname can be a domain hostname or an IP address in dot notation.
> -p port
> Normally remote port 161/UDP is used. If you run your snmp agent on another port you can specify which port here. The default value is taken from environment variable SNMP_PORT. If this variable is not set, then the value is taken from the services file entry snmp/udp.
> -t timeout
> Change the timeout time for each retry in seconds. The default timeout is 10 seconds.
> -i requestID
> This integer value is used to differentiate different requests. The default requestID is 0.
> -c community
> This string is used as the community name. The default community is public.
> -n numcolumns
> This integer value shows the number of columns to be printed. The default value is 1.
> -w width
> This integer value indicates the width of every column. The default width is 10.
> name
> The ObjectId of the table

### Exit Status

> Exit status is 0 if successful, In all other cases it is nonzero.

### Examples of `snmpwalktable`

    CommandLine>   snmpwalktable -h symoncool -p 161 1.3.6.1.2.1.4.20

    OutPut>           127.0.0.1
                                 129.146.53.224
                                 1
                                 2
                                     255.0.0.0
                                     255.255.255.0
                                        1
                                        1
                                     65535
                                     65535

    CommandLine>  snmpwalktable -h symoncool -p 161 -n 5 -w 3 \
    1.3.6.1.2.1.4.20

    OutPut>       127 1   255 1   655
                  129 2   255 1   655

    CommandLine>    snmpwalktable -h symoncool -p 161 -n 5 \
    1.3.6.1.2.1.4.20

    OutPut> 127.0.0.1  1          255.0.0.0  1          65535     129.146.53
    2          255.255.25 1          65535

    CommandLine>      snmpwalktable -h symoncool -p 161 -n 5 -c foo \
    -t 1  1.3.6.1.2.1.4.20

    OutPut>          Request Timed Out: snmpwalktable -h symoncool \
    -p 161 -n 5 -c foo  -t 1 1.3.6.1.2.1.4.20

> > Note - If the access privilege is insufficient and no timeout occurs, `snmpwalktable` returns without printing anything. Also, the command does not print anything if the given OID is not a table.

Copyright © 2000 Sun Microsystems, Inc. All Rights Reserved.