snmptrapd -h
An alert definition can optionally be configured to send SNMP traps when the alert's conditions are satisfied. This page discusses how to configure SNMP alert trap notifications and how to test that they are working.
Before configuring any alerts to send SNMP trap notifications, you must first set some global SNMP properties in the RHQ Administration section. This is a one time step. Go to the Administration > Server Configuration item on the menu bar. At the bottom of this page, you must specify general information common to all SNMP traps which will be emitted by JBoss ON.
Changes to these Server level settings do not require the RHQ Server to be restarted. Regardless of whether we're using SNMP protocol version 1 or 2c, you should usually set the 'community' property to 'public' (without the quotes) in order to simplify configuration of trap listeners. This page focuses on generating traps for SNMP protocol version 1 and 2c. However, it's also possible to generate SNMP v3 traps.
When you create an Alert on a particular Resource or compatible group, or an Alert Template on a particular Resource type, after you have specified the alert definition, you can choose the SNMP Trap tab and specify details about the specific trap you want emitted.
The suggested way to try out SNMP trap alert notifications is to define an alert whose condition is always true and which fires at a regular interval. For example, you could create an alert on a JBoss AS Server Resource that fires when the Active Thread Count metric is > 1 (i.e. all the time), and then add an SNMP trap notification to the alert. You could then go to the Resource's Monitor > Schedule tab and set the metric collection interval on the Active Thread Count metric to be 1 minute. This will cause the alert to be fired every minute, and thereby cause the associated SNMP trap to also be generated every minute.
Here are some sample configurations you can use to try out SNMP trap notifications.
The below settings will generate a generic Link Down trap:
Agent Address: 127.0.0.1
Agent Port: 1621
SNMP Transport: UDP
SNMP Protocol Version: 1
Community: public
Generic ID: 2 (i.e. SNMPv2-SMI::zeroDotZero Link Down Trap)
OID: 1.3.6.1.4.1.8072.4.0.1 (i.e. NET-SNMP-AGENT-MIB::nsNotifyStart)
Alert Name: testSNMPTrap2
The below settings will generate a Notify Start trap:
Agent Address: 127.0.0.1
Agent Port: 1621
SNMP Transport: UDP
SNMP Protocol Version: 1
Community: public
Generic ID: 6 (i.e. enterprise-specific trap)
Enterprise OID: 1.3.6.1.4.1.8072.4.0 (i.e. NET-SNMP-MIB::netSnmpNotifications)
Specific ID: 1 (when combined with Enterprise OID, gives 1.3.6.1.4.1.8072.4.0.1 ( i.e. NET-SNMP-AGENT-MIB::nsNotifyStart))
OID: 1.3.6.1.4.1.8072.4.0.1 (i.e. NET-SNMP-AGENT-MIB::nsNotifyStart)
Alert Name: testSNMPTrap2
With SNMP v2c, there is really no distinction between Generic traps and Enterprise specific ones, you just specify the OID of the trap you want, in this case Link Down.
The below settings will generate a generic Link Down trap:
Agent Address: 127.0.0.1
Agent Port: 1621
SNMP Transport: UDP
SNMP Protocol Version: 2c
Community: public
Trap OID: 1.3.6.1.6.3.1.1.5.3 (i.e. IF-MIB::linkDown)
OID: 1.3.6.1.4.1.8072.4.0.1 (i.e. NET-SNMP-AGENT-MIB::nsNotifyStart)
Alert Name: testSNMPTrap2
In order to make sure RHQ is really generating SNMP traps when an alert fires, you need to install a program capable of receiving and parsing such traps. One such program is 'snmptrapd' which is included in the open-source Net-SNMP tool set. snmptrapd can be used to test SNMP trap notifications as follows:
Go to http://www.net-snmp.org/ and download the current version of Net-SNMP for the operating system that is running on the JON Server machine.
Install Net-SNMP on the same machine as the RHQ Server. If you are using the GUI installer for Windows, the only components you need to select are the Base Components and the Net-SNMP Trap Service.
Once the installation is complete, open a command terminal and type:
snmptrapd -h
You should see a lot of command line options fly past.
The final step is to configure snmptrapd to allow connections from our RHQ Server. To do this create a file called snmptrapd.conf in <Net-SNMP_HOME>/usr/etc/snmp/ and add the following line:
authcommunity log public
To start listening for SNMP traps, open a command terminal and type:
snmptrapd -Lo 127.0.0.1:1621
The -Lo just tells it to output all traps received to stdout. 127.0.0.1 says we should listen on the loopback network interface and 1621 says use UDP port 1621. The default for snmptrapd is to try to listen on UDP port 162, but other programs, e.g. Skype and the Remote Procedure Call (RPC) service, are often already using that port, so it's easier just to pick a different one.