Advanced system monitoring CLI tool with real-time dashboard, alerts, and REST API
Project description
OverWatch ๐ญ
Advanced System Monitoring CLI Tool
OverWatch is a powerful, terminal-based system monitor built with Python. It provides real-time monitoring of CPU, memory, disk, network, and processes with a beautiful Rich/Textual UI, plugin support, configurable alerts, and a RESTful API.
๐ Features
- ๐ Real-time Dashboard: Beautiful terminal UI powered by Rich
- ๐ Plugin System: Extensible architecture for custom monitoring modules
- ๐จ Smart Alerts: Threshold-based notifications via Email and Telegram
- ๐ REST API: FastAPI server with WebSocket support for real-time data
- ๐ฅ๏ธ Cross-Platform: Works on Linux, macOS, and Windows
- โก Performance Monitoring:
- CPU usage (overall & per-core)
- Memory (RAM & Swap)
- Disk usage & I/O
- Network statistics
- Process details
- Temperature sensors (when available)
๐ฆ Installation
OverWatch offers multiple installation methods โ pick the one that works for you:
One-Line Install (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/sudoyasir/overwatch/main/install.sh | bash
This auto-detects your OS, installs dependencies if missing, and sets everything up.
Install from PyPI (Recommended)
# Core only (dashboard + CLI)
pip install overwatch-monitor
# With API server support
pip install "overwatch-monitor[api]"
# With alert notifications (email + telegram)
pip install "overwatch-monitor[alerts]"
# Everything included
pip install "overwatch-monitor[all]"
Or use pipx for isolated CLI installation (no venv conflicts):
pipx install "overwatch-monitor[all]"
Install from Source
Quick setup (recommended):
git clone https://github.com/sudoyasir/overwatch.git
cd overwatch
./quick_setup.sh # Installs everything
Using Make:
git clone https://github.com/sudoyasir/overwatch.git
cd overwatch
make install-all # Or: make install (core only)
source venv/bin/activate
Manual:
git clone https://github.com/sudoyasir/overwatch.git
cd overwatch
python3 -m venv venv && source venv/bin/activate
pip install -e ".[all]"
Docker
# Dashboard mode
docker run -it sudoyasir/overwatch
# API server mode
docker run -p 8000:8000 sudoyasir/overwatch api
# Build locally
docker build -t overwatch . && docker run -it overwatch
Run Without Installing
# Clone and run directly as a Python module
git clone https://github.com/sudoyasir/overwatch.git
cd overwatch
pip install psutil rich click
python -m overwatch start
Modular Installation
OverWatch uses optional dependency groups so you only install what you need:
| Install Command | What You Get |
|---|---|
pip install overwatch-monitor |
Dashboard + CLI (core) |
pip install "overwatch-monitor[api]" |
+ FastAPI server & WebSocket |
pip install "overwatch-monitor[alerts]" |
+ Email & Telegram alerts |
pip install "overwatch-monitor[all]" |
Everything |
pip install "overwatch-monitor[dev]" |
+ Testing & linting tools |
Makefile Targets
If you cloned the repo, these shortcuts are available:
make install # Core install
make install-all # All features
make dev # Development mode
make run # Launch dashboard
make api # Start API server
make test # Run tests
make check # Verify installation
make clean # Clean build artifacts
make help # Show all targets
Requirements
- Python 3.10 or higher
- pip (or pipx) package manager
Dependencies
Core (always installed):
psutil- System and process utilitiesrich- Terminal UIclick- CLI framework
API (optional โ pip install "overwatch-monitor[api]"):
fastapi- API serveruvicorn- ASGI serverwebsockets- WebSocket support
Alerts (optional โ pip install "overwatch-monitor[alerts]"):
requests- HTTP client (for Telegram notifications)
๐ Quick Start
Note: Always activate the virtual environment first:
source venv/bin/activate
Launch Terminal Dashboard
overwatch start
Options:
--refreshor-r: Set refresh rate in seconds (default: 1.0)
Example:
overwatch start --refresh 0.5
Start API Server
overwatch api
Options:
--hostor-h: Host address (default: 0.0.0.0)--portor-p: Port number (default: 8000)
Example:
overwatch api --host 127.0.0.1 --port 9000
Understanding the API Host:
0.0.0.0means the server listens on ALL network interfaces- Access locally:
http://localhost:8000orhttp://127.0.0.1:8000 - Access from other devices on your network:
http://YOUR_SERVER_IP:8000 - Find your server IP:
hostname -I(Linux) oripconfig(Windows)
Interactive API Documentation:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Other Commands
# Show version information
overwatch version
# Display system information
overwatch info
# List available plugins
overwatch plugins
# Show current metrics
overwatch metrics --format json
๐ก API Usage Guide
Starting the API Server
The API server runs on 0.0.0.0:8000 by default, which means:
- Local access:
http://localhost:8000orhttp://127.0.0.1:8000 - Network access:
http://YOUR_SERVER_IP:8000(from other devices on your network) - Production: Use a reverse proxy like Nginx or deploy behind a load balancer
REST API Endpoints
| Endpoint | Method | Description | Example |
|---|---|---|---|
/ |
GET | API root info | curl http://localhost:8000/ |
/health |
GET | Health check | curl http://localhost:8000/health |
/metrics |
GET | All system metrics | curl http://localhost:8000/metrics |
/metrics/cpu |
GET | CPU usage & stats | curl http://localhost:8000/metrics/cpu |
/metrics/memory |
GET | RAM & swap usage | curl http://localhost:8000/metrics/memory |
/metrics/disk |
GET | Disk usage & I/O | curl http://localhost:8000/metrics/disk |
/metrics/network |
GET | Network stats | curl http://localhost:8000/metrics/network |
/metrics/processes |
GET | Running processes | curl http://localhost:8000/metrics/processes?limit=10 |
/metrics/sensors |
GET | Temperature sensors | curl http://localhost:8000/metrics/sensors |
/process/{pid} |
GET | Process details | curl http://localhost:8000/process/1234 |
Practical Examples
1. Get CPU Usage (Shell/Bash)
# Simple request
curl http://localhost:8000/metrics/cpu
# Pretty print JSON
curl -s http://localhost:8000/metrics/cpu | jq '.'
# Get only CPU percentage
curl -s http://localhost:8000/metrics/cpu | jq '.percent'
2. Monitor Memory (Python)
import requests
response = requests.get('http://localhost:8000/metrics/memory')
data = response.json()
print(f"RAM Usage: {data['virtual']['percent']}%")
print(f"Available: {data['virtual']['available_gb']:.2f} GB")
3. Watch Disk Space (Node.js)
const axios = require('axios');
async function checkDisk() {
const response = await axios.get('http://localhost:8000/metrics/disk');
response.data.partitions.forEach(partition => {
console.log(`${partition.device}: ${partition.percent}% used`);
});
}
checkDisk();
4. Real-Time Monitoring Dashboard (HTML/JavaScript)
<!DOCTYPE html>
<html>
<head>
<title>OverWatch Monitor</title>
</head>
<body>
<h1>System Monitor</h1>
<div id="metrics"></div>
<script>
async function updateMetrics() {
const response = await fetch('http://localhost:8000/metrics');
const data = await response.json();
document.getElementById('metrics').innerHTML = `
<p>CPU: ${data.cpu.percent}%</p>
<p>Memory: ${data.memory.virtual.percent}%</p>
<p>Disk: ${data.disk.partitions[0].percent}%</p>
`;
}
// Update every 2 seconds
setInterval(updateMetrics, 2000);
updateMetrics();
</script>
</body>
</html>
5. Alert System (Python)
import requests
import time
THRESHOLDS = {
'cpu': 90,
'memory': 85,
'disk': 90
}
def check_alerts():
response = requests.get('http://localhost:8000/metrics')
data = response.json()
if data['cpu']['percent'] > THRESHOLDS['cpu']:
print(f"โ ๏ธ HIGH CPU: {data['cpu']['percent']}%")
if data['memory']['virtual']['percent'] > THRESHOLDS['memory']:
print(f"โ ๏ธ HIGH MEMORY: {data['memory']['virtual']['percent']}%")
for partition in data['disk']['partitions']:
if partition['percent'] > THRESHOLDS['disk']:
print(f"โ ๏ธ HIGH DISK ({partition['mountpoint']}): {partition['percent']}%")
while True:
check_alerts()
time.sleep(60) # Check every minute
6. Export to CSV (Python)
import requests
import csv
from datetime import datetime
def log_metrics_to_csv():
response = requests.get('http://localhost:8000/metrics')
data = response.json()
with open('metrics_log.csv', 'a', newline='') as f:
writer = csv.writer(f)
writer.writerow([
datetime.now().isoformat(),
data['cpu']['percent'],
data['memory']['virtual']['percent'],
data['disk']['partitions'][0]['percent']
])
log_metrics_to_csv()
WebSocket Real-Time Streaming
Connect to /ws for live metrics updates (1 second interval).
Python Example:
import asyncio
import websockets
import json
async def monitor():
uri = "ws://localhost:8000/ws"
async with websockets.connect(uri) as websocket:
while True:
message = await websocket.recv()
data = json.loads(message)
print(f"CPU: {data['cpu']['percent']}% | Memory: {data['memory']['virtual']['percent']}%")
asyncio.run(monitor())
JavaScript Example:
const ws = new WebSocket('ws://localhost:8000/ws');
ws.onopen = () => {
console.log('Connected to OverWatch');
};
ws.onmessage = (event) => {
const metrics = JSON.parse(event.data);
console.log('CPU:', metrics.cpu.percent + '%');
console.log('Memory:', metrics.memory.virtual.percent + '%');
};
ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
Use Cases
- DevOps Monitoring: Integrate with Grafana, Prometheus, or custom dashboards
- CI/CD Pipelines: Monitor build server resources during deployments
- Load Testing: Track system performance during stress tests
- Mobile Apps: Build iOS/Android apps that monitor your servers
- Slack/Discord Bots: Send alerts to team channels when thresholds are exceeded
- Data Analysis: Collect historical data for capacity planning
- Home Automation: Trigger actions based on system metrics
๐ Plugin Development
Create custom plugins to extend OverWatch functionality.
Plugin Structure
- Create a new Python file in
overwatch/plugins/ - Implement a
run()function that returns a dict
Example Plugin
# overwatch/plugins/my_plugin.py
from typing import Dict, Any
def run() -> Dict[str, Any]:
"""
Your plugin logic here.
Returns:
Dict with plugin name and data
"""
return {
"name": "My Custom Plugin",
"data": {
"status": "active",
"value": 42
},
"status": "success",
}
# Optional: Plugin metadata
PLUGIN_INFO = {
"name": "My Plugin",
"version": "1.0.0",
"description": "Does something awesome",
"author": "Your Name",
}
Loading Plugins
Plugins are automatically discovered and loaded from the overwatch/plugins/ directory. Use overwatch plugins to list all available plugins.
๐จ Alert Configuration
Configure Thresholds
Edit overwatch/alerts/thresholds.json:
{
"cpu": {
"threshold": 90,
"enabled": true
},
"memory": {
"threshold": 80,
"enabled": true
},
"disk": {
"threshold": 85,
"enabled": true
},
"temperature": {
"threshold": 80,
"enabled": false
}
}
Email Notifications
Set environment variables:
export EMAIL_SMTP_SERVER="smtp.gmail.com"
export EMAIL_SMTP_PORT="587"
export EMAIL_SMTP_USERNAME="your-email@gmail.com"
export EMAIL_SMTP_PASSWORD="your-app-password"
export EMAIL_FROM="your-email@gmail.com"
export EMAIL_TO="recipient@example.com"
Telegram Notifications
Set environment variables:
export TELEGRAM_BOT_TOKEN="your-bot-token"
export TELEGRAM_CHAT_ID="your-chat-id"
To create a Telegram bot:
- Message @BotFather
- Create a new bot with
/newbot - Get your chat ID from @userinfobot
๐๏ธ Project Structure
overwatch/
โโโ core/ # Monitoring modules
โ โโโ cpu.py
โ โโโ memory.py
โ โโโ disk.py
โ โโโ network.py
โ โโโ processes.py
โ โโโ sensors.py
โโโ ui/ # Dashboard UI
โ โโโ dashboard.py
โ โโโ components/
โ โโโ cpu_panel.py
โ โโโ memory_panel.py
โ โโโ disk_panel.py
โ โโโ network_panel.py
โ โโโ process_panel.py
โโโ plugins/ # Plugin system
โ โโโ __init__.py
โ โโโ example_plugin.py
โโโ alerts/ # Alert system
โ โโโ manager.py
โ โโโ telegram.py
โ โโโ email.py
โ โโโ thresholds.json
โโโ api/ # REST API
โ โโโ server.py
โ โโโ websocket.py
โโโ cli/ # CLI interface
โ โโโ main.py
โ โโโ commands.py
โโโ utils/ # Utilities
โ โโโ loader.py
โ โโโ system_info.py
โโโ overwatch.py # Main entry point
๐ผ๏ธ Screenshots
๐งช Development
Setup Development Environment
# Clone the repository
git clone https://github.com/sudoyasir/overwatch.git
cd overwatch
# Install in development mode
pip install -e .
# Run tests (if available)
pytest
Run from Source
python -m overwatch.cli.main start
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Developed entirely by Yasir N. (@sudoyasir)
Technologies Used:
๐จโ๐ป Author
Yasir N.
- GitHub: @sudoyasir
- Portfolio: sudoyasir.space
- Email: y451rmahar@gmail.com
๐ง Contact
For questions, issues, or suggestions:
- GitHub Issues: github.com/sudoyasir/overwatch/issues
- Email: y451rmahar@gmail.com
Made with โค๏ธ by Yasir N.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file overwatch_monitor-0.1.0.tar.gz.
File metadata
- Download URL: overwatch_monitor-0.1.0.tar.gz
- Upload date:
- Size: 48.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2c4d2717e55d0e1f92eb0858224a07359aa56b2fd24a3b1374223a596227f03
|
|
| MD5 |
a6e216213bfb6c39c7e717f0d4098fd4
|
|
| BLAKE2b-256 |
c4621e1b2371a2febbbea895cbc56f1aff674c1a9e94f9d980e03a828fbb92ee
|
File details
Details for the file overwatch_monitor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: overwatch_monitor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c34299a975f9cabcc049d208f169f45c6bc976d379587350bb8b557541d7d28c
|
|
| MD5 |
ef3b824e7a698feba39fadab5313dff5
|
|
| BLAKE2b-256 |
01e38897335b2afefa80113ded3b9ffc1ae751a4d6c8e68fe8051364a623b8e7
|