Lightweight Linux server health monitor with TUI and email alerts
Project description
🖥️ Server Health Monitor (SHM)
A lightweight, production-ready system health monitor for Linux servers. Beautiful terminal UI and email alerts — all from a single pip install.
✨ Features
- Interactive TUI — Full-screen terminal dashboard (like
htop, but for everything) - Email Alerts — Get notified when CPU, memory, disk, or swap cross thresholds
- Auto-start on Boot — One command to install as a systemd service
- Zero Config — Works out of the box with sensible defaults
- Lightweight — Only
psutil,PyYAML,loguru, andpydanticas core dependencies
📦 Installation
pip install server-health-monitor
🚀 Quick Start
1. Launch the TUI
monitor
Navigate with 1–6 or Tab to switch between views: Overview, Processes, Disk, Network, Alerts, and Config.
2. Run as Background Daemon
monitor --daemon
Collects metrics, checks thresholds, and sends email alerts — no UI.
🔧 Configuration
SHM reads from config.yaml in the current directory (or pass --config /path/to/config.yaml).
Default Config
thresholds:
cpu_percent: 85.0
memory_percent: 85.0
disk_percent: 90.0
swap_percent: 80.0
alerts:
enabled: true
cooldown_minutes: 5
log_file: alerts.jsonl
smtp:
enabled: false
host: smtp.gmail.com
port: 587
username: ""
password: ""
from_addr: admin@example.com
to_addrs:
- alerts@example.com
use_tls: true
collection_interval: 5
metrics_log: metrics.jsonl
You can also edit the config directly in the TUI — press 6 to go to the Config tab, use arrow keys to navigate, Enter to edit, and s to save.
📧 Email Alerts Setup
Gmail (Recommended)
-
Create a Google App Password
Go to https://myaccount.google.com/apppasswords and generate a 16-character app password. -
Update your config:
smtp: enabled: true host: smtp.gmail.com port: 587 username: "you@gmail.com" password: "abcd efgh ijkl mnop" # your app password from_addr: "you@gmail.com" to_addrs: - "alerts@yourcompany.com" use_tls: true
-
Test it — Set
cpu_percent: 1.0temporarily and run:monitor --daemonYou should receive an email within seconds.
Important: The TUI (
monitor) is display-only. Email alerts are sent by the daemon (monitor --daemon) or the systemd service.
🔄 Auto-Start on Boot (systemd)
Install SHM as a system service so the alerting daemon starts automatically on every boot:
sudo monitor --install
This will:
- Copy a default config to
/etc/shm/config.yaml - Register and enable a
shmsystemd service - Start the daemon immediately
After Installation
# Edit config (set your SMTP credentials, thresholds, etc.)
sudo nano /etc/shm/config.yaml
# Apply changes
sudo systemctl restart shm
Management Commands
| Command | Description |
|---|---|
sudo systemctl status shm |
Check if daemon is running |
sudo systemctl restart shm |
Restart after config changes |
sudo journalctl -u shm -f |
Watch live logs |
sudo monitor --uninstall |
Remove the service |
Note: The systemd service runs independently. You can still use
monitor(TUI) at any time for interactive monitoring.
🎮 TUI Keyboard Reference
Global
| Key | Action |
|---|---|
1–6 / Tab |
Switch view |
Shift+Tab |
Previous view |
? |
Show help overlay |
q |
Quit |
Processes View
| Key | Action |
|---|---|
↑ ↓ |
Select process |
/ |
Search by name or PID |
s |
Cycle sort (CPU → MEM → PID → Name) |
k |
Kill selected process (with confirmation) |
Esc |
Clear search |
Config View
| Key | Action |
|---|---|
↑ ↓ |
Navigate fields |
Enter |
Edit field value |
s |
Save config to disk |
📊 What Gets Monitored?
| Category | Metrics |
|---|---|
| CPU | Total %, per-core %, load average, temperature (if available) |
| Memory | Used/total, percentage, available, cached, buffers, swap |
| Disk | All mounted partitions — used/total/free per mount |
| Network | RX/TX rates, total bytes, per-interface stats, errors/drops |
| Processes | PID, name, user, CPU%, MEM%, status — sortable and searchable |
📁 File Structure
After running, SHM creates these files in the working directory:
| File | Purpose |
|---|---|
config.yaml |
Configuration (thresholds, SMTP, intervals) |
metrics.jsonl |
Timestamped metric snapshots (auto-rotated at 10k lines) |
alerts.jsonl |
Alert history log |
monitor.log |
Application log (rotated at 10 MB) |
🔍 Troubleshooting
monitor: command not found
Make sure the package is installed and the Python scripts directory is in your PATH:
pip install server-health-monitor
# If using a venv:
source venv/bin/activate
Not receiving emails
- Ensure you are running the daemon (
monitor --daemon) or the systemd service — the TUI alone does not send emails. - Verify
smtp.enabled: truein your config. - Check that you're using a Google App Password, not your regular password.
- Check logs:
sudo journalctl -u shm -fortail -f monitor.log.
Some metrics are missing
Network connection details and listening ports require elevated privileges:
sudo monitor
🏗️ Development
# Clone the repo
git clone https://github.com/Jayanth1312/server-health-monitor.git
cd server-health-monitor
# Create a virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in editable mode
pip install -e .
# Run
monitor
📜 License
MIT License — see LICENSE for details.
🙏 Credits
Built by Jayanth Paladugu — GitHub
If you find this useful, give it a ⭐ on GitHub!
Project details
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 server_health_monitor-1.0.0.tar.gz.
File metadata
- Download URL: server_health_monitor-1.0.0.tar.gz
- Upload date:
- Size: 39.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
911a2cd51bf678ffeebd71d3f461047195981d3802ca31a5d3496063af339327
|
|
| MD5 |
bbb6791b018c59214fe723d6b5982f6c
|
|
| BLAKE2b-256 |
ff87fe3a86e2fb83fe448f0ca491ae49956a18dc946b2ad331cca9eb6ab686ea
|
File details
Details for the file server_health_monitor-1.0.0-py3-none-any.whl.
File metadata
- Download URL: server_health_monitor-1.0.0-py3-none-any.whl
- Upload date:
- Size: 39.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f731c30dedbb29277d0aee672114c7d8074115ac314e2a5749ddc6decc30178b
|
|
| MD5 |
f533018eeb7ce4e11cdf71f7ac9bce7d
|
|
| BLAKE2b-256 |
5dd063c3ff83b0d718e360e515e52705e0fec1ceec4be9ef9674640de1f64c5a
|