A bash script to analyze and monitor Linux server performance statistics.
https://roadmap.sh/projects/server-stats GitHub Repository: https://github.com/Shegxy69/Server-Performance-Stat Project Page: https://shegxy69.github.io/Server-Performance-Stat/
This script provides comprehensive server performance metrics including:
- Total CPU usage
- Memory usage (total, used, free, percentage)
- Disk usage (total, used, free, percentage)
- Top 5 processes by CPU usage
- Top 5 processes by memory usage
- OS version and system information
- System uptime and load average
- Currently logged in users
- Failed login attempts
- Real-time server performance monitoring
- Easy-to-read formatted output
- No external dependencies (uses built-in Linux commands)
- Can be automated with cron jobs
- Supports log file generation
- Linux operating system (tested on AlmaLinux 9.6)
- Bash shell
- Basic Linux commands:
top,free,df,ps,uptime,who sudoaccess (optional, for failed login attempts)
- Clone this repository:
git clone https://github.com/Shegxy69/Server-Performance-Stat.git
cd Server-Performance-Stat- Make the script executable:
chmod +x server-stats.shRun the script as a normal user:
./server-stats.shsudo ./server-stats.sh========================================
SERVER PERFORMANCE STATS
========================================
1. Total CPU Usage:
-------------------
CPU Usage: 0.0%
2. Total Memory Usage:
----------------------
Total Memory: 1771 MB
Used Memory: 738 MB
Free Memory: 653 MB
Memory Usage: 41.67%
3. Total Disk Usage:
--------------------
Total Disk: 17G
Used Disk: 5.1G
0AFree Disk: 12G
Disk Usage: 30%
### Automated Monitoring with Cron
Schedule the script to run automatically:
### Run daily at 9:00 AM
```bash
crontab -e
# Add this line:
0 9 * * * /path/to/server-stats.sh > /path/to/logs/server-stats-$(date +\%Y\%m\%d).log 2>&1
0 * * * * /path/to/server-stats.sh > /path/to/logs/server-stats-$(date +\%Y\%m\%d-\%H\%M).log 2>&1This project demonstrates:
- Bash scripting fundamentals
- Linux system administration
- Server monitoring techniques
- Text processing with
awk,sed,grep - Process management
- Automation with cron
- How to write bash scripts from scratch
- Understanding Linux system metrics (CPU, memory, disk)
- Using text processing tools to extract d
- Automating tasks with cron jobs
- Git and GitHub basics
- DevOps fundamentals
Issue: Permission denied
chmod +x server-stats.shIssue: Cannot see failed login attempts
sudo ./server-stats.shGitHub: @Shegxy69
Live Repository: https://github.com/Shegxy69/Server-Performance-Stat
This project is open source and available under the MIT License.
- Project inspired by DevOps learning path
- Thanks to the Linux community for excellent documentation
⭐ If you found this helpful, please star this repository!