A lightweight and extensible Bash script to analyze basic server performance statistics. Ideal for debugging, monitoring, or tracking system health over time. Second version of this project sets up a simple monitoring stack using Prometheus, Node Exporter, and Grafana using Docker Compose — with custom ports to avoid conflict with existing services like Outline.
The script server-stats.sh
provides the following information:
- ✅ Total CPU usage
- ✅ Memory usage (used, free, percentage)
- ✅ Disk usage (used, free, percentage)
- ✅ Top 5 processes by CPU
- ✅ Top 5 processes by Memory
- ✅ System info (uptime, OS version, load average, logged-in users)
- ✅ Failed SSH login attempts
- ✅ Daily logs saved with timestamp
- ✅ Automatic Git commit and push of logs
- Clone the repository:
git clone https://github.com/Ramtinboreili/monitoring-server.git
cd monitoring-server
- Make the script executable:
chmod +x server-stats.sh
- Create
logs/
directory (optional, auto-created on run):
mkdir -p logs
./server-stats.sh
This will:
- 🎨 Print all stats with colors to terminal
- 📝 Save a daily log to
logs/YYYY-MM-DD.log
- 🔄 Automatically commit and push the log file to GitHub (branch:
main
)
To automate daily reporting:
- Open your crontab:
crontab -e
- Add this line at the bottom:
0 22 * * * /bin/bash /full/path/to/monitoring-server/server-stats.sh
✅ Replace /full/path/to/...
with the absolute path to your script.
Log files are saved in the logs/
folder like this:
logs/
├── 2025-03-28.log
├── 2025-03-29.log
└── ...
Each log contains stats like:
===== CPU Usage =====
CPU Usage: 15.2%
===== Memory Usage =====
Used: 1048MB | Free: 512MB | Usage: 67.18%
...
- Prometheus (metrics collection) - exposed on
19090
- Node Exporter (host metrics)
- Grafana (visualization) - exposed on
13000
git clone https://github.com/your-username/monitoring-project.git
cd monitoring-project
docker compose up -d
- Requires Bash and standard Linux tools:
top
,ps
,df
,free
,lsb_release
,uptime
, etc. - Make sure your Git repo is initialized and connected to a remote (
origin
). - You should have SSH keys or GitHub token-based authentication set up for push to work without password prompts.
Ramtin Boreili
GitHub: @Ramtinboreili
🔥 If you'd like to improve this further (e.g. generate HTML/JSON reports, email daily summaries, or build a dashboard), just open an issue or fork the repo!