trapsend
- Organization of this page
Syntax
The syntax for sending an SNMPv1 trap is:
trapsend -v1 [-ipv6] [-port port-number] node-name community-name standard-trap-number [enterprise-specific-trap-number enterprise-ID [time-stamp [object-identifier value-type value] [object-identifier value-type value] ... ] ]
The syntax for sending an SNMPv2c trap is:
trapsend -v2c [-ipv6] [-port port-number] node-name community-name trap-OID [time-stamp [object-identifier value-type value] [object-identifier value-type value] ... ]
Description
The trapsend command sends an SNMPv1 trap or SNMPv2c trap to the specified IPv4 node or IPv6 node.
Location
-
Systems other than AIX: /opt/CM2/ESA/bin
-
AIX: /usr/CM2/ESA/bin
Arguments
- -v1
-
Send an SNMPv1 trap.
- -v2c
-
Send an SNMPv2c trap.
- -ipv6
-
Send the trap to an IPv6 node. If omitted, the trap is sent to an IPv4 node.
- -port port-number
-
Specify the trap destination port number as an integer from 1 to 65535. If omitted, 162 is assumed. If an out-of-range numeric value or a non-numeric value is specified, a message is output, and processing continues assuming a value of 162.
- node-name
-
Specify an IP address or host name.
When -ipv6 is specified, specify an IPv6 node (an IPv6 address or host name that can be resolved to an IPv6 address), otherwise specify an IPv4 node (an IPv4 address or host name that can be resolved to an IPv4 address).
- community-name
-
Specify the community name.
- standard-trap-number
-
Specify a standard trap number as an integer from 0 to 6. Specify 6 to issue an enterprise-specific trap.
If a non-numeric value is entered, processing continues using 0 (coldStart).
- enterprise-specific-trap-number
-
Specify an enterprise-specific trap number as a 32-bit signed integer in decimal notation. This cannot be omitted when issuing an enterprise-specific trap. If a non-numeric value is specified, a message is output and processing continues using the value 0.
- enterprise-ID
-
Specify a sysObjectID. This cannot be omitted when issuing an enterprise-specific trap.
The input format follows the numeric object identifier notation (see below). If a format other than this is specified, an error message is output and the program terminates.
If this argument is omitted, the following sysObjectID is assumed:
OS
sysObjectID
HP-UX (IPF)
1.3.6.1.4.1.116.3.9.1.3
Solaris
1.3.6.1.4.1.116.3.8.1.3
AIX
1.3.6.1.4.1.116.3.13.1.3
Linux
1.3.6.1.4.1.116.3.14.1.3
- trap-OID
-
Specify the trap OID. The specified value follows the numeric object identifier notation (see below).
- time-stamp
-
Specify a time as an integer of value 0 or greater. If omitted, the value 0 is used. If a non-numeric value is entered, a message is output and processing continues using the value 0.
- object-identifier, value-type, value
-
The trapsend command permits the specification of more than one object-identifier value-type value tuple.
- object-identifier
-
The format of the value follows the numeric object identifier notation (see below).
- value-type
-
Select from the following types:
Specified value
Type
Description
-i
INTEGER
Specifies a 32-bit signed integer value as a decimal or hexadecimal (0x...) string.
-o
OCTET STRING
Specifies pairs of hexadecimal numbers separated by a colon or space (Examples: "0A B1 B3", 00:BB:F0).
-d
OBJECT IDENTIFIER
Format follows the numeric object identifier notation (see below).
-a
IpAddress
IPv4 address format
-c
Counter32
32-bit unsigned integer value
-g
Gauge32
32-bit unsigned integer value
-t
TimeTicks
32-bit unsigned integer value
-D
OCTET STRING
Character string of NVT ASCII code set values
-N
NULL
Specifies a numeric value. However, the value that is entered is ignored.
- value
-
Specify a value of the correct value type.
- Numeric object identifier notation
-
In the trapsend command, when an object identifier is specified as a number, it must conform to the following format:
0-2.0-39[.0-4294967295[.0-4294967295...]]
Return values
- 0: Normal termination
-
Because the SNMP trap is sent over UDP, delivery to the destination node is not confirmed. As a result, the destination node might not be notified even in the case of normal termination. Also, even if a message is output to the standard output or standard error when the trapsend command is executed, if the return value is 0 then the SNMP trap is sent.
- Other than 0: Runtime error
-
The SNMP trap is not sent.
Execution examples
These examples show transmission of SNMPv1 traps.
- SNMPv1 trap transmission example 1
-
In this example, a coldStart trap (standard trap number 0) is sent to the node with IPv4 address 192.168.1.5 using the community name sendtrap.
trapsend -v1 192.168.1.5 sendtrap 0
- SNMPv1 trap transmission example 2
-
In this example, an enterpriseSpecific trap (standard trap number 6) and enterprise-specific trap number 5, with an enterprise ID of 1.3.6.1.4.1.116.3.14.1.3, is sent to port 22162 of the node with IPv6 address fec0::1111:2222:3333:4444:5555 using the community name sendtrap.
trapsend -v1 -port 22162 -ipv6 fec0::1111:2222:3333:4444:5555 sendtrap 6 5 1.3.6.1.4.1.116.3.14.1.3
- SNMPv1 trap transmission example 3
-
In this example, a linkDown trap (standard trap number 2) with enterprise ID 1.3.6.1.4.1.116.3.14.1.3 is sent to the hostname esaipv6 (which can be resolved to an IPv6 address) using the community name sendtrap. The time stamp is 10000. One object-identifier value-type value tuple is assigned (object identifier: 1.3.6.1.2.1.2.2.1.1.3, value type: Integer, value: 3).
trapsend -v1 -ipv6 esaipv6 sendtrap 2 0 1.3.6.1.4.1.116.3.14.1.3 10000 1.3.6.1.2.1.2.2.1.1.3 -i 3
These examples illustrate transmission of SNMPv2c traps.
- SNMPv2c trap transmission example 1
-
In this example, a warmStart trap (object identifier: 1.3.6.1.6.3.1.1.5.2) is sent to the node with IPv4 address 192.168.1.5 using the community name sendtrap.
trapsend -v2c 192.168.1.5 sendtrap 1.3.6.1.6.3.1.1.5.2
- SNMPv2c trap transmission example 2
-
In this example, a linkUp trap (object identifier: 1.3.6.1.6.3.1.1.5.4) is sent to the node with IPv6 address fec0::1111:2222:3333:4444:5555 with the time stamp 79000 and the community name sendtrap. One object-identifier value-type value tuple is assigned (object identifier: 1.3.6.1.2.1.2.2.1.1.3, value type: Integer, value: 3).
trapsend -v2c -ipv6 fec0::1111:2222:3333:4444:5555 sendtrap 1.3.6.1.6.3.1.1.5.4 79000 1.3.6.1.2.1.2.2.1.1.3 -i 3
Notes
-
Unlike the snmptrap command, you cannot specify the Agent Address field of SNMPv1 trap packets.
-
If the trap destination node is an IPv4 node, the IP address of the agent system (the value of the host name obtained by the OS functions of the relevant system and converted to an IP address using OS functions) is entered in the Agent Address field.
-
If the trap destination node is an IPv6 node, 0.0.0.0 is entered in the Agent Address field. However, if the destination node is the IPv6 loopback address (::1), 127.0.0.1 is entered. If the trap destination node is an IPv4-mapped address, the IPv4 address of the agent system is entered.