This Bash script monitors system resource usage, including disk, CPU, and memory utilization. It logs the data, raises alerts when usage exceeds a specified threshold, and sends an email notification if necessary.
- Monitors disk usage and alerts if usage exceeds the defined threshold.
- Displays current CPU usage.
- Displays current memory usage, including detailed breakdown.
- Lists top memory-consuming processes.
- Logs all outputs to a specified file.
- Sends an email notification when a threshold is breached.
./monitor.sh [-t threshold] [-f logfile]-t threshold: Set the disk usage threshold (default: 80%).-f logfile: Set the log file name (default:system_monitor.log).
./monitor.sh -t 85 -f my_log.logThis runs the script with an 85% disk usage threshold and logs to my_log.log.
- Linux-based OS
- Bash shell
df,top,free,awk,sed, andpscommandssendmailinstalled and configured for email notifications
- Clone the repository:
git clone https://github.com/your-username/system-monitor.git
- Navigate to the directory:
cd system-monitor - Make the script executable:
chmod +x monitor.sh
All outputs are logged in the specified log file. The default log file is system_monitor.log.
If a threshold is exceeded, an email alert is sent to the configured email address. Ensure that sendmail is installed and properly configured.
This project is licensed under the MIT License. Feel free to modify and distribute.
[Ahmed El-Hadad]