snmptrap Command

Purpose

Generate a notification (trap) to report an event to the SNMP manager with the specified message.

Syntax

snmptrap [ -a host ] [ -h targethost ] [ -c community ] [ -o oid ] [-d ] -m message

Description

Generate a notification (trap) to report an event to the SNMP manager with the specified message.

Flags

Item Description
-a host Specifies to connect to the SNMP agent on the specified host. If the -a flag is not specified, the default host is the local host. host can be an IPv4 address, an IPv6 address, or a host name.
-c community Specifies community name to use. This community must have been set in /etc/snmpdv3.conf for SNMP version 3 or in /etc/snmpd.conf for SNMP version 1 and have the read access privilege at least to the SNMP agent running on the specified host or local host. If the -c flag is not specified, the default community name is "public".
-o oid Specifies the event that generates the trap message. The oid specified, it will be used in the trap packet. If the parameter is not specified, the default OID is used in the trap packet. This specified OID is not validated for its correctness.
-d Enables the debug facility
-h targethost Specifies the target network manger host to which the trap message will be sent. The target host can be an IPv4 address, an IPv6 address, or a host name.The -h flag is different from the -a flag. The -a flag specifies a host where the AIX® SNMP agent (snmp) must be running and the SNMP agent forwards this trap to network mangers. However, the -h flag does not require the AIX SNMP agent to forward the trap message to network managers, and it sends the trap directly to the network manager. If there are no -h and -a flags, the trap will be sent to the AIX SNMP agent on the local host.
-m message Defines the message that the snmptrap command will send. message specifies the information the trap will hold. This information is in the text format. The -m flag must be the last flag specified.

Exit Status

0
Trap information was sent out correctly.
1
This indicates something was wrong during the process.

Examples

  1. To send a trap with the message 'hello world' to the SNMP agent running on the local host, enter the following:
    snmptrap -m hello world
    Note: The community, public, must have read access to the SNMP agent running on the local host. For details, please refer to SNMP configuration documentation.
  2. To send a trap with the community name, community1, and the message 'hello world' to the SNMP agent running on a remote host blah, enter the following:
    snmptrap -c community1 -h blah -m hello world
    Note: The community 'community1' must have read access to the SNMP agent running on the host 'blah'. For details, please refer to the SNMP configuration documentation.
  3. To send a trap to the network manager running on a Linux® platform and where the host name is nehcyg, type the following:
    snmptrap -h nehcyg -m hello world
  4. To send a trap to the network manager running on a Linux platform where the host name is nehcyg, and with the OID 1.3.6.1.4.1.2.6.191.1.6.1.0, enter the following:
    snmptrap -h nehcyg –o 1.3.6.1.4.1.2.6.191.1.6.1.0 -m hello world
  5. To send a trap with the community1 community name, and the message hello world to the SNMP agent that is running on an IPv6 address, enter the following command:
    snmptrap -c community1 -h 2000:1:1:1:209:6bff:feae:6d67 -m hello world
    Note: The community1 community must have read access to the SNMP agent that is running on the IPv6 address. For more information, see SNMP for network management.
  6. To send a trap to the network manager that runs on an IPv6 address, and with the OID 1.3.6.1.4.1.2.6.191.1.6.1.0, enter the following command:
    snmptrap -h 2000:1:1:1:209:6bff:feae:6d67 -o 1.3.6.1.4.1.2.6.191.1.6.1.0 -m hello world

Files

Item Description
/etc/snmpdv3.conf Contains the configuration file for the SNMP version 3 agent.
/etc/snmpd.conf Contains the configuration file for the SNMP version 1 agent.