Alarm Customization from Trap,Syslog,Sub Event Type
Scenario Overview
This guide demonstrates how to customize alarms for traps, syslogs, and sub-event types using CNC Fault API. These customizations allow network administrators to configure new alarms, adjust event policies, and manage sub-event types for traps and syslogs. Note that alarm customization applies only to new syslogs and traps; it does not affect existing alarms. However, adding a new subevent type to the existing PKT_INFRA-FM alarm is supported.
Prerequisites
Before running these examples, ensure:
- You have obtained an access token. Refer to the 'Getting Started' section for instructions.
- The
cnc-api-common.sh
script is properly configured. - Necessary input/output directories exist for storing and retrieving configuration files.
Customized Alarms from Trap
Set up custom trap event with specified details trapName, trapOid,trapAttributes,eventDetails. Retrieve custom trap events based on the specified event type.
Run the script alarm_custom_trap.sh from the example directory.
cd cnc-fault-api-examples;./alarm_custom_trap.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
alarm_custom_trap() {
# Assume the CNC JWT has already been obtained by running the get-cnc-jwt.sh script.
# Read from jwt file and export it as AUTH_TOKEN_HDR
export_jwt
# STEP 1 : Add alarm custom trap from CNC_API_INPUT
# STEP 2 : store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/custom/trap
CNC_API_INPUT="$PRJ/input/alarm-custom-trap.json"
CNC_API_OUTPUT="$PRJ/output/alarm-custom-trap.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
# Prompt the user to enter the event type (eg nexusLinkDown)
read -p "Enter the eventtype: " eventtype
# STEP 3 : Retrieve alarm custom trap
CNC_API_URL=$CNC_FAULT_API_CTX/custom/trap/$eventtype
CNC_API_OUTPUT="$PRJ/output/alarm-custom-trap-retrieval.json"
http_get $CNC_API_URL $CNC_API_OUTPUT
# STEP 4 : Test alarm custom trap from CNC_API_INPUT
# STEP 5 : store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/custom/trap/test
CNC_API_INPUT="$PRJ/input/alarm-custom-trap-test.json"
CNC_API_OUTPUT="$PRJ/output/alarm-custom-trap-test.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
}
alarm_custom_trap
Customized Alarms from Syslog
Set up custom event syslog configuration with custom mnemonics and regex details. Retrieve custom syslog configuration based on the event type.
Run the script alarm_custom_syslog.sh
from the example directory.
cd cnc-fault-api-examples;./alarm_custom_syslog.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
alarm_custom_syslog() {
# assume cnc jwt is obtained prior to invoking this method by executing get-cnc-jwt.sh script
# read from jwt file and export it as AUTH_TOKEN_HDR
export_jwt
# STEP 1 : Add alarm custom syslog from CNC_API_INPUT
# STEP 2 : store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/custom/syslog
CNC_API_INPUT="$PRJ/input/alarm-custom-syslog.json"
CNC_API_OUTPUT="$PRJ/output/alarm-custom-syslog.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
# Prompt the user to enter the event type (eg LINEPROTO-5-DOWN)
read -p "Enter the eventtype: " eventtype
# STEP 3 : Retrieve alarm custom syslog policy
CNC_API_URL=$CNC_FAULT_API_CTX/custom/syslog/$eventtype
CNC_API_OUTPUT="$PRJ/output/alarm-custom-syslog-retrieval.json"
http_get $CNC_API_URL $CNC_API_OUTPUT
# STEP 4 : Test alarm custom syslog from CNC_API_INPUT
# STEP 5 : Store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/custom/syslog/test
CNC_API_INPUT="$PRJ/input/alarm-custom-syslog-test.json"
CNC_API_OUTPUT="$PRJ/output/alarm-custom-syslog-test.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
}
alarm_custom_syslog
Customized Alarms from Sub Event Types
Set up custom sub-event type with the specified details as eventType, category, defaultSeverity, description.
Run the script alarm_custom_subeventtype.sh
from the example directory.
cd cnc-fault-api-examples;./alarm_custom_subeventtype.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
alarm_custom_subeventtype() {
# assume cnc jwt is obtained prior to invoking this method by executing get-cnc-jwt.sh script
# read from jwt file and export it as AUTH_TOKEN_HDR
export_jwt
# STEP 1 : Add alarm custom subeventtype from CNC_API_INPUT
# STEP 2 : store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/custom/subeventtype
CNC_API_INPUT="$PRJ/input/alarm-custom-subeventtype.json"
CNC_API_OUTPUT="$PRJ/output/alarm-custom-subeventtype.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
}
alarm_custom_subeventtype