You can configure alerts about registered events to be sent as traps by using SNMP
(Simple Network Management Protocol).
About this task
SNMP is a standard protocol for collecting and organizing information about managed devices or
services. It exposes management data in the form of variables that are defined in managed
information base (MIB) files.
Procedure
- Install and configure an SNMP server with a trap listener. For more information, see
Installing Net-SNMP.
If you already have a trap listener running, go to step 2. Otherwise, you can follow these instructions to configure an
example SNMP trap listener setup on Red Hat® Enterprise Linux®.
Note: SNMP setup is outside the scope of Cloud Pak for Data.
- Edit the SNMPTRAPD configuration file.
For example,
open the
SNMPTRAPD file by using the following
command.
vi /etc/snmp/snmptrapd.conf
Add the
following lines.
authCommunity log public
authCommunity log test
- Import the following management information base (MIB) file, which can be provided to
the server that receives SNMP traps, and move it to
/usr/share/snmp/mibs/.
Sample MIB file
IBM-CP4D-MIB DEFINITIONS ::= BEGIN
IMPORTS
Integer32,
enterprises,
MODULE-IDENTITY, OBJECT-TYPE, OBJECT-IDENTITY, NOTIFICATION-TYPE
FROM SNMPv2-SMI
NOTIFICATION-GROUP
FROM SNMPv2-CONF;
cp4d MODULE-IDENTITY
LAST-UPDATED "202009290000Z"
ORGANIZATION "Cloud Pak For Data"
CONTACT-INFO "ISS customer support: support@iss.net"
DESCRIPTION "MIB module defined for alerting framework purposes"
REVISION "202009290000Z"
DESCRIPTION "Initial Revision"
::= { ibmProd 170 }
ibm OBJECT IDENTIFIER ::= { enterprises 2 }
ibmProd OBJECT IDENTIFIER ::= { ibm 6 }
lite OBJECT IDENTIFIER ::= { cp4d 1 }
alerts OBJECT IDENTIFIER ::= { lite 1 }
alertTable OBJECT-TYPE
SYNTAX SEQUENCE OF AlertEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"This is the data structure associated to
alerts delivered by alerting framework"
::= { alerts 1 }
alertEntry OBJECT-TYPE
SYNTAX AlertEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"This is the data structure associated to
alerts delivered by alerting framework"
INDEX { alertID }
::= { alertTable 1 }
AlertEntry ::= SEQUENCE {
alertID Integer32,
message OCTET STRING
reference OCTET STRING
type OCTET STRING,
severity INTEGER,
reasonCode OCTET STRING,
}
alertID OBJECT-TYPE
SYNTAX Integer32(0..127)
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Identifier of alert being sent"
::= { alertEntry 1 }
message OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Detailed description of alert"
::= { alertEntry 2 }
reference OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Reference of alert"
::= { alertEntry 3 }
type OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Type of event"
::= { alertEntry 4 }
severity OBJECT-TYPE
SYNTAX INTEGER {
critical (2),
warning (1),
info (0)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Severity of created alert;"
::= { alertEntry 5 }
reasonCode OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Reason code test"
::= { alertEntry 6 }
alertNotifications OBJECT IDENTIFIER ::= { cp4d 0 }
alertNotificationsGroup NOTIFICATION-GROUP
NOTIFICATIONS { alertNotification }
STATUS current
DESCRIPTION
"The basic alerts."
::= { cp4d 3 }
alertNotification NOTIFICATION-TYPE
OBJECTS { alertID, type, severity, message, reference }
STATUS current
DESCRIPTION
"Alert notification provided by alerting framework."
::= { alertNotifications 1 }
END
- Edit the snmptrapd config file so that it can translate received
traps with the object identifiers (OIDs) from the alerting framework.
vi /etc/snmp/snmp.conf
mibs +IBM-CP4D-MIB
- Edit the snmptrapd config file to configure logging.
vi /etc/sysconfig/snmptrapd
OPTIONS="-Lf /var/log/snmp-trap.log"
- Start the SNMPTRAPD trap and enable it on system startup.
systemctl start snmptrapd
systemctl enable snmptrapd
- Test logging by sending an example trap and verifying that it appears in your log
file.
snmptrap -v 2c -c public localhost '' SNMPv2-MIB::sysName sysName.0 s "test trap"
tail -f /var/log/snmp-trap.log
- Configure the Cloud Pak for Data alerting watchdog to use SNMP by using the
following command.
curl -X POST '<https://<my-deployment-url>/zen-watchdog/v1/monitoring/config/snmp>' \
-F host=<value> \
-F port=<value> \
-F community=<value> \
-H 'Authorization: ZenApiKey ${MY_TOKEN}'
Set the following parameters:
| Parameter |
Type |
Description |
| host |
String |
The SNMP server host address. |
| port |
String |
The SNMP server port. The default port is 162. |
| community |
String |
The community string associated with the SNMP connection. |
- Optional: Check whether your configuration is stored correctly by using the
following GET command.
curl -X GET 'https://<my-deployment-url>/zen-watchdog/v1/monitoring/config/snmp' \
-H 'Authorization: ZenApiKey ${MY_TOKEN}'
For more information, see Configure SNMP.
What to do next
Check your SNMP logs by running the following
command.
tail -f /var/log/snmp-trap.log