AP Monitor is a powerful and flexible FastAPI-based application designed to monitor wireless Access Points (APs) and client counts by integrating with Cisco DNA Center APIs. It provides real-time data, historical trends, and advanced diagnostics to help you manage your wireless network effectively.
- Real-time Monitoring: Get up-to-the-minute client counts for your entire wireless network.
- Historical Data: Store and query historical client count data to identify trends and patterns.
- RESTful API: A comprehensive RESTful API for retrieving data and managing the application.
- WebSocket Support: A WebSocket endpoint for receiving real-time updates of the total client count.
- Advanced Diagnostics: A suite of diagnostic tools to help you identify and troubleshoot issues with your wireless network.
- Flexible Configuration: Configure the application using environment variables to adapt it to your specific needs.
- Docker Support: Deploy the application using Docker for easy and consistent deployments.
- Authentication: Secure your API endpoints with API key authentication.
- Caching: An in-memory cache to improve the performance of expensive API calls.
- Python 3.10+
- PostgreSQL 12+
- Docker (optional)
-
Clone the repository:
git clone https://github.com/your-username/client_count.git cd client_count -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install the dependencies:
pip install -r ap_monitor/requirements.txt
-
Configure the application:
Create a
.envfile in the root directory of the project and add the following environment variables:# Database Configuration DB_HOST=localhost DB_NAME=wireless_count DB_USER=postgres DB_PASSWORD=your_password DB_PORT=5432 # DNA Center API Configuration DNA_API_URL=https://your-dnac-host/dna/intent/api/v1/ DNA_USERNAME=your_username DNA_PASSWORD=your_password # Application Configuration LOG_LEVEL=INFO ENABLE_DIAGNOSTICS=true API_KEY=your-secret-api-key
-
Initialize the database:
python -c "from ap_monitor.app.db import init_db; init_db()"
To run the application, use the following command:
uvicorn ap_monitor.app.main:app --host 0.0.0.0 --port 8000You can now access the API at http://localhost:8000.
To deploy the application using Docker, you can use the provided Dockerfile and docker-compose.yml files.
-
Build the Docker image:
docker build -t ap-monitor . -
Run the application using Docker Compose:
docker-compose up
The API is documented using OpenAPI (Swagger). You can access the interactive documentation at http://localhost:8000/docs.
All endpoints (except /health) require an API key to be passed in the X-API-Key header.
To run the tests, use the following command:
TESTING=true PYTHONPATH=ap_monitor pytest -v ap_monitor/tests/Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.
