Chapter 12 |
Developer Environment Tools |
This chapter describes the following SNMP commands:
The following sections present the information in the format of man pages.
snmpset--Change information in manageable nodes with SNMP
/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 |
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.
None Integer OctetString IPAddr Opaque Counter Gauge TimeTicks ObjectId Null |
Exit status is 0 if successful, In all other cases it is nonzero.
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--Get information from manageable nodes with SNMP
/opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpget -h host \ [-p port] [-t timeout] [-i requestID][-c community] [-q ] name1 ... nameN |
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.
Exit status is 0 if successful, In all other cases it is nonzero.
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--Get information from manageable nodes with SNMP
/opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpnext -h host \ [-p port] [-t timeout] [-i requestID] [-c community] name1 ... nameN |
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.
Exit status is 0 if successful. In all other cases it is nonzero.
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--Send an SNMP TRAP message to a host
/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 ] ... |
None Integer OctetString IPAddr Opaque Counter Gauge TimeTicks ObjectId Null |
Exit status is 0 if successful. In all other cases it is nonzero.
The following table presents trap types and what they signify. The meaning of the numbers is illustrated within parenthesis.
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--Query for a tree of information about a network entity
/opt/SUNWsymon/util/bin/sparc-sun-solaris$VERSION/snmpwalk -h fhost \ [-p fport] [-t timeout] [-i requestId] [-c community]name1 ... nameN |
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.
Exit status is 0 if successful. In all other cases it is nonzero.
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 |
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, snmpwalk just returns without printing anything.
snmpwalktable--Query for a table of information about a network entity
/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 |
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 is 0 if successful, In all other cases it is nonzero.
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.