Retrieve Collection Status Summary of Devices
Scenario Overview
This guide provides network operators with an overview of device collection statuses (in progress, warning, failed, completed, maintenance) for efficient monitoring.
Prerequisites
Before running this example, obtain an access token from the 'Getting Started' section, configure cnc-api-common.sh
, and ensure input/output directories exist.
Retrieve Collection Status Summary of Devices
To retrieve the current collection status summary of all devices, run the collection_status_summary.sh
script from the example directory. Ensure the script sets up its dependencies properly before execution.
cd cnc-inventory-api-examples;./collection_status_summary.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
collection_status_summary() {
# Assuming the CNC JWT has 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 collection status summary from the server and store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_INVENTORY_API_CTX/collectionstatussummary/query
CNC_API_OUTPUT="$PRJ/output/collection_status_summary.json"
http_get $CNC_API_URL $CNC_API_OUTPUT
}
collection_status_summary