A lightweight bot application to interact with the APIC from a Webex chat room
Monitor your Data Center with an user-friendly bot. This repository contains a Go-based web server, which listens to Webex webhooks notifications and interacts with the APIC REST API to retrieve information about the operational status of your ACI Fabric.
This application allows you to retrieve operational, topology, event/fault and endpoint information from the ACI Fabric by simply typing short and human-readable commands in a Webex room. These is the list of the currently supported commands by the aci-chatbot:
• /cpu -> Get APIC CPU Information 💾
• /ep -> Get APIC Endpoint Information 💻. Usage /ep [ep_mac]
• /events -> Get Fabric latest events ❎. Usage /events [user:opt] [count(1-10):opt]
• /faults -> Get Fabric latest faults ⚠️. Usage /faults [count(1-10):opt]
• /help -> Chatbot Help ❔
• /info -> Get Fabric Information ℹ️
• /neigh -> Get Fabric Topology Information 🔢. Usage /neigh [node_id]
• /websocket -> Subscribe to Fabric events 📩
The bot takes advantage of the APIC REST API to query and filter information from the APIC Management Information Tree (MIT). Additionally, the /websocket
command leverages the APIC WebSocket functionality, to get instant notifications once any instance of a defined MO/Class is created, modified or deleted.
-
Make sure to have Go 1.15+ or Docker installed on your computer/server
-
Login to your Webex account and create your own bot. Create Bot
The bot application must be hosted in a server reachable via the public internet because the webhooks are delivered from webex.com . For development and testing pursposes you could use ngrok to expose your server to the public internet. Ngrok will expose your application (Server IP & Port) over a secure tunnel.
Follow these instructions after installing ngrok:
-
Start the ngrok service stating the port the bot server listens to. By default the application listens to the port 7001, however if you are using the docker container you must state here Docker host port.
./ngrok http <bot_port> --region=eu
ngrok by @inconshreveable
Session Status online
Session Expires 1 hour, 59 minutes
Version 2.3.40
Region Europe (eu)
Web Interface http://127.0.0.1:7001
Forwarding http://2d6e-89-246-96-47.eu.ngrok.io -> http://localhost:7001
Forwarding https://2d6e-89-246-96-47.eu.ngrok.io -> http://localhost:7001
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
- The generated HTTP url is your
BOT_URL
NOTE:: The trial version of ngrok creates the secure tunnel only for 2 hours
- Set and source the environmental variables in
env.sh
export WEBEX_TOKEN=YOUR-WEBEX-TOKEN-GOES-HERE
export BOT_URL=http://2258-173-38-220-34.eu.ngrok.io
export APIC_URL=https://sandboxapicdc.cisco.com/
export APIC_USERNAME=admin
export APIC_PASSWORD=admin
source env.sh
-
Execute the application
go run main.go
NOTE:: The Go application listens to port
7001
- Set the environmental variables in
.env
:
WEBEX_TOKEN=YOUR-WEBEX-TOKEN-GOES-HERE
BOT_URL=http://2258-173-38-220-34.eu.ngrok.io
APIC_URL=https://sandboxapicdc.cisco.com/
APIC_USERNAME=admin
APIC_PASSWORD=admin
-
Run the application in a Docker container
docker run --env-file .env -it -p <bot_port>:7001 jgomezve/aci-chatbot:latest
NOTE: In case you are using ngrok, <bot_port> is the same port used to start ngrok.
Either send a message directly to your bot or add it to a Webex Group
NOTE: Some commands do not work if the target APIC is a simulator