Lightweight monitoring adapter bridging Glances metrics with Uptime Kuma
Project description
GlanceWatch ๐ฏ
GlanceWatch is a lightweight monitoring adapter that bridges Glances system metrics with Uptime Kuma and other monitoring tools. It exposes simple HTTP endpoints with configurable thresholds that answer: "Is my system healthy?"
โจ Features
- ๐ฏ Simple HTTP Endpoints: Returns HTTP 200 (OK) or 503 (unhealthy) based on thresholds
- ๐จ Web UI: Modern dashboard with sliders to configure thresholds in real-time
- โ๏ธ Configurable Thresholds: Set custom limits for RAM, CPU, and disk usage
- ๐พ Persistent Configuration: Changes saved to config.yaml automatically
- ๏ฟฝ Easy Installation: Just
pip install glancewatch- everything included! - ๐ Multiple Disk Monitoring: Monitor all or specific mount points
- ๐ฅ Health Checks: Built-in health endpoint for service monitoring
- ๐ OpenAPI Docs: Auto-generated API documentation at
/docs - ๐ Real-Time Metrics: Auto-refreshing dashboard shows live system status
๐ Quick Start
Prerequisites: Glances must be installed and running
One-Line Install (Ubuntu/Debian)
curl -sSL https://raw.githubusercontent.com/collinskramp/glancewatch/main/install-pip.sh | bash
This installs Glances, GlanceWatch, and sets up systemd services automatically!
Manual Installation
1. Install and Start Glances
# Ubuntu/Debian
sudo apt install -y glances
glances -w
# macOS
brew install glances
glances -w
# Or via pip
pip install glances
glances -w
2. Install GlanceWatch
# Install from PyPI
pip install glancewatch
3. Run GlanceWatch
glancewatch
That's it! ๐
Access the dashboard:
- Web UI: http://localhost:8000/configure/
- API Docs: http://localhost:8000/docs
- Status Endpoint: http://localhost:8000/status
See INSTALL.md for detailed instructions, systemd setup, and troubleshooting.
๐ก API Endpoints
Core Monitoring Endpoints
GET /status
Overall system status combining all metrics.
{
"ok": true,
"ram": {
"ok": true,
"value": 45.2,
"threshold": 80.0,
"unit": "%"
},
"cpu": {
"ok": true,
"value": 32.5,
"threshold": 80.0,
"unit": "%"
},
"disk": {
"ok": true,
"disks": [
{
"mount_point": "/",
"percent_used": 62.3,
"size_gb": 500.0,
"ok": true
}
],
"threshold": 85.0
},
"last_check": "2025-11-11T10:30:00"
}
GET /ram
RAM usage check.
{
"ok": true,
"value": 45.2,
"threshold": 80.0,
"unit": "%",
"last_check": "2025-11-11T10:30:00"
}
GET /cpu
CPU usage check (average across all cores).
{
"ok": true,
"value": 32.5,
"threshold": 80.0,
"unit": "%",
"last_check": "2025-11-11T10:30:00"
}
GET /disk
Disk usage check for monitored mount points.
{
"ok": true,
"disks": [
{
"mount_point": "/",
"fs_type": "ext4",
"percent_used": 62.3,
"size_gb": 500.0,
"used_gb": 311.5,
"free_gb": 188.5,
"ok": true
}
],
"threshold": 85.0,
"last_check": "2025-11-11T10:30:00"
}
Utility Endpoints
GET /health
Service health check.
{
"status": "healthy",
"version": "1.0.0",
"glances_connected": true,
"glances_url": "http://localhost:61208",
"uptime_seconds": 3600.5,
"timestamp": "2025-11-11T10:30:00"
}
GET /config
View current configuration.
{
"glances_base_url": "http://localhost:61208",
"thresholds": {
"ram_percent": 80.0,
"cpu_percent": 80.0,
"disk_percent": 85.0
},
"disk_mounts": ["/"],
"timestamp": "2025-11-11T10:30:00"
}
PUT /config
Update monitoring thresholds (also available via Web UI).
Request:
{
"thresholds": {
"ram_percent": 75.0,
"cpu_percent": 85.0,
"disk_percent": 90.0
}
}
Response:
{
"ok": true,
"message": "Configuration updated successfully",
"thresholds": {
"ram_percent": 75.0,
"cpu_percent": 85.0,
"disk_percent": 90.0
}
}
Changes are persisted to /var/lib/glancewatch/config.yaml and take effect immediately.
Web UI
Access the configuration interface at http://localhost:8100/ui
- Dashboard: Real-time metrics with visual indicators
- Sliders: Adjust RAM, CPU, and Disk thresholds (10-100%)
- Persistence: Changes saved automatically to config.yaml
- Auto-refresh: Dashboard updates every 5 seconds
- Status Colors:
- ๐ข Green: < 75% of threshold
- ๐ก Yellow: 75-90% of threshold
- ๐ด Red: > 90% of threshold
โ๏ธ Configuration
Environment Variables
Create a .env file or set environment variables:
# Glances Connection
GLANCES_BASE_URL=http://localhost:61208
GLANCES_TIMEOUT=5
# Server Settings
HOST=0.0.0.0
PORT=8000
# Thresholds (0-100)
RAM_THRESHOLD=80.0
CPU_THRESHOLD=80.0
DISK_THRESHOLD=85.0
# Disk Monitoring
DISK_MOUNTS=/ # Single mount
# DISK_MOUNTS=/,/home,/data # Multiple mounts
# DISK_MOUNTS=all # All mounts
DISK_EXCLUDE_TYPES=tmpfs,devtmpfs,overlay,squashfs
# Error Handling
RETURN_HTTP_ON_FAILURE= # 200 with ok=false (default)
# RETURN_HTTP_ON_FAILURE=503 # Return 503 on failure
# Logging
LOG_LEVEL=INFO
YAML Configuration
Create ~/.config/glancewatch/config.yaml (or /var/lib/glancewatch/config.yaml in Docker):
glances_base_url: http://localhost:61208
glances_timeout: 5
host: 0.0.0.0
port: 8000
thresholds:
ram_percent: 80.0
cpu_percent: 80.0
disk_percent: 85.0
disk:
mounts:
- /
- /home
exclude_types:
- tmpfs
- devtmpfs
log_level: INFO
Note: Environment variables override YAML settings.
๐ Uptime Kuma Integration
Add GlanceWatch to Uptime Kuma for automatic alerting:
- Add New Monitor in Uptime Kuma
- Monitor Type: HTTP(s)
- URL:
http://your-server:8000/status - Heartbeat Interval: 20 seconds (or your preference)
- Expected Status Code: 2xx (for success)
- Save
How it works:
- โ HTTP 200: All thresholds OK (Uptime Kuma shows GREEN/UP)
- โ ๏ธ HTTP 503: One or more thresholds exceeded (Uptime Kuma shows RED/DOWN and alerts)
Configure your thresholds via the Web UI at http://your-server:8000/configure/
See INSTALL.md for detailed setup instructions.
๐ณ Docker Deployment (Optional)
If you prefer Docker, a docker-compose.yml is included that runs both Glances and GlanceWatch:
git clone https://github.com/collinskramp/glancewatch.git
cd glancewatch/docker
docker-compose up -d
Access:
- GlanceWatch: http://localhost:8000
- Glances Web UI: http://localhost:61208
See INSTALL.md for more deployment options.
โ๏ธ Configuration
Configure via Web UI (easiest) or edit config file.
Web UI (Recommended)
Visit http://localhost:8000/configure/ and use the sliders to adjust thresholds.
Config File
Config is stored at ~/.config/glancewatch/config.yaml:
thresholds:
ram_percent: 80.0
cpu_percent: 80.0
disk_percent: 85.0
Environment Variables
export GLANCEWATCH_GLANCES_URL=http://localhost:61208
export GLANCEWATCH_RAM_THRESHOLD=80.0
export GLANCEWATCH_CPU_THRESHOLD=80.0
export GLANCEWATCH_DISK_THRESHOLD=85.0
glancewatch
See INSTALL.md for complete configuration options.
๐งช Testing
Run the test suite:
# Install dev dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/ -v
# With coverage
pytest tests/ --cov=app --cov-report=html
๐ Example Use Cases
1. Alert When RAM Exceeds 80%
# Set threshold
export RAM_THRESHOLD=80
# Monitor endpoint
curl http://localhost:8000/ram
# Returns: {"ok": false, "value": 85.2, ...} when exceeded
2. Monitor Multiple Disks
# Monitor root and data partitions
export DISK_MOUNTS=/,/data
curl http://localhost:8000/disk
3. Integration with Scripts
#!/bin/bash
RESPONSE=$(curl -s http://localhost:8000/status)
OK=$(echo $RESPONSE | jq -r '.ok')
if [ "$OK" != "true" ]; then
echo "System unhealthy!"
# Send notification, trigger action, etc.
fi
๐ ๏ธ Development
Code Quality
# Format code
black app/ tests/
# Lint
ruff check app/ tests/
# Type checking
mypy app/
Project Structure
glancewatch/
โโโ app/
โ โโโ __init__.py # Package initialization
โ โโโ main.py # FastAPI application
โ โโโ monitor.py # Core monitoring logic
โ โโโ config.py # Configuration management
โ โโโ models.py # Pydantic data models
โ โโโ api/
โ โโโ __init__.py
โ โโโ health.py # Health check endpoint
โโโ tests/
โ โโโ test_monitor.py # Monitor tests
โ โโโ test_api.py # API endpoint tests
โโโ docker/
โ โโโ Dockerfile # Container image
โ โโโ docker-compose.yml # Development stack
โโโ requirements.txt # Production dependencies
โโโ requirements-dev.txt # Development dependencies
โโโ README.md # This file
๐ง Troubleshooting
Glances Connection Failed
Problem: "error": "Failed to fetch RAM data"
Solutions:
- Check Glances is running:
ps aux | grep glances - Verify Glances API:
curl http://localhost:61208/api/3/mem - Check
GLANCES_BASE_URLconfiguration - Ensure Glances web server is enabled:
glances -w
High False Positive Rate
Problem: Alerts trigger too frequently
Solutions:
- Increase thresholds:
RAM_THRESHOLD=90 - Adjust check interval in monitoring tool
- Use
/statusfor combined health (all metrics must fail)
Docker Container Unhealthy
Problem: Health checks failing
Solutions:
- Check logs:
docker logs glancewatch - Verify Glances connectivity from container
- Increase health check timeout in compose file
๐ License
MIT License - see LICENSE file for details.
๐ Support & Contributing
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ Documentation:
- Installation Guide
- API Documentation (when running)
- Ubuntu Quickstart
๐ Acknowledgments
- Glances - Excellent cross-platform monitoring tool
- Uptime Kuma - Self-hosted monitoring solution
- FastAPI - Modern Python web framework
Made with โค๏ธ for the self-hosted community
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 glancewatch-1.0.0.tar.gz.
File metadata
- Download URL: glancewatch-1.0.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
404048e289a5a14c91aeadb963b3350fb1efa973e8e8d3088afc90bde862b4be
|
|
| MD5 |
ac5204f503ed1d0d5ec47e93c62e1885
|
|
| BLAKE2b-256 |
933e640c4f7b55e8625932404a8210cde7546078978c4d22cc2d4ff5799b9079
|
File details
Details for the file glancewatch-1.0.0-py3-none-any.whl.
File metadata
- Download URL: glancewatch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
976bc3e8f5ce4077744c6eae00476150b90ff6aa9a13660f12fdb5cf6f8e3d86
|
|
| MD5 |
7a223b9ed1a8a562663878640f773e55
|
|
| BLAKE2b-256 |
3c67edf4ca42348151cdb071df739716035239b6e6fae80aa1900cd0fe81c235
|