Exposes REST API endpoints for accessing PM counter data including network elements, interface counters, system metrics, BGP peers, and processed file information.
Stores and retrieves telecom performance monitoring (PM) counters in a time-series database, including interface counters, system metrics, CPU/memory utilization, BGP peer data, and threshold alerts.
Provides a chat bot interface for querying PM counter data, allowing natural language questions about CPU utilization, memory usage, interface counters, and system statistics.
PM Counter Monitoring System
A comprehensive system for monitoring telecom performance monitoring (PM) counters from remote SFTP locations, storing them in a time-series database, and providing access through API endpoints and a Streamlit chat interface.
Architecture
Components
SFTP Client (
sftp_client.py) - Handles file downloads from remote SFTP serverJob Server (
job_server.py) - Periodically fetches and processes XML filesXML Parser (
xml_parser.py) - Parses PM counter XML filesDatabase (
database.py) - PostgreSQL schema and modelsData Storage (
data_storage.py) - Saves parsed data to databaseAPI Server (
api_server.py) - FastAPI REST endpointsMCP Server (
mcp_server.py) - Model Context Protocol serverStreamlit Frontend (
streamlit_app.py) - Chat bot interface
Quick Start with Docker (Recommended)
The easiest way to run the entire system is using Docker Compose:
The Docker setup includes:
PostgreSQL database
SFTP server (for testing, with example XML files)
Job server (fetches files every hour)
API server
MCP server
Streamlit frontend
All services are automatically configured to work together.
Manual Setup (Without Docker)
1. Install Dependencies
2. Configure Environment
Copy .env.example to .env and update with your settings:
Edit .env with your database and SFTP credentials.
3. Setup Remote Location (SFTP Server)
The remote location is where your XML files are stored. You have several options:
Option A: Use Local Files for Testing (Easiest)
Option B: Set Up Local SFTP Server
See SETUP_REMOTE.md for detailed instructions on setting up a local SFTP server.
Option C: Use Existing Remote SFTP Server
Update .env with your remote SFTP server credentials:
For more details, see SETUP_REMOTE.md.
4. Setup PostgreSQL Database
5. Initialize Database Schema
Or run:
Running the System
With Docker (Recommended)
Without Docker
1. Start Job Server
The job server fetches files from SFTP at configured intervals:
2. Start API Server
Or using uvicorn:
3. Start MCP Server
Or using uvicorn:
4. Start Streamlit Frontend
Docker Commands
Use the Makefile for convenient commands:
Or use docker-compose directly:
Configuration
Changing Fetch Interval
The fetch interval can be configured in two ways:
Environment Variable: Set
FETCH_INTERVAL_HOURSin.envfile (for Docker) or environmentDocker Compose: Update
FETCH_INTERVAL_HOURSindocker-compose.ymlor.envfile
For Docker, update the environment variable and restart the job server:
For non-Docker, update Config.FETCH_INTERVAL_HOURS in config.py or set environment variable.
API Endpoints
Main API (Port 8000)
GET /- API informationGET /network-elements- List all network elementsGET /interfaces/{interface_name}/counters- Get interface countersGET /system/counters- Get system countersGET /cpu/utilization- Get CPU utilizationGET /memory/utilization- Get memory utilizationGET /bgp/peers- List BGP peersGET /bgp/peers/{peer_address}/counters- Get BGP peer countersGET /files/processed- List processed filesGET /stats/summary- Get summary statistics
MCP Server (Port 8001)
POST /mcp- MCP protocol endpointGET /mcp/methods- List available MCP methods
MCP Methods:
get_interface_counters- Get interface countersget_system_counters- Get system countersget_cpu_utilization- Get CPU utilizationget_memory_utilization- Get memory utilizationget_latest_metrics- Get latest metrics summary
Streamlit Chat Interface
The Streamlit frontend provides a chat bot interface where you can ask questions like:
"What is the current CPU utilization?"
"Show me memory usage for the last 12 hours"
"Get interface counters for GigabitEthernet1/0/1"
"What are the latest metrics?"
"Show me system statistics"
Database Schema
The system stores data in the following tables:
file_records- Track downloaded XML filesnetwork_elements- Network element informationmeasurement_intervals- Time intervals for measurementsinterface_counters- Interface performance countersip_counters- IP layer counterstcp_counters- TCP layer counterssystem_counters- System performance countersbgp_counters- BGP peer countersthreshold_alerts- Threshold alerts from XML files
Testing with Local Files
For testing without a real SFTP server, you can:
Use the existing
example_1.xmlandexample_2.xmlfilesModify the job server to process local files directly
Use a local SFTP server like
openssh-serverfor testing
Troubleshooting
Database Connection Issues: Ensure PostgreSQL is running and credentials are correct
SFTP Connection Issues: Verify SFTP server is accessible and credentials are correct
API Not Responding: Check if services are running on correct ports
No Data: Ensure job server has processed files and data is in the database
License
MIT License