System Monitoring and API Project
This project includes a FastAPI application alongside a system health monitoring tool. The system tracks CPU, memory, disk usage, and SSH attempts, sending alerts to a Discord webhook when thresholds are exceeded.
-
FastAPI Application:
- A simple web API that responds to GET requests at
/with a "Hello World" message.
- A simple web API that responds to GET requests at
-
System Health Monitoring:
- Monitors CPU, memory, and disk usage.
- Tracks failed SSH login attempts.
- Sends real-time alerts to a Discord webhook.
-
Docker Integration:
- Fully containerized using Docker and Docker Compose.
-
Backup Automation:
- A bash script to automate database backups.
.
├── app.py # FastAPI application
├── health_monitor.py # System health monitoring script
├── backup.sh # Database backup script
├── setup.sh # Initial setup script
├── supervisord.conf # Supervisor configuration
├── docker-compose.yml # Docker Compose configuration
├── requirements.txt # Python dependencies
├── Dockerfile # Docker image definition
└── crontab # Cron job configuration for periodic tasks
- Docker and Docker Compose
- Python 3.9 or higher
- Git
-
Clone the Repository:
git clone <repository_url> cd <repository_folder>
-
Run Setup Script:
./setup.sh
-
Build and Start Services:
docker-compose up --build
-
Access FastAPI: Open your browser and navigate to
http://localhost:8000.
- Endpoint:
/ - Method:
GET - Response:
{ "message": "Hello World" }
- Starts automatically with Supervisor.
- Alerts are sent to the configured Discord webhook.
- Executes periodically via cron.
- Backup files are saved in the
./backupsdirectory.
- Configure the Discord webhook URL and other environment variables in a
.envfile.
Example .env file:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
- Configuration for Supervisor is provided in
supervisord.conf.
Install dependencies using requirements.txt:
pip install -r requirements.txtFeel free to fork this repository and submit pull requests. Ensure code quality by following PEP 8 guidelines.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy Coding!