A lightweight and portable Bash script to analyze and monitor basic server performance metrics on any Linux system.
This project is designed for DevOps engineers, system administrators, and developers who need quick insights into server health without installing heavy monitoring tools.
- Total CPU usage
- Memory usage (Used vs Free with percentage)
- Disk usage (Used vs Free with percentage)
- Top 5 processes by CPU usage
- Top 5 processes by Memory usage
- OS version
- System uptime
- Load average
- Logged-in users
- Failed login attempts (SSH)
This script works on most Linux distributions such as:
- Ubuntu / Debian
- CentOS / RHEL
- Kali Linux
- Arch Linux
bashtopfreedfpsawkgrep
git clone https://github.com/your-username/server-stats.gitcd server-statschmod +x server-stats.shExecute the script using:
./server-stats.sh=========================================
SERVER PERFORMANCE STATS
=========================================
CPU Usage:
Used: 18.4%
Memory Usage:
Used: 2100MB (52.5%)
Free: 1900MB (47.5%)
Disk Usage:
Used: 25G (50%)
Free: 25G
Top 5 Processes by CPU Usage:
PID COMMAND %CPU
1234 chrome 35.0
5678 node 20.5
Top 5 Processes by Memory Usage:
PID COMMAND %MEM
1234 chrome 15.2
5678 node 10.1
Additional Stats:
OS: Ubuntu 22.04 LTS
Uptime: up 2 hours
Load Average: 0.45, 0.60, 0.75
Logged in users: 2
Failed login attempts: 5
=========================================
The script uses standard Linux commands:
| Metric | Command Used |
|---|---|
| CPU Usage | top |
| Memory Usage | free |
| Disk Usage | df |
| Processes | ps |
| OS Info | /etc/os-release |
| Uptime | uptime |
| Logs | /var/log/auth.log |
You can schedule this script using cron jobs:
crontab -eExample: Run every 5 minutes
*/5 * * * * /path/to/server-stats.sh >> /var/log/server-stats.log- Add colored output for readability
- Threshold-based alerts (CPU/Memory/Disk)
- Export metrics to JSON or CSV
- Send alerts via Email / Slack
- Build a web dashboard (Flask / Node.js)
- Integrate with Prometheus & Grafana
- Quick server health monitoring
- Debugging performance bottlenecks
- Lightweight alternative to heavy monitoring tools
- DevOps learning project
- Cloud VM monitoring
Contributions are welcome!
- Fork the repository
- Create a new branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License.
Prem Krishna
If you found this project helpful, please consider giving it a star on GitHub! https://roadmap.sh/projects/server-stats