Alarms and Events Retrieval
Scenario Overview
This guide demonstrates how to retrieve alarms and events from the Crosswork Network Controller based on specified criteria. The alarms and events are stored in separate databases, and this script allows network administrators to filter and query them by type, severity, and other conditions.
Type can be system,network or device. Severity can be critical,major,minor,warning,information and cleared.
The filterCondition
parameter supports the values and
and or
. The sortParams
parameter supports values such as updated.DESC
(descending order) and updated.ASC
(ascending order).
Prerequisites
Before running this example, 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 and output directories exist for storing and retrieving alarm and event query files.
Retrieval of Alarms and Events
Run the script alarm_event_query.sh
from the example directory.
cd cnc-fault-api-examples;./alarm_event_query.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
alarm_event_query() {
# 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 : Retrieve Alarms according to criteria in the request ( type can be system, network, device)
# STEP 2 : Store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/query
CNC_API_INPUT="$PRJ/input/alarm-query.json"
CNC_API_OUTPUT="$PRJ/output/alarm-query.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
# STEP 3 : Retrieve Events according to criteria in the request ( type can be system, network, device)
# STEP 4 : Store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_FAULT_API_CTX/event/query
CNC_API_INPUT="$PRJ/input/event-query.json"
CNC_API_OUTPUT="$PRJ/output/event-query.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
}
alarm_event_query