This repository contains a set of Python and Bash scripts designed to monitor the health of a Linux system, automate backup tasks, analyze server log files, and check the health of applications. These scripts help system administrators automate critical monitoring and maintenance tasks, and quickly identify performance issues or failures in the system and applications.
The scripts are written in Python and Bash, and they provide useful reports and alerts based on predefined thresholds, ensuring proactive system management.
Monitors key system metrics such as:
- CPU Usage
- Memory Usage
- Disk Space
- Running Processes
If any of these metrics exceed predefined thresholds (e.g., CPU usage > 80%), the script sends alerts to the console or logs the results to a file.
Automates the backup of a specified directory to a remote server or cloud storage. It provides a report on the success or failure of the backup operation, ensuring data safety and reliability.
Analyzes web server logs (Apache, Nginx, etc.) to detect:
- 404 Errors (Failed page accesses)
- Most Requested Pages
- IP addresses with the Most Requests
The script generates a summarized report to help identify trends, errors, and potential performance bottlenecks.
Checks the uptime of an application by assessing its HTTP status codes. It reports if the application is "up" and functioning or "down" and unavailable, enabling quick action in case of failure.
To run these scripts, the following are required:
- Python 3.x: For executing the Python scripts.
- Bash: For executing the backup and log file analysis scripts.
- Linux-based system (or Windows Subsystem for Linux, WSL, on Windows).
- Required Python libraries: Listed in
requirements.txt.
-
Clone this repository to your local machine:
git clone <repository_url>
-
Navigate into the project directory:
cd SystemMonitoringScripts -
Install the necessary Python dependencies:
pip install -r requirements.txt
Run the following command to monitor system health:
python system_health.pyThis script will check system metrics and print alerts if thresholds are exceeded.
Run the following command to initiate the backup:
python backup.pyEnsure you modify the script to specify the source directory and remote backup destination.
Run the following command to analyze web server logs:
python log_analyzer.py /path/to/logfileThis will generate a report summarizing common patterns in the log file.
Run the following command to check the health of an application:
python app_health.py http://your-app-url.comThis will check the HTTP status of the application and report whether it's "up" or "down."
SystemMonitoringScripts/
├── README.md # Project documentation
├── system_health.py # System health monitoring script
├── backup.py # Automated backup script
├── log_analyzer.py # Log file analysis script
├── app_health.py # Application health checking script
├── logs/ # Directory for log files (empty initially, generated by script)
│ ├── system_health.log # Log file for system health monitoring (created dynamically)
├── .gitignore # Git ignore file to exclude unnecessary files from version control
└── requirements.txt # Python dependencies file
- Logs are stored in the
logs/directory, with thesystem_health.logfile capturing system health monitoring outputs. - You can extend the logging functionality in each script to include additional metrics or notifications as needed.